whispin / TG-Bybit-SignalsBot

TG bot for Tracking and Alerting trading signals using bybit api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TG / Bybit trading signals bot

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.

How it works

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).

Usage

  1. 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).
  2. for docker, place the .jar in the docker folder and run docker build . --tag=signal-bot inside that folder.
  3. you can then fill out the docker-compose.yaml with your config & and docker-compose up -d

Project Structure

โ”œโ”€โ”€ 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.

About

TG bot for Tracking and Alerting trading signals using bybit api


Languages

Language:Java 100.0%