Edit: Timezone discrepancy causing trading hour issues #1404
Replies: 3 comments 17 replies
-
Locking an order is a normal part of the order creation & execution process. They should not remain locked indefinitely, of course, but just seeing a log message stating that an order is locked is not indicative of any problem. So let's back up a little. What led you to investigate the logs regarding this order? Maybe you noticed that this order had not been executed when you expected it to have been? If so, I should point out that SOYMEAL, and other CME agricultural contracts have trading hours that are different from most other CME futures. When an order cannot be executed because of trading hours, there are no log messages telling you this, it just looks like stack_handler is ignoring the order. If this more or less describes what happened, then I would first check your trading hour configuration (interactive_diagnostics --> View instrument configuration --> View trading hours for all instruments). If that is not what happened, please provide more context. The other likely way I can see an order getting stuck in locked status is if there was a stack handler crash, in which case you should have a stack trace for that. |
Beta Was this translation helpful? Give feedback.
-
@tgibson11 Thanks again for your help. So I noticed that my CORN and SOYOIL trade is still not going through. Here is the output of trading hours:
Now I have dug in, and both the saved trading hours object and the trading hours pulled from IB have data, however it appears there is no intersection between the two hour sets. Here is an example:
IB trading hours are listed as 11:30 to 14:20 It looks like a conflict with the stored YAML. I wonder if running my server in EST and trying to use the gmt_offset is causing some issue somewhere in the chain. Might be easier to just reset server time to UTC? Or did you find you needed to manually edit the YAML? |
Beta Was this translation helpful? Give feedback.
-
US equity markets open at 9:30am EST, close at 4pm, so that is presumed to be the most liquid hours to trade. Rob doesn't want to trade right at the open or close (presumably due to volatility, and also maybe the risk of not getting filled at the close). So he's conservative with the hours he's willing to trade. Also, if you live in an area that doesn't have the same DST schedule as an exchange, using conservative hours makes it unnecessary to worry about that too. |
Beta Was this translation helpful? Give feedback.
-
I had a few live trades execute flawlessly last night and a position closed this AM.
However new orders are being reported as LOCKED
2024-09-11 13:01:14 DEBUG stack_handler {'type': 'run_stack_handler', 'strategy_name': 'dynamic_system', 'instrument_code': 'SOYMEAL', 'contract_order_id': '', 'instrument_order_id': 120} Put child order (Order ID:no order ID) Type best for dynamic_system/SOYMEAL/20250100, qty [-1], fill [0]@ price, None Parent:120 Children:no_children LOCKED on stack with ID 120 from parent order (Order ID:120) Type best for dynamic_system SOYMEAL, qty [-1], fill [0]@ price, None Parent:no parent Children:no_children
If I try to unlock under 32 or 33 (Lock/unlock order and instrument code) any change to lock status crashes
2024-09-11 13:28:56 DEBUG connectionIB {'type': 'Interactive-Order-Stack', 'broker': 'IB', 'clientid': 115} Terminating {'ipaddress': '127.0.0.1', 'port': 4001, 'client': 115}
2024-09-11 13:28:56 DEBUG Interactive-Order-Stack {'component': 'mongoIbBrokerClientIdData'} Released IB client ID 115
Traceback (most recent call last):
File "/home/trader/pysystemtrade/sysproduction/linux/scripts/run.py", line 66, in
func(*args, **kwargs)
File "/home/trader/pysystemtrade/sysproduction/interactive_order_stack.py", line 61, in interactive_order_stack
interactive_order_stack_with_ib_conn(ib_conn)
File "/home/trader/pysystemtrade/sysproduction/interactive_order_stack.py", line 70, in interactive_order_stack_with_ib_conn
menu.run_menu()
File "/home/trader/pysystemtrade/syscore/interactive/menus.py", line 64, in run_menu
method_chosen(*self._args, **self._kwargs)
File "/home/trader/pysystemtrade/sysproduction/interactive_order_stack.py", line 810, in order_locking
if order.is_order_locked():
AttributeError: 'named_object' object has no attribute 'is_order_locked'
I can also try to unlock under ALGO
(Order ID:120) Type best for dynamic_system/SOYMEAL/20250100, qty [-1], fill [0]@ price, None Parent:120 Children:no_children
It is reported as released
Order ID 120
Controlled by None; releasing now
Released
However I see no messages in the API or Client ID log regarding this order, and it immediately returns to LOCKED status.
There were no trade limits setup at this point. I tried using interactive_order_stack to manually place an order, but also not going through and no updates. I also restarted the system, ran shutdown processes, cleared the orders and regenerated.
Now I don't believe that's the root problem regardless, I am just not clear at what stage these locks are occurring and I don't see any logs related to the lock.
I verified that I am capable of manually placing the order in TWS though.
Any help on where to dig into this would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions