Giter Site home page Giter Site logo

tg-bybit-signalsbot's Introduction

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.

tg-bybit-signalsbot's People

Contributors

popfendi avatar

Stargazers

Strydex avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.