GithubHelp home page GithubHelp logo

conor19w / binance-futures-trading-bot Goto Github PK

View Code? Open in Web Editor NEW
502.0 27.0 168.0 98.66 MB

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

Python 99.93% Dockerfile 0.07%
technical-analysis binance trading-bot trading-strategies cryptocurrency trading bot bitcoin ethereum perpetual

binance-futures-trading-bot's Introduction

Binance-Futures-Trading-Bot Tweet

Technical Analysis driven Crypto Trading bot on Binance Futures ๐Ÿ“ˆ โ‚ฟ ๐Ÿš€

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. (currently working on new documentation)
  • If you enjoy the repo please share it around to friends & tweet about it using the tweet button above ๐Ÿ˜ƒ
    or Buy me a Coffee

This Bot currently only works on windows OS, in future I hope to support linux but I don't have the time right now


This Bot utilizes:

  • python-Binance Client to execute orders and pull data from Binance
  • ta library for Technical indicators
  • plotly for generating interactive Trade graphs.
  • tabulate for logging trades in a table format
  • colorlog for adding colour to logs

Important for live trading on windows:

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 TradingStrats.py as functions and then referenced in Bot_Class.Bot.make_decision()

  • Make_decision() must return Trade_Direction, stop_loss_val, take_profit_val for the strategy to work properly
  • You might draw inspiration for a strategy from one of the samples in TradingStrats.py
    Docs are being updated currently for the new bot
    Create Custom Strategies
    Create Custom TP/SL functions

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
  • Fill in your api keys into api_secret and api_key in live_trading_config.py

Running the live trading bot

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_trading.py

Settings are in live_trading_config.py

  • Trade a single position at a time by setting max_number_of_positions = 1, to trade multiple coins just increment this value.
  • leverage and order_size should be changed according to your preference
  • symbols_to_trade[] is a list of the symbols you wish to trade, If you wish to trade all symbols set trade_all_symbols = True.
  • Trailing stop: set use_trailing_stop = True and change trailing_stop_callback 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. (Not functioning currently, this needs updated for new bot)
  • trading_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 is the type of take profit and stop loss you want to use valid choices are: USDT, %, x (ATR), x (Swing High/Low) level 1, x (Swing High/Low) level 2, x (Swing High/Low) level 3, x (Swing Close) level 1, x (Swing Close) level 2, x (Swing Close) level 3
  • SL_mult and TP_mult are multipliers for the TP_SL_choice
    Example:
    TP_SL_choice = 'USDT'
    SL_mult = 1
    TP_mult = 2
    This configuration will set TP and SL values at $1 loss and $2 gain respectively
  • Choose the interval you want to trade, valid intervals are: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d.

YouTube Channels with Strategy Ideas:

Quantopian Lectures | 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

binance-futures-trading-bot's People

Contributors

conor19w avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binance-futures-trading-bot's Issues

Quantity less than or equal to zero.

10-09-2023 10:35:58 INFO: Account Balance: $10.35, Total profit: $0, Wins: 0, Losses: 0, Win/Loss ratio: Not available yet, No Open Positions
10-09-2023 10:37:00 WARNING: open_trade() - error occurred placing limit order on BTCUSDT, OP: 3, tick_size: 0.1 Entry price: 25828.2, trade direction: 0, Quantity: 0.0, Error Info: (BinanceAPIException(<Response [400]>, 400, '{"code":-4003,"msg":"Quantity less than or equal to zero."}'), 'trade_manager.py', 315), Error: APIError(code=-4003): Quantity less than or equal to zero.

multiple strategy

hi, currenly i manual running multi instance of bot
can you add func that bot work with a list of strategy and log will summary data of each strategy
thanks for nice project

Bot cannot run ubuntu os. Pls help!!!

I had error when running bot on ubuntu 22.04, python 3.11
Traceback (most recent call last):
File "/usr/local/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.11/site-packages/binance/threaded_stream.py", line 59, in run
self._loop.run_until_complete(self.socket_listener())
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 629, in run_until_complete
self._check_running()
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 588, in _check_running
raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
/usr/local/lib/python3.11/threading.py:1047: RuntimeWarning: coroutine 'ThreadedApiManager.socket_listener' was never awaited
self._invoke_excepthook(self)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
How to fix it???

Error occurred during live_trading

open_trade() - error occurred placing limit order on XRPUSDT, OP: 1, tick_size: 0.0001 Entry price: 0.5176, trade direction: 1, Quantity: 58.1, Error Info: (BinanceAPIException(<Response [400]>, 400, '{"code":-4061,"msg":"Order's position side does not match user's setting."}'), 'trade_manager.py', 293), Error: APIError(code=-4061): Order's position side does not match user's setting.
29-08-2023 17:47:00 ERROR: new_trades_loop() - error occurred, Error Info: (IndexError('list index out of range'), 'trade_manager.py', 67), Error: list index out of range

trading_strategy = 'tripleEMAStochasticRSIATR'
leverage = 10
order_size = 2 ## % of account
interval = '1m'
TP_SL_choice = '%'
SL_mult = .1 ## SL_mult x TP_SL_choice = SL value
TP_mult = .1 ## TP_mult x TP_SL_choice = TP value
trade_all_symbols = False
symbols_to_trade = ['BTCUSDT','ETHUSDT','XRPUSDT']
use_trailing_stop = False
trailing_stop_callback = .1
trading_threshold = .1 ## used to cancel trades that have moved this distance in % away from our attempted entry price
use_market_orders = False
max_number_of_positions = 5

I got this error and I want to know why this error happened and how to fix it

Mexc

Can we use it for Mexc?

the bot does not start

PS C:\Users\komp\Desktop\Binance-Futures-Trading-Bot-main> python --version
Python 3.7.0
PS C:\Users\komp\Desktop\Binance-Futures-Trading-Bot-main> python LiveTrading.py
Traceback (most recent call last):
File "LiveTrading.py", line 7, in
import SharedHelper
File "C:\Users\komp\Desktop\Binance-Futures-Trading-Bot-main\SharedHelper.py", line 3, in
import BotClass
File "C:\Users\komp\Desktop\Binance-Futures-Trading-Bot-main\BotClass.py", line 55
match self.strategy:
^
SyntaxError: invalid syntax

Following Binance APIs are deprecated.

Some v1 futures private endpoints are being deprecated.
image

ex)
BinanceAPIException(<Response [400]>, 400, '{"code":-5000,"msg":"GET /fapi/v1/balance is retired, please use GET /fapi/v2/balance"}')

BinanceAPIException(<Response [400]>, 400, '{"code":-5000,"msg":"GET /fapi/v1/positionRisk is retired, please use GET /fapi/v2/positionRisk"}')

how can i switch it to v2?

Backtest results

Hi @conor19w -

I was just going thru the code.. great job!!.

Have u had the chance to run backtest on the various strategies? do u have the results already that we can have a look at?

I am planning to start the backtest.. but in case u have already done it.. plz share.

Combining historical data with live data issue (Fix suggestion)

def get_historical(symbol,start_string,Interval):
Open = []
High = []
Low = []
Close = []
Volume = []
Date = []
try:
for kline in client.futures_historical_klines(symbol, Interval,start_str=start_string):
Date.append(datetime.utcfromtimestamp(round(kline[0]/1000)))
Open.append(float(kline[1]))
Close.append(float(kline[4]))
High.append(float(kline[2]))
Low.append(float(kline[3]))
Volume.append(float(kline[7]))
except BinanceAPIException as e:
print(e)
return Date,Open,Close,High,Low,Volume

In that block of code is small issue. client.futures_historical_klines(symbol, Interval,start_str=start_string) will return historical data but last [-1] candle is current active candle which is never closed. This is causing issue in calculating strategy later because when new last candle is added Close[-2] does not reflect actual previous candle close but reflect current value of candle in time of historical data pull.
To fix this do pop before processing data:

hist_data = client.futures_historical_klines(symbol, Interval,start_str=start_string)
hist_data.pop(-1)
for kline in hist_data:
      ........

Heikin_Ashi Strategy, TSL

Hi @conor19w ,

Do u happen to have the heikin_ashi strategy? is it easy to incorporate in the current bot?

Also TSL (trailing stop loss or trailing take profit) would be a great option to maximize profits.

