nikhilkumarrathi / cryptotrader-telegram

A Telegram bot written in Python which provides various Cryptocurrency Trading features, and Technical Analysis using Binance API.
MIT License
51 stars 19 forks source link
binance binance-api hobby-project python telegram-bot

This is an unplanned tool that turned into something nice and so useful. I was playing with Python, and Binance API when I realized that there are many things that I check so frequently, wouldn't it be nice to just fire a command from the Phone and get an answer within seconds? Or what about scheduling something to run over and over without having to remember it.

This tool is a Telegram bot, that supports various Trading commands by authorized handles. The Backend APIs are provided by Binance which supports quite a lot of features for Cryptocurrency Trading.

Prerequisites of this Tool

Running the tool

  1. Install Dependencies pip install -r requirements.txt
  2. Run the script python bot.py --log=INFO|DEBUG
  3. Or run with Docker: ./docker.sh In case you haven't configured it already, you will get a message. Please follow the next section for Configuration.

Configuration

The Configuration is a JSON file maintained at the following location: config/config.json. The directory also contains a Template file which should be used to configure it.

Please fill the following details in the config file.

  "telegramApiKey": "----",
  "binanceApiKey": "----",
  "binanceApiSecret": "----",
  "adminUserId": "--Telegram handle excluding @--"
  "adminChatId": "--Telegram Number ID ---"

https://bigone.zendesk.com/hc/en-us/articles/360008014894-How-to-get-the-Telegram-user-ID-

You can also provide some other UserIDs to give access to other accounts for certain Commands. You can create a named group under accessContro.groups node and provide a list of telegram userIDs.

  "accessControl": {
    "groups": {
    "private": [ "----","---"],
    ...

Configure adminChatId for CLI messages Telegram Messages needs a Chat ID to respond to. The Chat ID can be known when a message is sent from Telegram. Look into the Logs and find the from.id. Use this to configure adminChatId configuration.

Features Overview

Screenshots

Commands

Asset Management Commands

Command Details Examples
symboladd adds a Symbol in local store /symboladd ADA
symbolrm remove a Symbol in local store /symbolrm ADA
now Current Price of all Assets in USD /now
hot Any movement in prices in last N slots of given timeframe above percentage threshold /hot 5m 6 3
All Assets with price movements of 3% in 6x5m window

Trading Commands

Command Parameters Examples
bal Get Balance of all Assets /bal
balpie Get Pie chart of all balances, easier to know the weitage of each asset /balpie
snapshot Get a snapshot of all Assets in the account /snapshot
snapshotbal Get the Price of the snapshot taken last time (and Blame yourself in hindsight) /snapshotbal
TODO

Technical Analysis Commands

Command Parameters Examples
ta Technical Analysis on Predefined Charts /ta ADA 1h 1000
Find TA of the Assets with 1h timeframe and 1000 bars
hints Result of Technical Analysis without Charts /hints ADA 1h 1000
Find TA of the Assets with 1h timeframe and 1000 bars

Scheduling

Command Parameters Examples
schdinfo Get the list of all Schedules commands /schdinfo
schd Create a Scheduled Command /schd 600 bal
Get Balance in you accound in every 600 seconds
schdcancel Cancel all Commands with given command name /schdcancel bal
It will cancel all scheduled /bal commands

Conditional Commands

Command Parameters Examples
Ifabove Run another command if the price of the asset is ABOVE the specified value
Ifbelow Run another command if the price of the asset is BELOW the specified value

Modules Used

Docker

Build it: docker build --tag chatbot-telegram:0.1 .

Run it: docker run -it chatbot-telegram:0.1

ToDo