-
Notifications
You must be signed in to change notification settings - Fork 416
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
error on minute mark unsupported operand type(s) for -: 'NoneType' and 'float' #417
Comments
upon investigation, it is because I manually placed a market order for this pair, and when passivbot is staring up, it calls the update_open_order function which retrieves the open order, it shows the following: open_orders are: [{'order_id': '721c3dd7-3088-42c5-a110-523435343', 'custom_id': None, 'symbol': 'ADA/USDT:USDT', 'price': None, 'qty': 3561.0, 'type': 'market', 'side': 'sell', 'position_side': 'long', 'timestamp': 1698470303860}] The price is None in this case. this order is an open position that is already filled, shouldn't it have a price when filled? is it normal to have the price as none for all market orders? I did manually place orders sometimes, but this error never happened before. |
upon further investigation, the actual data returned from the exchange is
this is weird that this order is a FILLED market order, as it show up in the exchange interface as an Open Position, it should have a price or avgPrice based on my understanding. |
It happens when there are special orders, like TP or SL, in which price returned is None. Verified it by making such orders manually, and saw the same error as you did. Fixed now in latest master by catching price=None when fetching open orders, setting price to current market price, triggering the order's cancellation. |
Great, thanks. |
I have run this bot for a couple of weeks, it run quite smoothly without errors, and the bot was run on a couple of trading pairs on Bybit for live trading as well as on OKX for demo trading.
One day all of a sudden it shows the following error on ADAUSDT pair on Bybit.
2023-10-28T15:43:34 INFO starting bot...
2023-10-28T15:44:20 INFO heartbeat ADA/USDT:USDT
2023-10-28T15:44:20 INFO long: 3561.0 @ 0.2971 lWE: 0.8969 pprc diff 0.002 EMAs: [0.29597, 0.29586, 0.29565] e 0.0 @ 0.0 | c 3561.0 @ None
2023-10-28T15:44:20 INFO short: -4000.0 @ 0.2824 sWE: 0.9577 pprc diff 0.050 EMAs: [0.29256, 0.29123, 0.28994] e 0.0 @ 0.0 | c 0.0 @ 0.0
2023-10-28T15:44:20 INFO balance: 1179.49 equity: 1121.11 last price: 0.2964 liq: 0.0
2023-10-28T15:44:24 ERROR error on minute mark unsupported operand type(s) for -: 'NoneType' and 'float'
Traceback (most recent call last):
File "D:\My Project\passivbot\passivbot.py", line 1541, in on_minute_mark
await self.cancel_and_create()
File "D:\My Project\passivbot\passivbot.py", line 1059, in cancel_and_create
to_cancel = sorted(to_cancel, key=lambda x: calc_diff(x["price"], self.price))
File "D:\My Project\passivbot\passivbot.py", line 1059, in
to_cancel = sorted(to_cancel, key=lambda x: calc_diff(x["price"], self.price))
File "D:\My Project\passivbot\njit_funcs.py", line 48, in calc_diff
return abs(x - y) / abs(y)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'
The error seems to be only on ADAUSDT, all other pairs are running fine. Restarting the bot doesn't help either, I was suspecting some data corruption on the cached exchange data, but after cleaning all cached data, the error still showed on restarting the bot. Any pointer to get this fixed would be good.
The text was updated successfully, but these errors were encountered: