I got commissioned to create this TG bot for a trading signals channel before they decided to go awol and not pay me (that's my excuse for no tests). So sharing it here for anyone that may find it useful.
The bot must be an admin of the channel in order for it to work.
You send a message to your channel in this format:
๐ฎ๐ค๐ฎ๐ค๐ฎ๐ค (emojis optional)
Pair: BTCUSDT <-- the pair as it is written on bybit
Direction: Long
Entry: 27025 <- entry price
TP1: 27100 <-- price targets
TP2: 27200
TP3: 27300
SL: 26950 <-- stop loss
The bot parses this message, stores the open trade in a mongoDB and subscribes to price updates from the bybit api.
It then tracks the targets, sends updates to the channel when the targets are hit & keeps track of trading stats (these are available through commands).
mvn clean install
to build the .jar (you can run standalone with just the jar, fill out the application.properties with your config and make sure you have a mongoDB running somewhere).- for docker, place the .jar in the docker folder and run
docker build . --tag=signal-bot
inside that folder. - you can then fill out the docker-compose.yaml with your config & and
docker-compose up -d
โโโ docker
โ โโโ docker-compose.yaml
โ โโโ dockerfile
โโโ pom.xml
โโโ README.md
โโโ src
โ โโโ main
โ โ โโโ java
โ โ โ โโโ com
โ โ โ โโโ popfendi
โ โ โ โโโ bots
โ โ โ โ โโโ SignalBot.java
โ โ โ โโโ client
โ โ โ โ โโโ BybitWebsocket.java
โ โ โ โ โโโ Client.java -- handles conn to bybit
โ โ โ โโโ config
โ โ โ โ โโโ ArgsParser.java -- parses cmd line args
โ โ โ โ โโโ PropertiesLoader.java -- loads external props
โ โ โ โโโ handlers
โ โ โ โ โโโ EarningsCommand.java -- handler for /earnings cmd
โ โ โ โ โโโ ListCommand.java -- handler for /list command
โ โ โ โ โโโ MessageHandler.java -- handler for non command msgs
โ โ โ โ โโโ StatsCommand.java -- hander for /stats command
โ โ โ โ โโโ StreamHandler.java -- handler for data stream from bybit
โ โ โ โโโ Main.java
โ โ โ โโโ models
โ โ โ โ โโโ Direction.java
โ โ โ โ โโโ PriceData.java
โ โ โ โ โโโ Signal.java
โ โ โ โ โโโ Stats.java
โ โ โ โ โโโ Targets.java
โ โ โ โโโ repository
โ โ โ โโโ DataManager.java -- holds most of the data handling logic
โ โ โ โโโ MongoDBClient.java -- db client
โ โ โโโ resources
โ โ โโโ application.properties -- config
โ โ โโโ delta.json -- example event from bybit
โ โ โโโ fail.json -- example event from bybit
โ โ โโโ snapshot.json -- example event from bybit
โ โโโ test
โ
โโโ target
I've tried to comment the code in a clear and concise way to read through the code and it should make sense.