Skip to content

Commit

Permalink
a bit more safety on IB exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Jan 25, 2021
1 parent 5988aa9 commit bb789ea
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions aat/exchange/public/ib/ib.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,33 @@ async def tick(self) -> AsyncGenerator[Any, Event]: # type: ignore[override]
"Inactive",
):
# ignore
if order.id in self._order_received_map:
# cannot place order, return false
self._order_received_res[order.id] = False
self._order_received_map[order.id].set()
await asyncio.sleep(0)

if order.id in self._order_cancelled_map:
# cannot cancel order, return false
self._order_cancelled_res[order.id] = False
self._order_cancelled_map[order.id].set()
await asyncio.sleep(0)

continue

elif status in ("Submitted",):
self._order_received_res[order.id] = True
self._order_received_map[order.id].set()
await asyncio.sleep(0)
if order.id in self._order_received_map:
# order submitted, return true
self._order_received_res[order.id] = True
self._order_received_map[order.id].set()
await asyncio.sleep(0)

elif status in ("Cancelled",):
self._order_cancelled_res[order.id] = True
self._order_cancelled_map[order.id].set()
await asyncio.sleep(0)
if order.id in self._order_cancelled_map:
# order cancelled, return true
self._order_cancelled_res[order.id] = True
self._order_cancelled_map[order.id].set()
await asyncio.sleep(0)

elif status in ("Filled",):
# this is the filled from orderStatus, but we
Expand Down

0 comments on commit bb789ea

Please sign in to comment.