Describe the bug
Currently in testing mode, so running XSP instead of SPX:
It is 8:53 PM UTC. The bot seems to have stopped on its own, and this has happened a few times. Bot does tend to reply to commands.
To Reproduce
Modify the SPX to XSP (this should have no impact).
Since the position is XSP, it put an order for 0.05 close after the position was opened. The buy to close log is attached. Once the 0.05 order was placed, I modified the order to 0.03.
Expected behavior
Bot to continue processing, as once the BUY_TO_CLOSE order is placed by the bot, it should not have any impact whether the user goes and manually modifies the order on TDA/TOS.
Log
autotrader.log is as follows (tail end of it).
2021-06-04 13:41:45,161 - tdaBroker.py - place_order() - INFO - Your order being placed is: OrderedDict([('orderStrategyType', 'SINGLE'), ('orderType', 'LIMIT'), ('session', 'NORMAL'), ('duration', 'GOOD_TILL_CANCEL'), ('price', '0.05'), ('orderLegCollection', [{'instruction': 'BUY_TO_CLOSE', 'quantity': 1.0, 'instrument': {'assetType': 'OPTION', 'symbol': 'XSP_060721P413'}}])])
2021-06-04 13:41:45,413 - tdaBroker.py - place_order() - INFO - Order 4485468214 Placed
2021-06-04 13:41:45,413 - botMediator.py - process_strategies() - INFO - Sleeping...
2021-06-04 13:42:12,453 - cspByDeltaStrategy.py - process_strategy() - DEBUG - processstrategy
2021-06-04 13:42:12,454 - cspByDeltaStrategy.py - get_market_session_loop() - DEBUG - get_market_session_loop
2021-06-04 13:42:12,715 - cspByDeltaStrategy.py - process_open_market() - DEBUG - Processing Open-Market
2021-06-04 13:42:12,715 - cspByDeltaStrategy.py - process_expiring_positions() - DEBUG - process_expiring_positions
2021-06-04 13:42:12,715 - cspByDeltaStrategy.py - build_new_order() - DEBUG - build_new_order
Bot was started as nohup python
nohup log as follows: two separate instances of bot crashing and not responding is below.
Grabbing new access token...
Grabbing new access token...
Grabbing new access token...
Traceback (most recent call last):
File "/home/azureuser/LoopTrader/looptrader/main.py", line 39, in
bot.process_strategies()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Mediator/botMediator.py", line 72, in process_strategies
strategy.process_strategy()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 102, in process_strategy
self.process_open_market(hours.end, now)
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 142, in process_open_market
self.place_new_orders_loop()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 430, in place_new_orders_loop
neworder = self.build_new_order()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 295, in build_new_order
int(position.symbol[-4:])
ValueError: invalid literal for int() with base 10: 'P410'
Traceback (most recent call last):
File "/home/azureuser/LoopTrader/looptrader/main.py", line 39, in
bot.process_strategies()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Mediator/botMediator.py", line 72, in process_strategies
strategy.process_strategy()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 102, in process_strategy
self.process_open_market(hours.end, now)
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 142, in process_open_market
self.place_new_orders_loop()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 430, in place_new_orders_loop
neworder = self.build_new_order()
File "/home/azureuser/LoopTrader/looptrader/basetypes/Strategy/cspByDeltaStrategy.py", line 295, in build_new_order
int(position.symbol[-4:])
ValueError: invalid literal for int() with base 10: 'P413'