whittlem / pycryptobot

Python Crypto Bot (PyCryptoBot)
Apache License 2.0
1.98k stars 741 forks source link

UnboundLocalError("local variable 'trading_data' referenced before assignment") #757

Closed Moneybox76 closed 1 year ago

Moneybox76 commented 1 year ago

When selling via telegram bot error message appears in the logs. Selling of position is working.

Bot1 2023-01-20 07:57:29 ETHUSDT 15m Restarting application in 30 seconds after exception: UnboundLocalError("local variable 'trading_data' referenced before assignment")

whittlem commented 1 year ago

Can you please provide your config.json so I can re-create it? This is on Binance right?

mamylius commented 1 year ago

Hello, I do have the same error message.

{ "binance": { "api_url": "https://api.binance.com", "config": { "autorestart": 1, "base_currency": "BNB", "disablebuynearhigh": 1, "enableinsufficientfundslogging": 1, "enabletelegrambotcontrol": 1, "telegramerrormsgs": 1, "granularity": "15m", "live": 1, "nobuynearhighpcnt": 1, "nosellmaxpcnt": 3, "nosellminpcnt": -9, "quote_currency": "USDT", "sellatresistance": 1, "selllowerpcnt": -12, "telegram": 1, "trailingbuypcnt": 1, "trailingstoploss": -1, "trailingstoplosstrigger": 3, "verbose": 0, "websocket": 0, "graphs": 1, "tradetracker": 1, "predictions": 0, "buypercent": 80, "bullonly":1 }, "api_key_file": "binance.key" }, "telegram" : { "token" : "", "client_id" : "", "user_id": "" } }

I start it with docker compose:

bnbusdt: build: context: . container_name: BNBUSDT volumes:

NLegal commented 1 year ago

Traceback (most recent call last): File "/pycryptobot/controllers/PyCryptoBot.py", line 1558, in run self.s.run() File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/sched.py", line 151, in run action(*argument, **kwargs) File "/pycryptobot/controllers/PyCryptoBot.py", line 1153, in execute_job tradinggraphs.render_ema_and_macd(len(trading_data), "graphs/" + filename, True) UnboundLocalError: local variable 'trading_data' referenced before assignment Bot1 2023-04-01 12:21:33 BTC-USDT 1hour Restarting application in 30 seconds after exception: UnboundLocalError("local variable 'trading_data' referenced before assignment")

same for kucoin it is caused by "graphs": 1.

whittlem commented 1 year ago

I believe I've fixed it.

if self.is_sim: tradinggraphs.render_ema_and_macd(len(trading_dataCopy), "graphs/" + filename, True) else: tradinggraphs.render_ema_and_macd(len(self.trading_data), "graphs/" + filename, True)

It's in the "beta" branch now. Can you test it and let me know?