CyberPunkMetalHead / Binance-volatility-trading-bot

This is a fully functioning Binance trading bot that measures the volatility of every coin on Binance and places trades with the highest gaining coins If you like this project consider donating though the Brave browser to allow me to continuously improve the script.
MIT License
3.41k stars 777 forks source link

No buy, sell, check after error in <module>, buy, convert_volume #114

Closed zawhie closed 3 years ago

zawhie commented 3 years ago

After some time Binance Detect Moonings.py throws the following error:

External signal received on DGBUSDT, calculating volume in USDT
[2021-05-18 13:31:09] External signal received on ENJUSDT, calculating volume in USDT
Traceback (most recent call last):
  File "Binance Detect Moonings.py", line 497, in <module>
    orders, last_price, volume = buy()
  File "Binance Detect Moonings.py", line 239, in buy
    volume, last_price = convert_volume()
  File "Binance Detect Moonings.py", line 220, in convert_volume
    volume[coin] = float(QUANTITY / float(last_price[coin]['price']))
KeyError: 'DGBUSDT'
[2021-05-18 13:31:10] Signalsample: Signal detected on ETHUSDT

After this, there's no additional buy, sell or even check if the price has changed.

ShogunMan commented 3 years ago

DGBUSDT not in custom tickerlist?

zawhie commented 3 years ago

It happened on different coins, BALUSDT, ONEUSDT, CHRUSDT, but I'm not able to recreate it. Right now ONEUSDT got parsed without an error.

I'm not using a custom tickerlist.

Amraki commented 3 years ago

Same happened to me for 'DIAUSDT' with a fresh instance of code and my API key/secret. Error is the same output as above.

ShogunMan commented 3 years ago

Are you sure custom list are not set to true in your yml config?

Amraki commented 3 years ago

It appears the default config has CUSTOM_LIST set to True.

From the Discord discussions, it seems the issue is caused by the tickers.txt and signalsample.txt files not having the same coin symbols.

To my knowledge, there was no warning this would be a problem and is obviously confusing to anyone who runs the bot thinking the default config works for the majority of users.

The easiest solution would be to disable CUSTOM_LIST by default but preferably error handling will solve the cause of the issue.

zawhie commented 3 years ago

It also happens if tickers.txt and signalsample.txt are exactly the same. Same with and without a custom list..

popeye2019 commented 3 years ago

Same error yesterday i was not able to launch the bot. This error appear at each launch. Today the boat run from 13H00 to 17h47 without any problem then ....it appeared. It seem there is no value in float(last_price[coin]['price']). yesterday i've print value quantity it was ok but float(......) was empty.

Copy of terminal =>

[2021-05-19 17:47:01] not enough time has passed yet...Session profit:201.69% [2021-05-19 17:47:02] External signal received on DOGEUSDT, calculating volume in USDT Traceback (most recent call last): File "C:\Users\francis\Desktop\Binance Bot\Cinance\Binance Detect Moonings.py", line 501, in orders, last_price, volume = buy() File "C:\Users\francis\Desktop\Binance Bot\Cinance\Binance Detect Moonings.py", line 243, in buy volume, last_price = convert_volume() File "C:\Users\francis\Desktop\Binance Bot\Cinance\Binance Detect Moonings.py", line 224, in convert_volume volume[coin] = float(QUANTITY / float(last_price[coin]['price'])) KeyError: 'DOGEUSDT' [2021-05-19 17:48:35] Signalsample: Max signal by AVAXUSDT at 17 on shortest timeframe [2021-05-19 17:48:35] Signalsample: 1 coins above 16 treshold on both timeframes [2021-05-19 17:48:35] Signalsample: Waiting 4 minutes for next analysis [2021-05-19 17:52:35] Signalsample: Analyzing 90 coins [2021-05-19 17:54:13] Signalsample: Max signal by DIAUSDT at 17 on shortest timeframe [2021-05-19 17:54:13] Signalsample: No coins above 16 threshold on both timeframes [2021-05-19 17:54:13] Signalsample: Waiting 4 minutes for next analysis [2021-05-19 17:58:13] Signalsample: Analyzing 90 coins

popeye2019 commented 3 years ago

to easy reproduce error

in signalsamplemod.py

TA_BUY_THRESHOLD = 8 # How many of the 26 indicators to indicate a buy

flo-joe commented 3 years ago

I'm also getting this error. It seems the last_price dictionary is somehow not finding the entry for a coin. I added a line just to capture the entire value of the particular dictionary entry, so that I could print it out later:

coins_last_price = last_price[coin]

And got: KeyError: 'BNTUSD'

popeye2019 commented 3 years ago

Hello

Here a little soluce ?! I hope, I do not write mistake

modify in def wait_for_price(): '''calls the initial price and ensures the correct amount of time has passed before reading the current price again''' ... old code ... .... new code ......

# Disabled until fix
#print(f'Up: {coins_up} Down: {coins_down} Unchanged: {coins_unchanged}')

# Here goes new code for external signalling
externals = external_signals()
exnumber = 0
valid = False
for excoin in externals:
    valid = False
    for test in tickers:
        if test == excoin[:-4]:
            valid = True
    if not valid  : print(f'\033[91mnok : {excoin}')

for excoin in externals:
    valid=False
    for test in tickers:
        if test == excoin[:-4]:
            valid=True
            #print (f'Excoin: {excoin}')
    if valid and (excoin not in volatile_coins and excoin not in coins_bought and (len(coins_bought) + exnumber) < MAX_COINS):
        volatile_coins[excoin] = 1
        exnumber +=1
        print(f'External signal received on {excoin}, calculating volume in {PAIR_WITH}')

return volatile_coins, len(volatile_coins), historical_prices[hsp_head]
getsec commented 3 years ago

Stale...