Code Monkey home page Code Monkey logo

binance-trading-bot's Introduction

Dynamic Binance Trading Bot

Description

This Binance trading bot analyses the changes in price across all coins on Binance it constructs so called "market resistance" and "market support" based on those prices and buys coins that pass support lines and sells coins that pass resistance line.

Internal Operation

  • Bot automatically creates list from binance coins and sorts it based on volume or price changes
  • Bot then scans price changes based on given time interval and creates market resistance and support
  • Bot puts coins that passed support line into trailing buy and waits for price to stop falling and then places a buy
  • Bot then monitors bought coins and pools for prices every recheck interval and if price is over market resistance activates trailing stoploss
  • Bot sells coin and logs if its win or loss for internal calculations (dynamic settings adjustment, stoploss etc)
  • Bot adjuststs all settings based on previous win/loss ratio and based on accumulated profit detects
  • Bot recreates list and restarts cycle

Features

  • Automatic coins list creation polling binance coins list
  • Automatic list sorting based on VOLUME or PRICECHANGE
  • Automatic stoploss modification based on closed trades percent and win/loss ratio
  • Automatic buy treshold based on market support and TAKE PROFIT based on market resistance
  • Automatic buy trailing based on price dropping/rising
  • Automatic session restart after bot stopped with all current strategies
  • Reporting to discord channel and telegram optional
  • Automatic changing of settings from config file on the fly based on wins / losses

WIKI

https://github.com/goranjovic55/Binance-Trading-Bot/wiki

READ BEFORE USE

  1. If you use the TEST_MODE: False in your config, you will be using REAL money.
  2. To ensure you do not do this, ALWAYS check the TEST_MODE configuration item in the config.yml file..

DISCORD CHANNEL

https://discord.gg/AjJYXy3C

💥 Disclaimer

All investment strategies and investments involve risk of loss. Nothing contained in this program, scripts, code or repositoy should be construed as investment advice. Any reference to an investment's past or potential performance is not, and should not be construed as, a recommendation or as a guarantee of any specific outcome or profit. By using this program you accept all liabilities, and that no claims can be made against the developers or others connected with the program.

binance-trading-bot's People

Contributors

freshlondon avatar goranjovic55 avatar jlefebvre59 avatar lorvent avatar masonlyons avatar row-bear avatar yaka996 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

Watchers

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

binance-trading-bot's Issues

AttributeError: 'dict' object has no attribute 'moving_averages'

Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/joey/Desktop/BinanceBot/modules/pausebotmod.py", line 69, in do_work
paused = analyze()
File "/home/joey/Desktop/BinanceBot/modules/pausebotmod.py", line 53, in analyze
ma_analysis = analysis.moving_averages[TYPE]
AttributeError: 'dict' object has no attribute 'moving_averages'

session uptime doesn't take shutdown period in account

Session uptime is calculated by time difference between start and now.
If I start a session, shut it down after a minute, then start bot again 24 hours later, uptime will show 24 hours.
Actual active time is ~2 minutes

use market resistance and support for price change calculations

use resistance and support for pricechange calculations and threshold in wait for price
maybe we can drop the signals completely and then have pure binance lists (with more pairs)
limit maximum time difference and recheck interval to some normal numbers maybe too?

decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

Tickers CREATED from Binance tickers!!!tickers/tickers_USDT.txt <<
Tickers sort List tickers/tickers_USDT.txt by volume<<
[2021-11-07 21:29:52] Press Ctrl-Q to stop the script
[2021-11-07 21:29:52] No modules to load None
Traceback (most recent call last):
File "C:\crypto\Binance-Trading-Bot\Binance_Detect_Moonings.py", line 205, in
report('message', 'Bot initiated')
File "C:\crypto\Binance-Trading-Bot\bot\report.py", line 96, in report
+ str(round(settings_struct['CHANGE_IN_PRICE_MIN'], 2)) + '/'
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

Fix minimun TAKE PROFIT

I think it's a bad idea there is no limit bottom limit of dynamic TAKE PROFIT ....

under 0.4 , 0.3 ... it's very difficult to really take profit. ( Fee, Order take with Market ... )

ERROR BUY volume

[2021-09-07 16:30:53] BUY_VOLATILE_COINS: {'ADAUSDT': Decimal('-0.821'), 'COSUSDT': Decimal('-1.152882615156017830609212481')}
[2021-09-07 16:30:53] ERROR BUY volume ADAUSDT : Volume too lower/not enought (minNotional)
[2021-09-07 16:30:53] ERROR BUY volume COSUSDT : Volume too lower/not enought (minNotional)

'dict' error

Using USDT as pair

Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/pbp/goranjovic55/Binance-Trading-Bot/pausebotmod.py", line 59, in do_work
paused = analyze()
File "/home/pbp/goranjovic55/Binance-Trading-Bot/pausebotmod.py", line 44, in analyze
ma_analysis = analysis.moving_averages[TYPE]
AttributeError: 'dict' object has no attribute 'moving_averages'

Parsing of values from config

Either -2 or -.5 as value for SL/TP in config result in error.
input is interpreted as string, then rounding fails

Stop Loss Bug

Hi,

Stop Loss don't work as expected. I start a test session with default parameters in config.yml (STOP_LOSS: 3)

The "STOP_LOSS" variable in session_info.json is filled with strange numbre like this:

4433.675640106201
9683876534.500877
4.759015155419072e+16
3.034450382939706e+25
6.132429670462307e+74
6.6884224795857e+193

On first buy of some coins the SL start with huge numbers:
TP:1.28:2.39 or SL:-4484690756570124023740448572080896602373552377797895937321755711979170249294191028339175364001004076712027837302784460278942709748430728250434827881423120834402557335323044126654464.00:-359321429097838669505640101637343327859453470871260005056995556301422959179011934669454782998943547413225179896825135179135730388922616458931735518059590156283531749735606361497010176.00 not yet reached, not selling ADAUSDT for now >> Bought at: 1.24810000 - Now: 1.24460000 : -0.28% Est: -0.06 USDT - CIP: -0.63/-0.51 - TAKE_PROFIT: 2.39

Eventually after a while the SL in both session_info.json and in test_coins_bought.json (or coins_bought.json) stay stuck on NaN

So there's no stop loss at all and only the TRAILING_STOP_LOSS trigger a change from NaN to a normal value.

BUSD throws discord error

Since discord image for BUSD doesn't exist, it throws an error.

Starting ta_indicator_signalmod_firewatch
Traceback (most recent call last):
  File "Binance_Detect_Moonings.py", line 1125, in <module>
    bot_launch()
  File "Binance_Detect_Moonings.py", line 947, in bot_launch
    report('message', bot_message)
  File "Binance_Detect_Moonings.py", line 716, in report
    data = {"username" : BOT_ID , "avatar_url": discord_avatar(), "content": bot_message}
  File "Binance_Detect_Moonings.py", line 735, in discord_avatar
    return DISCORD_AVATAR
UnboundLocalError: local variable 'DISCORD_AVATAR' referenced before assignment

Bot (sometimes) crashes on live-net when selling coins (and if restarted trade_slots is not being updated)

[2021-08-09 09:01:41] TP or SL reached, selling 0.893 WAVESBUSD. Bought at: 16.83300000 (Price now: 16.86300000) - 0.18% - Est: 0.03 BUSD
[2021-08-09 09:01:41] TP or SL reached, selling 10.54 WRXBUSD. Bought at: 1.42310000 (Price now: 1.42070000) - -0.17% - Est: -0.03 BUSD
[2021-08-09 09:01:42] Sold WAVESBUSD, removed order ID 110980828 from history.
[2021-08-09 09:01:42] Sold WRXBUSD, removed order ID 63935702 from history.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.9/http/client.py", line 1345, in getresponse
response.begin()
File "/usr/lib/python3.9/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.9/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.9/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

AND

