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

Stack handler error #1474

Open
oldlore opened this issue Dec 27, 2024 · 0 comments
Open

Stack handler error #1474

oldlore opened this issue Dec 27, 2024 · 0 comments

Comments

@oldlore
Copy link

oldlore commented Dec 27, 2024

I had a -1 position in HANGENT_mini that was about to expire, so I put a close order in using interactive_order_stack. At the same time, the dynamic system decided to close the position so I ended up with this in interactive_order_stack (this was run after the crash)

(Order ID:746) Type best for dynamic_system HANGENT_mini, qty [1], fill [0]@ price, None Parent:no parent Children:no_children
(Order ID:747) Type best for dynamic_system CRUDE_W_micro, qty [1], fill [0]@ price, None Parent:no parent Children:[739]
(Order ID:748) Type best for dynamic_system GOLD_micro, qty [-1], fill [0]@ price, None Parent:no parent Children:[740]
(Order ID:749) Type best for dynamic_system CAD, qty [-1], fill [0]@ price, None Parent:no parent Children:[741]
(Order ID:750) Type best for dynamic_system HANGENT_mini, qty [0], fill [0]@ price, None Parent:no parent Children:[742]

What actually happened was the system placed an order for 1 to close the position then crashed as below.

Traceback (most recent call last):
  File "/home/lore/pysystemtrade/sysproduction/linux/scripts/run.py", line 67, in <module>
    func(*args, **kwargs)
  File "/home/lore/pysystemtrade/sysproduction/run_stack_handler.py", line 11, in run_stack_handler
    price_process.run_process()
  File "/home/lore/pysystemtrade/syscontrol/run_process.py", line 106, in run_process
    self._main_loop_over_methods()
  File "/home/lore/pysystemtrade/syscontrol/run_process.py", line 132, in _main_loop_over_methods
    timer_class.check_and_run(**kwargs)
  File "/home/lore/pysystemtrade/syscontrol/timer_functions.py", line 124, in check_and_run
    self.run_function(**kwargs)
  File "/home/lore/pysystemtrade/syscontrol/timer_functions.py", line 299, in run_function
    self._function(**kwargs)
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py", line 43, in create_broker_orders_from_contract_orders
    self.create_broker_order_for_contract_order(contract_order_id)
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py", line 82, in create_broker_order_for_contract_order
    self.post_trade_processing(completed_broker_order_with_controls)
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/create_broker_orders_from_contract_orders.py", line 338, in post_trade_processing
    self.apply_broker_order_fills_to_database(
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/fills.py", line 97, in apply_broker_order_fills_to_database
    self.apply_broker_fills_to_contract_order(contract_order_id)
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/fills.py", line 129, in apply_broker_fills_to_contract_order
    self.apply_fills_to_contract_order(
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/fills.py", line 178, in apply_fills_to_contract_order
    self.apply_contract_fill_to_instrument_order(contract_order_id)
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/fills.py", line 224, in apply_contract_fill_to_instrument_order
    self.apply_contract_fills_for_instrument_order(
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/fills.py", line 240, in apply_contract_fills_for_instrument_order
    self.apply_contract_fill_to_parent_order_single_child(
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/fills.py", line 264, in apply_contract_fill_to_parent_order_single_child
    self.fill_for_instrument_in_database(
  File "/home/lore/pysystemtrade/sysexecution/stack_handler/fills.py", line 371, in fill_for_instrument_in_database
    self.instrument_stack.change_fill_quantity_for_order(
  File "/home/lore/pysystemtrade/sysexecution/order_stacks/order_stack.py", line 331, in change_fill_quantity_for_order
    raise overFilledOrder(e)
sysexecution.orders.base_orders.overFilledOrder: Can't fill order with fill [1] more than trade quantity [0] 

Since the stack handler crashed the other orders did not take place. Trying to run the end of day stack deletion failed with the same error. I also ended up with a strategy position in HANGENT_mini of +1, which had to be fixed to correct the positions "break". It would be ideal if the stack handler could handle the niche scenario where a position is closed (or rolled?) the same time as the system decides to change position. I usually wait until after the strategy order generator runs before closing positions to avoid this sort of situation.

Thanks!

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

1 participant