Do u have any plans to add these?

web socket problem

Symbol: GALAUSDT Start Balance: -99
<class 'binance.exceptions.BinanceAPIException'> Bot.py 728
Error in websocket, Restarting
Account Balance: 1833.02999368 Profit: 0
Task exception was never retrieved
future: <Task finished name='Task-5' coro=<ThreadedApiManager.start_listener() done, defined at /home/boss/conor2/.env/lib/python3.8/site-packages/binance/threaded_stream.py:42> exception=UnboundLocalError("local variable 'Date' referenced before assignment")>
Traceback (most recent call last):
File "/home/boss/conor2/.env/lib/python3.8/site-packages/binance/threaded_stream.py", line 52, in start_listener
callback(msg)
File "Bot.py", line 556, in handle_socket_message
Date = flow.dataStream(Date, datetime.utcfromtimestamp(round(float(payload['t'])/1000)), 1, 300)
UnboundLocalError: local variable 'Date' referenced before assignment
<class 'binance.exceptions.BinanceAPIException'> Bot.py 728
Error in websocket, Restarting
Account Balance: 1833.02999368 Profit: 0
<class 'binance.exceptions.BinanceAPIException'> Bot.py 728
Error in websocket, Restarting

Is this line correct?

https://github.com/conor19w/Binance-Futures-Bot/blob/a962a0d9505b1c2afcd0f4ec53cdbbd13074d41e/Bot_Class.py#L140

Is this line correct? Or should it be referencing -1 index on OPEN_H?
It is an append statement so for example:
Close_H length =300
Open_H length =300
self.Close_H.append((self.Open[-1] + self.Close[-1] + self.Low[-1] + self.High[-1]) / 4)
Close_H length =301
Open_H length =300
Current:
self.Open_H.append((self.Open_H[-2] + self.Close_H[-2]) / 2)-> self.Open_H.append((self.Open_H[-299] + self.Close_H[-300]) / 2)
What may be the correction:
self.Open_H.append((self.Open_H[-1] + self.Close_H[-2]) / 2) -> self.Open_H.append((self.Open_H[-300] + self.Close_H[-300]) / 2)

Close_H length =301
Open_H length =301

Error on start (backtest)

