Skip to content

Commit

Permalink
- changes to modifying all take profit children
Browse files Browse the repository at this point in the history
  • Loading branch information
woody committed Nov 23, 2023
1 parent aee21c9 commit a2882bd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rithmic/interfaces/order/order_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,12 +760,26 @@ def submit_amend_bracket_order_all_take_profit_orders(self, order_id: str, limit
:return: None
"""
parent_order = self.status_manager._get_order_by_order_id(order_id)
current_take_profit = parent_order.take_profit_limit_price
assert isinstance(parent_order, BracketOrder)
next_modified_count = parent_order.all_take_profit_modified_count + 1
modify_map = dict()
for take_profit_order in parent_order.take_profit_orders:
modify_map[take_profit_order.order_id] = take_profit_order.modify_count + 1
asyncio.run_coroutine_threadsafe(
self._send_limit_order_amendment(
take_profit_order.basket_id, take_profit_order.security_code, take_profit_order.exchange_code,
take_profit_order.quantity, limit_price
),
loop=self.loop,
)
complete = False
while not complete:
if all([tp.modify_count == modify_map[tp.order_id] for tp in parent_order.take_profit_orders]):
complete = True
parent_order.all_take_profit_modified_count = next_modified_count
parent_order.all_take_profit_modified = True
parent_order.update_take_profit_limit_price(limit_price)
parent_order.all_take_profit_modified_history[next_modified_count] = dict(
modified_at=get_utc_now(), new_take_profit=limit_price, old_take_profit=current_take_profit
)

0 comments on commit a2882bd

Please sign in to comment.