A Technical Analysis Bot that trades leveraged USDT futures markets on Binance.

conor19w conor19w Last update: Mar 18, 2023

Binance-Futures-Trading-Bot Tweet

Technical Analysis driven Crypto Trading bot on Binance Futures 📈🚀 Tweet

Join My public Discord Server & Follow The Twitter

  • Comes with 11 pre-built strategies found in TradingStrats.py
  • See Documentation below to implement your TA strategies.
  • If you enjoy the repo please share it around to friends & tweet about it using the tweet button above 😃
    or Buy me a Coffee
  • Utilizes python-Binance Client to execute orders and pull data from Binance
  • Utilizes ta library for Technical indicators
  • Utilizes plotly for generating interactive Trade graphs.
  • Set up windows to sync time once a day if you don't do this binance will eventually reject orders with a timestamp error.

Creating Custom Strategies:

Strategies are implemented in Bot_Class as functions in Make_decision()

Binance Setup

  • Create a Binance Account (This link uses my referral which gives you 5% kickback on trades & would be greatly appreciated)
  • Enable Two-factor Authentication in the security section to keep your crypto safe.
  • Create a new API key under the API Management section.
  • [✓] Read Info [✓] Enable Trading [✓] Enable Futures [X] Enable Withdrawals
  • Whitelist your IP address to further secure your account, and so that your API keys don't expire after 3 months.
  • Fill in your api keys into api_secret and api_key in Config_File.py

For running Bot with cloud provider, Run directly from Live_Bot.py as you can't use the GUI through ssh

Run strategies at your own risk I am not responsible for your trading decisions, futures are risky and proper risk management should be adhered to at all times, always have a stoploss

python3 Live_Bot.py
  • Settings are in Config_File.py
  • Trade a single position at a time by setting Number_Of_Trades = 1, to trade multiple coins just increment this value.
  • leverage and order_Size should be changed according to your preference
  • symbol[] is a list of the symbols you wish to trade, If you wish to trade all symbols set Trade_All_Coins = True.
  • Trailing stop: set use_trailing_stop = 1 and change trailing_stop_percent to suit your strategy to use the trailing stop (Min val .001 i.e .1%, Max 5 i.e. 5%). The trailing stop will be placed when the take profit value margin of increase/decrease is reached from your strategy.
  • To close a trade based off a condition check_close_pos() must return a close_pos flag.
  • strategy is the name of the strategy you want to use, see below for adding your own custom strategies.
  • There are 11 default strategies to choose from: StochRSIMACD, tripleEMAStochasticRSIATR, tripleEMA, breakout, stochBB, goldenCross, candle_wick, fibMACD, EMA_cross, heikin_ashi_ema2 & heikin_ashi_ema
  • TP_SL_choice correspond to the type of SL/TP seen in the dropdowns in the GUI see below for adding custom ones.
  • SL_mult and TP_mult correspond to the numbers preceding the TP and SL choice dropdowns.
  • Choose the Interval you want to trade and the buffer of candlesticks your strategy will need this will be dependent on indicators you need to ensure you have a sufficient buffer, or you will get errors.
  • Buffer sizes should be about 5 times the length of your largest EMA. In TradingStrats.py you'll find all the strategies, taking tripleEMAStochasticRSIATR as an example:
    That strategy has a 50EMA as its largest EMA, so you need at least 250 candles. If you're trading the:
    • 1m timeframe this would be 250 minutes buffer
    • 3m timeframe would be 750 minutes buffer
    • 5m timeframe would be 1250 minutes buffer etc...
      (not sure that this is valid buffer input but you can convert these amounts to hours/ days)

Docker container creation:

  • Navigate to the project directory in your terminal window
  • Run the following Command this will create a docker image with the current state of your Config.py and choice of strategy in Bot_Class.py:

Sample docker commands that I use, note yours may be different (sudo may not be needed for you, I am on Linux):

sudo docker build --tag live_bot .
sudo docker run -it live_bot

GUI for Backtesting and Live Trading

  • Run app.py to get the GUI
python3 app.py

Backtests are displayed in the terminal while running, the results are then saved to a csv file in the Backtests directory along with a graph image and trades taken graphs (see below).

  • Otherwise run a backtest from the Backtester.py Script by configuring the inputs found in:
__name__ == "__main__":

Backtests are saved in a folder named backtests on completion of a backtest, along with a csv file of the trades taken. An interactive html file is generated for each trade (using plotly), so you can do analysis on winning and losing trades.

YouTube Channels with Strategy Ideas:

Silicon Trader | Trade Pro | Strategy Testing | Trading Journal | The Moving Average

TO-DO List:

Trello Board

Contact me Tweet

  • Prioritise your Trello ticket with a one time payment
  • Get Custom Strategies made to your specifications by reaching out to me on discord for a quote price.
  • If you have any queries about anything, or need me to explain any blocks of code please reach out to me on Discord.
  • If you have any suggestions or requests please reach out to me as well. Join My public Discord Server & Follow The Twitter

Subscribe to our newsletter