[2021-08-09 12:06:35] TP:52.08:0.11 or SL:50.99:-2.00 not yet reached, not selling PSGBUSD for now >> Bought at: 52.02700000 - Now: 51.17600000 : -1.64% Est: -0.25 BUSD - CIP: -0.10/-0.08 - TAKE_PROFIT: 0.09
[2021-08-09 12:06:35] Sold ZECBUSD, removed order ID 100776316 from history.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.9/http/client.py", line 1345, in getresponse
response.begin()
File "/usr/lib/python3.9/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.9/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.9/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 702, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.9/http/client.py", line 1345, in getresponse
response.begin()
File "/usr/lib/python3.9/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.9/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.9/socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.9/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/hugo/Binance-Trading-Bot/Binance_Detect_Moonings.py", line 215, in
reload_tickers()
File "/home/hugo/Binance-Trading-Bot/bot/tickers_list.py", line 124, in reload_tickers
tickers_list(SORT_LIST_TYPE)
File "/home/hugo/Binance-Trading-Bot/bot/tickers_list.py", line 52, in tickers_list
tickers_binance = client.get_ticker()
File "/usr/local/lib/python3.9/dist-packages/binance/client.py", line 998, in get_ticker
return self._get('ticker/24hr', data=params, version=self.PRIVATE_API_VERSION)
File "/usr/local/lib/python3.9/dist-packages/binance/client.py", line 237, in _get
return self._request_api('get', path, signed, version, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/binance/client.py", line 202, in _request_api
return self._request(method, uri, signed, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/binance/client.py", line 196, in _request
self.response = getattr(self.session, method)(uri, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

Error while selling

Sometimes there's an error while selling and the session abort.

[2021-07-26 11:30:23] TP or SL reached, selling 44.04 COCOSUSDT. Bought at: 0.68340000 (Price now: 0.68280000)  - -0.09% - Est: -0.03 USDT
Traceback (most recent call last):
  File "/home/jay/Bureau/Binance-Trading-Bot/Binance_Detect_Moonings.py", line 212, in <module>
    trade_crypto()
  File "/home/jay/Bureau/Binance-Trading-Bot/bot/trade.py", line 472, in trade_crypto
    coins_sold = sell_coins()
  File "/home/jay/Bureau/Binance-Trading-Bot/bot/trade.py", line 348, in sell_coins
    report_struct['report'] = REPORT
UnboundLocalError: local variable 'REPORT' referenced before assignment

The coin is sold but at next start it's still referenced in coins_bought.json and the slot is still counted as used in session_info.json.

auto ticker generation needs attention

Reminder to self to check the ticker generation ->remove hardcoded filter for UP and DOWN
Think how to handle signal samples
add top(x) option to avoid loading all pairs

dynamic applying to SL even when dynamic settings disabled

I have disabled stoploss DYNAMIC_SETTINGS: False
Yet, i see that dynamic stoploss is being applied

Time: 18.61 | Interval: 1 | Price change min/max: -0.39/-0.34% | Stop loss: 0.1 | Take profit: 0.18 | Trailing stop loss: 0.48 | Trailing take profit: 0.01 | Holding time limit: 3349.56
STOP_LOSS - SELL: 10.253 QTUMUSDT - Bought at 6.50, sold at 6.49 - Profit: -0.18 USDT (-0.12%)
Trade slots: 8/15 (533.333/1000 USDT) | Session: -9.64720108 USDT (-11.63%) | Win/Loss: 8/11 (42.11%) | Gains: -0.9647% | Balance: 990.35 | Value: 990.35 USD | Value gain: -9.65 | Uptime: 10:12:10

thanks

No modules to load None

Hi
I am getting following errors? Is it normal ? Nothing happens if i wait too much though.
Thank you..
Annotation 2021-08-28 213700

trying to send sell Message even if Telegram disabled

hey, you did nice Progress so far
I did a Testrun this morning and it crashed on 1st sell trigger with Telegram disabled in config:

[2021-06-07 07:24:55] TP or SL reached, selling 51 POWRETH - 9.645e-05 - 9.705e-05 : 0.62% Est: 0.00003110 ETH Traceback (most recent call last): File "Binance_Detect_Moonings.py", line 922, in <module> coins_sold = sell_coins() File "Binance_Detect_Moonings.py", line 525, in sell_coins report('message', f"Sell: {coins_sold[coin]['volume']} {coin} - {BuyPrice} - {LastPrice} Profit: {profit:.{decimals()}f} {PriceChange-(TRADING_FEE*2):.{decimals()}f}%") File "Binance_Detect_Moonings.py", line 606, in report bot_token = TELEGRAM_BOT_TOKEN NameError: name 'TELEGRAM_BOT_TOKEN' is not defined

Buy & Sell price recording for main net

Further check this out:
-When making a buy, the price is returned from Binance(?)
-That price is written to coins_bought.json
-Price written to logfile is price retrieved earlier by convert_volume()

-Check which price is used for further calculations
-Ensure one price is used

Selling Coin and Leaving Some Behind

The Bot sells coins and leave some behind. For example the Bot will buy 16 beta at 1.24946 per coin plus fee of 0.016 at a total cost of 19.99136 and during selling the bot will only sell 15 beta instead of 16. What happens is that 1 beta is left behind. It happens for all coins. Why cant the Bot sell all the coins it buys.

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.