Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Moneybox76 opened this issue Jan 20, 2023 · 4 comments

Comments

@Moneybox76
Copy link

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
Copy link
Owner

whittlem commented Feb 5, 2023

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

@mamylius
Copy link

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:
- ./BNB/binance.key:/app/binance.key
- ./BNB/config.json:/app/config.json
- ./BNB/pycryptobot.log:/app/pycryptobot.log
- ./BNB/graphs:/app/graphs
- ./BNB/csv:/app/csv
environment:
- PYTHONUNBUFFERED=1
image: pycryptobot/pycryptobot:latest
deploy:
restart_policy:
condition: on-failure
restart: always
tty: true

@NLegal
Copy link

NLegal commented Apr 1, 2023

Traceback (most recent call last):
File "/pycryptobot/controllers/PyCryptoBot.py", line 1558, in run
self.s.run()
File "/opt/homebrew/Cellar/[email protected]/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
Copy link
Owner

whittlem commented Jun 11, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants