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.