Skip to content

Commit

Permalink
Fix order cancellation bug introduced by IB API change and fix order …
Browse files Browse the repository at this point in the history
…id deadlock (#98)

* Fixes #97

* Fix based on testing.

* Change order id strategy to increment to avoid deadlocks.
Fix #99
  • Loading branch information
chipkent authored Sep 28, 2022
1 parent b5c547f commit e01010c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/deephaven_ib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class IbSessionTws:
_tables_raw: Dict[str, Table]
_tables: Dict[str, Table]

def __init__(self, host: str = "", port: int = 7497, client_id: int = 0, download_short_rates: bool = True, order_id_strategy: OrderIdStrategy = OrderIdStrategy.RETRY, read_only: bool = True, is_fa: bool = False):
def __init__(self, host: str = "", port: int = 7497, client_id: int = 0, download_short_rates: bool = True, order_id_strategy: OrderIdStrategy = OrderIdStrategy.INCREMENT, read_only: bool = True, is_fa: bool = False):
self._host = host
self._port = port
self._client_id = client_id
Expand Down Expand Up @@ -1166,7 +1166,7 @@ def order_cancel(self, order_id: int) -> None:

self._assert_connected()
self._assert_read_write()
self._client.cancelOrder(orderId=order_id)
self._client.cancelOrder(orderId=order_id, manualCancelOrderTime="")

def order_cancel_all(self) -> None:
"""Cancel all open orders.
Expand Down
2 changes: 1 addition & 1 deletion src/deephaven_ib/_tws/order_id_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class OrderIdEventQueue:
_last_value: int
_request_thread: Thread

def __init__(self, client: 'IbTwsClient', strategy: OrderIdStrategy = OrderIdStrategy.RETRY):
def __init__(self, client: 'IbTwsClient', strategy: OrderIdStrategy):
self._events = []
self._values = []
self._lock = LoggingLock("OrderIdEventQueue")
Expand Down

0 comments on commit e01010c

Please sign in to comment.