asavinov / intelligent-trading-bot

Intelligent Trading Bot: Automatically generating signals and trading based on machine learning and feature engineering
https://t.me/intelligent_trading_signals
MIT License
1.05k stars 224 forks source link

Problems trade status sync. 'NoneType' object has no attribute 'get' #47

Open posido opened 5 months ago

posido commented 5 months ago

Hi,

I am running: python -m service.server -c configs/config.jsonc

I get the error message shown in the screenshot.

image

asavinov commented 5 months ago

Hi, it seems to be a problem with trader. It is not tested in latest versions and might be removed in future. Do you have more output like log or stacktrace?

posido commented 5 months ago

Unfortunately, not. It seems to happen in Server.py:

image

Here you see the output "Balance: = 0.002...." misses the left side.

print(f"Balance: {App.config['base_asset']} = {str(App.base_quantity)}") print(f"Balance: {App.config['quote_asset']} = {str(App.quote_quantity)}")

base_asset and quote_asset is not set in App.py. might that be the reason?

base_asset": "", # BTC ETH quote_asset": "",

I did not set it as the readme says it is already configured for Bitcoin.

asavinov commented 5 months ago

If I use the sample config 'config-sample-v0.7.dev.jsonc' then I do not have any errors. This exception seems to be raised from 'trader.py' if I turn on the trade function by adding "actions": ["trade"] in the config. So if you want to run it without trade (and without this exceptions) then turn off trade mode by removing "trade" from "actions". It will not try to access your account where seem to be a problem.

posido commented 5 months ago

Yes, without trade it works. But of course at the end I want to try to trade with it.

asavinov commented 5 months ago

Could you check what is in your collector.log file. There should be an exception message like this one:

2024-06-08 18:05:49,982 DEBUG https://api.binance.com:443 "GET /api/v3/openOrders?symbol=BTCUSDT&timestamp=1717862749666&signature=xyz HTTP/1.1" 401 70
2024-06-08 18:06:35,664 ERROR Binance exception in 'get_open_orders' APIError(code=-2015): Invalid API-key, IP, or permissions for action.
posido commented 5 months ago

Right, didn't see that log before:

2024-06-08 18:16:01,347 INFO ===> Start trade task. Timestamp 1717870561347. Interval [1717870560000,1717870620000]. 2024-06-08 18:16:01,348 ERROR Wrong status value None. 2024-06-08 18:16:01,348 ERROR Task exception was never retrieved future: <Task finished name='Task-348' coro=<main_trader_task() done, defined at /home/posido/intelligent-trading-bot/service/trader.py:31> exception=AttributeError("'NoneType' object has no attribute 'get'")> Traceback (most recent call last): File "/home/posido/intelligent-trading-bot/service/trader.py", line 100, in main_trader_task signal_side = signal.get("side") ^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'get' 2024-06-08 18:17:01,007 INFO ===> Start collector task. Timestamp 1717870621007. Interval [1717870620000,1717870680000]. 2024-06-08 18:17:01,269 DEBUG https://api.binance.com:443 "GET /api/v3/klines?endTime=1717870621007&interval=1m&limit=4&symbol=BTCUSDT HTTP/1.1" 200 229 2024-06-08 18:17:01,271 DEBUG Stored klines. Total 2880 in db. Last kline end: 1717870620000. Current time: 1717870621270 2024-06-08 18:17:01,272 INFO <=== End collector task. 2024-06-08 18:17:01,272 INFO Analyze BTCUSDT. Last kline timestamp: 2024-06-08 18:16:00 2024-06-08 18:17:01,323 INFO Analyze finished. Close: 69,462 Signals: trade_score=-0.004, buy_signal_column=False, sell_signal_column=False 2024-06-08 18:17:01,346 INFO ===> Start trade task. Timestamp 1717870621346. Interval [1717870620000,1717870680000]. 2024-06-08 18:17:01,347 ERROR Wrong status value None. 2024-06-08 18:17:01,347 ERROR Task exception was never retrieved future: <Task finished name='Task-351' coro=<main_trader_task() done, defined at /home/posido/intelligent-trading-bot/service/trader.py:31> exception=AttributeError("'NoneType' object has no attribute 'get'")> Traceback (most recent call last): File "/home/posido/intelligent-trading-bot/service/trader.py", line 100, in main_trader_task signal_side = signal.get("side")

posido commented 4 months ago

Do you have an update on that issue? Many thanks!

asavinov commented 4 months ago

I tried to fix problems in binance trader but I cannot finally test it because I do not have a (working) API key. So let me know if you get any problems. Now actions attribute is not needed. To turn on Binance trading you need to set trade_model.trader_binance as well as all parameters after it. The logic is in the trader_binance.py in case you want to improve something.

snisnik commented 1 month ago

I think i have a related issue, when i try to enable trading the notifications stop working on telegram and i get this on the collector: 2024-10-08 10:16:01,329 INFO <=== End collector task. 2024-10-08 10:16:01,347 INFO Analyze BTCUSDT. Last kline timestamp: 2024-10-08 13:15:00 2024-10-08 10:16:01,452 INFO Analyze finished. Close: 62,427 Signals: trade_score=-0.007, buy_signal_column=False, sell_signal_column=False 2024-10-08 10:16:01,470 INFO ===> Start trade task. Timestamp 1728393361469. Interval [1728393360000,1728393420000]. 2024-10-08 10:16:01,470 ERROR Wrong status value None. 2024-10-08 10:16:01,776 DEBUG https://api.binance.com:443 "GET /api/v3/account?timestamp=1728393361470&signature=274aa284b92d129cb056159080c0e1c2a250a89a993e58a41a5ad63b30c4f7bb HTTP/1.1" 200 2903 2024-10-08 10:16:01,779 INFO <=== End trade task.

Also in the terminal i'm getting this msg Problems trade status sync. can't multiply sequence by non-int of type 'decimal.Decimal'

any ideas on how to fix this? thanks

PCC2901 commented 2 weeks ago

to fix your trouble check this click maybe this will solve your problem.