Loading Price Data
Traceback (most recent call last):
File "Bot.py", line 826, in
price_data = load(f"C:\Users\conor\Desktop\plots_mean\Equity_Curves_{TIME_INTERVAL}\price_data.joblib")
File "/home/ubuntu/.local/lib/python3.8/site-packages/joblib/numpy_pickle.py", line 579, in load
with open(filename, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\conor\Desktop\plots_mean\Equity_Curves_15\price_data.joblib'

Please add requirements file as well

the bot was not tracking trade can you tell me what is the problem

C:\Users\soumy\Binance-Futures-Trading-Bot>python Live_Bot.py
Setting Leverage...
Starting BTCUSDT web socket
BTCUSDT 3 2
Starting ETHUSDT web socket
ETHUSDT 3 2
Starting BCHUSDT web socket
BCHUSDT 3 2
Starting XRPUSDT web socket
XRPUSDT 1 4
Starting EOSUSDT web socket
EOSUSDT 1 3
Starting LTCUSDT web socket
LTCUSDT 3 2
Starting TRXUSDT web socket
TRXUSDT 0 5
Starting ETCUSDT web socket
ETCUSDT 2 3
Starting LINKUSDT web socket
LINKUSDT 2 3
Starting XLMUSDT web socket
XLMUSDT 0 5
Starting ADAUSDT web socket
ADAUSDT 0 5
Starting XMRUSDT web socket
XMRUSDT 3 2
Starting DASHUSDT web socket
DASHUSDT 3 2
Starting ZECUSDT web socket
ZECUSDT 3 2
Starting XTZUSDT web socket
XTZUSDT 1 3
Starting BNBUSDT web socket
BNBUSDT 2 3
Starting ATOMUSDT web socket
ATOMUSDT 2 3
Starting ONTUSDT web socket
ONTUSDT 1 4
Starting IOTAUSDT web socket
IOTAUSDT 1 4
Starting BATUSDT web socket
BATUSDT 1 4
Starting VETUSDT web socket
VETUSDT 0 6
Starting NEOUSDT web socket
NEOUSDT 2 3
Starting QTUMUSDT web socket
QTUMUSDT 1 3
Starting IOSTUSDT web socket
IOSTUSDT 0 6
Starting THETAUSDT web socket
THETAUSDT 1 4
Starting ALGOUSDT web socket
ALGOUSDT 1 4
Starting ZILUSDT web socket
ZILUSDT 0 5
Starting KNCUSDT web socket
KNCUSDT 0 5
Starting ZRXUSDT web socket
ZRXUSDT 1 4
Starting COMPUSDT web socket
COMPUSDT 3 2
Starting OMGUSDT web socket
OMGUSDT 1 4
Starting DOGEUSDT web socket
DOGEUSDT 0 6
Starting SXPUSDT web socket
SXPUSDT 1 4
Starting KAVAUSDT web socket
KAVAUSDT 1 4
Starting BANDUSDT web socket
BANDUSDT 1 4
Starting RLCUSDT web socket
RLCUSDT 1 4
Starting WAVESUSDT web socket
WAVESUSDT 1 4
Starting MKRUSDT web socket
MKRUSDT 3 2
Starting SNXUSDT web socket
SNXUSDT 1 3
Starting DOTUSDT web socket
DOTUSDT 1 3
Starting DEFIUSDT web socket
DEFIUSDT 3 1
Starting YFIUSDT web socket
YFIUSDT 3 1
Starting BALUSDT web socket
BALUSDT 1 3
Starting CRVUSDT web socket
CRVUSDT 1 3
Starting TRBUSDT web socket
TRBUSDT 1 3
Starting RUNEUSDT web socket
RUNEUSDT 0 4
Starting SUSHIUSDT web socket
SUSHIUSDT 0 4
Starting EGLDUSDT web socket
EGLDUSDT 1 3
Starting SOLUSDT web socket
SOLUSDT 0 4
Starting ICXUSDT web socket
ICXUSDT 0 4
Starting STORJUSDT web socket
STORJUSDT 0 4
Starting BLZUSDT web socket
BLZUSDT 0 5
Starting UNIUSDT web socket
UNIUSDT 0 4
Starting AVAXUSDT web socket
AVAXUSDT 0 4
Starting FTMUSDT web socket
FTMUSDT 0 6
Starting ENJUSDT web socket
ENJUSDT 0 5
Starting FLMUSDT web socket
FLMUSDT 0 4
Starting TOMOUSDT web socket
TOMOUSDT 0 4
Starting RENUSDT web socket
RENUSDT 0 5
Starting KSMUSDT web socket
KSMUSDT 1 3
Starting NEARUSDT web socket
NEARUSDT 0 4
Starting AAVEUSDT web socket
AAVEUSDT 1 3
Starting FILUSDT web socket
FILUSDT 1 3
Starting RSRUSDT web socket
RSRUSDT 0 6
Starting LRCUSDT web socket
LRCUSDT 0 5
Starting MATICUSDT web socket
MATICUSDT 0 5
Starting OCEANUSDT web socket
OCEANUSDT 0 5
Starting BELUSDT web socket
BELUSDT 0 5
Starting CTKUSDT web socket
CTKUSDT 0 5
Starting AXSUSDT web socket
AXSUSDT 0 5
Starting ALPHAUSDT web socket
ALPHAUSDT 0 5
Starting ZENUSDT web socket
ZENUSDT 1 3
Starting SKLUSDT web socket
SKLUSDT 0 5
Starting GRTUSDT web socket
GRTUSDT 0 5
Starting 1INCHUSDT web socket
1INCHUSDT 0 4
Starting CHZUSDT web socket
CHZUSDT 0 5
Starting SANDUSDT web socket
SANDUSDT 0 5
Starting ANKRUSDT web socket
ANKRUSDT 0 6
Starting LITUSDT web socket
LITUSDT 1 3
Starting UNFIUSDT web socket
UNFIUSDT 1 3
Starting REEFUSDT web socket
REEFUSDT 0 6
Starting RVNUSDT web socket
RVNUSDT 0 5
Starting SFPUSDT web socket
SFPUSDT 0 4
Starting XEMUSDT web socket
XEMUSDT 0 4
Starting COTIUSDT web socket
COTIUSDT 0 5
Starting CHRUSDT web socket
CHRUSDT 0 4
Starting MANAUSDT web socket
MANAUSDT 0 4
Starting ALICEUSDT web socket
ALICEUSDT 1 3
Starting HBARUSDT web socket
HBARUSDT 0 5
Starting ONEUSDT web socket
ONEUSDT 0 5
Starting LINAUSDT web socket
LINAUSDT 0 5
Starting STMXUSDT web socket
STMXUSDT 0 5
Starting DENTUSDT web socket
DENTUSDT 0 6
Starting CELRUSDT web socket
CELRUSDT 0 5
Starting HOTUSDT web socket
HOTUSDT 0 6
Starting MTLUSDT web socket
MTLUSDT 0 4
Starting OGNUSDT web socket
OGNUSDT 0 4
Starting NKNUSDT web socket
NKNUSDT 0 5
Starting DGBUSDT web socket
DGBUSDT 0 5
Starting 1000SHIBUSDT web socket
1000SHIBUSDT 0 6
Starting BAKEUSDT web socket
BAKEUSDT 0 4
Starting GTCUSDT web socket
GTCUSDT 1 3
Starting BTCDOMUSDT web socket
BTCDOMUSDT 3 1
Starting IOTXUSDT web socket
IOTXUSDT 0 5
Starting AUDIOUSDT web socket
AUDIOUSDT 0 4
Starting C98USDT web socket
C98USDT 0 4
Starting MASKUSDT web socket
MASKUSDT 0 4
Starting ATAUSDT web socket
ATAUSDT 0 4
Starting DYDXUSDT web socket
DYDXUSDT 1 3
Starting 1000XECUSDT web socket
1000XECUSDT 0 5
Starting GALAUSDT web socket
GALAUSDT 0 5
Starting CELOUSDT web socket
CELOUSDT 1 3
Starting ARUSDT web socket
ARUSDT 1 3
Starting KLAYUSDT web socket
KLAYUSDT 1 4
Starting ARPAUSDT web socket
ARPAUSDT 0 5
Starting CTSIUSDT web socket
CTSIUSDT 0 4
Starting LPTUSDT web socket
LPTUSDT 1 3
Starting ENSUSDT web socket
ENSUSDT 1 3
Starting PEOPLEUSDT web socket
PEOPLEUSDT 0 5
Starting ANTUSDT web socket
ANTUSDT 1 3
Starting ROSEUSDT web socket
ROSEUSDT 0 5
Starting DUSKUSDT web socket
DUSKUSDT 0 5
Starting FLOWUSDT web socket
FLOWUSDT 1 3
Starting IMXUSDT web socket
IMXUSDT 0 4
Starting API3USDT web socket
API3USDT 1 4
Starting GMTUSDT web socket
GMTUSDT 0 5
Starting APEUSDT web socket
APEUSDT 0 4
Starting WOOUSDT web socket
WOOUSDT 0 5
Starting JASMYUSDT web socket
JASMYUSDT 0 6
Starting DARUSDT web socket
DARUSDT 1 4
Starting GALUSDT web socket
GALUSDT 0 5
Starting OPUSDT web socket
OPUSDT 1 7
Starting INJUSDT web socket
INJUSDT 1 6
Starting STGUSDT web socket
STGUSDT 0 7
Starting FOOTBALLUSDT web socket
FOOTBALLUSDT 2 5
Starting SPELLUSDT web socket
SPELLUSDT 0 7
Starting 1000LUNCUSDT web socket
1000LUNCUSDT 0 7
Starting LUNA2USDT web socket
LUNA2USDT 0 7
Starting LDOUSDT web socket
LDOUSDT 0 6
Starting CVXUSDT web socket
CVXUSDT 0 6
Starting ICPUSDT web socket
ICPUSDT 0 6
Starting APTUSDT web socket
APTUSDT 1 5
Starting QNTUSDT web socket
QNTUSDT 1 6
Starting BLUEBIRDUSDT web socket
BLUEBIRDUSDT 1 5
Starting FETUSDT web socket
FETUSDT 0 7
Starting FXSUSDT web socket
FXSUSDT 1 6
Starting HOOKUSDT web socket
HOOKUSDT 1 6
Starting MAGICUSDT web socket
MAGICUSDT 1 6
Starting TUSDT web socket
TUSDT 0 7
Starting RNDRUSDT web socket
RNDRUSDT 1 6
Starting HIGHUSDT web socket
HIGHUSDT 1 6
Starting MINAUSDT web socket
MINAUSDT 0 7
Starting ASTRUSDT web socket
ASTRUSDT 0 7
Starting AGIXUSDT web socket
AGIXUSDT 0 7
Starting PHBUSDT web socket
PHBUSDT 0 7
Starting GMXUSDT web socket
GMXUSDT 2 6
Starting CFXUSDT web socket
CFXUSDT 0 7
Starting STXUSDT web socket
STXUSDT 0 7
Starting BNXUSDT web socket
BNXUSDT 1 6
Starting ACHUSDT web socket
ACHUSDT 0 7
Starting SSVUSDT web socket
SSVUSDT 2 6
Starting CKBUSDT web socket
CKBUSDT 0 7
Starting PERPUSDT web socket
PERPUSDT 1 6
Starting TRUUSDT web socket
TRUUSDT 0 7
Starting LQTYUSDT web socket
LQTYUSDT 1 6
Starting USDCUSDT web socket
USDCUSDT 0 7
Starting IDUSDT web socket
IDUSDT 0 7
Starting ARBUSDT web socket
ARBUSDT 1 6
Starting JOEUSDT web socket
JOEUSDT 0 7
Starting TLMUSDT web socket
TLMUSDT 0 7
Starting AMBUSDT web socket
AMBUSDT 0 7
Starting LEVERUSDT web socket
LEVERUSDT 0 7
Starting RDNTUSDT web socket
RDNTUSDT 0 7
Starting HFTUSDT web socket
HFTUSDT 0 7
Starting XVSUSDT web socket
XVSUSDT 1 6
Starting BLURUSDT web socket
BLURUSDT 0 7
Starting EDUUSDT web socket
EDUUSDT 0 7
Starting IDEXUSDT web socket
IDEXUSDT 0 7
Starting SUIUSDT web socket
SUIUSDT 1 6
Starting 1000PEPEUSDT web socket
1000PEPEUSDT 0 7
Starting 1000FLOKIUSDT web socket
1000FLOKIUSDT 0 7
Starting UMAUSDT web socket
UMAUSDT 0 6
Starting RADUSDT web socket
RADUSDT 0 6
Starting KEYUSDT web socket
KEYUSDT 0 7
Starting COMBOUSDT web socket
COMBOUSDT 1 6
Starting NMRUSDT web socket
NMRUSDT 1 6
Combining Historical and web socket data...
Start Balance: 110.0
Account Balance: 110.0, 2023-06-27 03:54:00: Active Trades: []
wins: 0, losses: 0, Total Profit: 0.0
Account Balance: 110.0, 2023-06-27 03:55:00: Active Trades: []
wins: 0, losses: 0, Total Profit: 0.0
Account Balance: 110.0, 2023-06-27 03:57:00: Active Trades: []
wins: 0, losses: 0, Total Profit: 0.0

Live_Bot.py - ImportError: cannot import name 'ThreadedWebsocketManager' from 'binance'

Hi I encounter this import error when running "python3 app.py" also I've already check the cause of the issue and to solve it we just need to add .streams when importing ThreadedWebsocketManager from binance. Thanks.

Live_Bot.py:
from pprint import PrettyPrinter
import sys, os
from binance.client import Client
from binance.exceptions import BinanceAPIException
from binance.streams import ThreadedWebsocketManager
from datetime import datetime, date, timedelta
from threading import Thread
from multiprocessing import Process, Pipe
import time

image

Incorrect trailing stop calculation for long positions

Trailing stop is calculating long position profits as short position and therefore calculation on the end is wrong . Please see marked issue and suggested correction

cashout.append({'x': i, 'y': trailing_stop_value, 'type': "win", 'position': 'short',

Suggestion

cashout.append({'x': i, 'y': trailing_stop_value, 'type': "win", 'position': 'long', 'Profit': positionSize * (trailing_stop_value - positionPrice)})

Error Process

Hey, really amazing code! thank you!
i'm having this issue with the backtesting, can you help me?

Process Process-1:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\multiprocessing\process.py", line 314, in _bootstrap
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\X\Downloads\Binance-Futures-Bot-main\Binance-Futures-Bot-main\Backtester.py", line 300, in run_backtester
average /= num_wins
ZeroDivisionError: division by zero

Issue

How can i close a position based on the Trade_Direction change? like a parameter if the direction inverts the trade close the position, how can i do this?

NameError: name 'np' and 'pd' is not defined

Loading Price Data
Symbols: ['SANDUSDT'] Start Balance: 1000 fee: 0.00036
15 min OHLC Candle Sticks from a period of 30 day
Traceback (most recent call last):
File "Bot.py", line 938, in
prediction[j], signal1, Type[j] = TS.RSIStochEMA(prediction[j],CloseStream[j],HighStream[j],LowStream[j],signal1,CurrentPos[j])
File "/home/boss/conorbot/TradingStrats.py", line 402, in RSIStochEMA
CloseS = pd.Series(CloseStream)
NameError: name 'pd' is not defined

.......................................

Symbols: ['SANDUSDT'] Start Balance: 1000 fee: 0.00036
15 min OHLC Candle Sticks from a period of 7 day
Traceback (most recent call last):
File "Bot.py", line 939, in
prediction[j],Type[j]=TS.tripleEMA(CloseStream[j],OpenStream[j],prediction[j])
File "/home/boss/conorbot/TradingStrats.py", line 353, in tripleEMA
EMA3 = np.array(ema_indicator(pd.Series(CloseStream), window=5))
NameError: name 'np' is not defined

Unable to use Heikin Ashi with new bot

The Heikin Ashi strategy in TradingStrats.py refers to variables in the deprecated Bot.

Does anyone have an updated Heikin Ashi function working with the new Bot ?

Trade multiple coins at same time

Hi @conor19w

Thanks for sharing the code.

I was looking to trade multiple coins at the same time by providing a list. From the code it looks like we can trade only 1 coin at a time.

Do u think that is possible to modify the code to trade multiple coins at same time?

Also some comments on the strategies would help understand them better.

ZeroDivisionError: division by zero

image
Coins Tradeable : ['STGUSDT']
Loading Price Data
Loading STGUSDT
Data doesnt exist in path: .//price_data//STGUSDT_01-02-23_18-02-23.joblib, Downloading Data to specified path now...
Downloading CandleStick Data for STGUSDT...
Saving Price data
Download Successful, Loading Data now
Aligning Data Sets... This may take a few minutes
['STGUSDT']
15m OHLC Candle Sticks from 01-02-23 to 18-02-23
Account Balance: 100.0

single positional indexer is out-of-bounds

Settings:
leverage: 5
order_size: 0.0125
fee: 0.00036
symbol = []

Overall Stats based on all coins
Trades Made: 0
Process Process-3:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\desenvolvimento\projetos\python\Binance-Futures-Trading-Bot-main\Backtester.py", line 483, in run_backtester
print("Accuracy: ", f"{(len(winning_trades) / tradeNO) * 100}%", "\n")
ZeroDivisionError: division by zero
Coins Tradeable : ['STGUSDT']
Loading Price Data
Loading STGUSDT
Aligning Data Sets... This may take a few minutes
['STGUSDT']
15m OHLC Candle Sticks from 01-02-23 to 18-02-23
Account Balance: 100.0

No open position at all

I just stack here, and no open position at all. my setting like this

2021-12-13T03:57:05.000000+00:00 app[api]: Build succeeded
2021-12-13T03:57:19.644698+00:00 app[worker.1]: Combining Historical and web socket data...
2021-12-13T03:58:06.248546+00:00 app[worker.1]: Finished.
2021-12-13T03:58:06.411248+00:00 app[worker.1]: Start Balance: 201.14444027

start_string = '4 hour'  
Interval = '30m'  
leverage = 15 
order_Size = .03 

Can you upload a video on youtube?, that your code it's proven work properly. Thank you!

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.