Skip to content

Commit

Permalink
Raise exception if client order id not found (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Ignatev authored Sep 19, 2022
1 parent 282e946 commit ea97791
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion flash_gate/gate/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,14 @@ async def create_order(self, param: dict, event_id: str):
self.transmitter.offer(log_event, Destination.LOGS)

async def cancel_order(self, param: dict):
client_order_id = param["client_order_id"]
order_id = self.order_id_by_client_order_id.get(param["client_order_id"])
symbol = param["symbol"]

try:
if order_id is None:
raise ValueError(f"order_id not found for {client_order_id}")

exchange = await self.get_exchange()
await exchange.cancel_order({"id": order_id, "symbol": symbol})
self.canceled_orders[order_id] = True
Expand Down Expand Up @@ -259,9 +263,13 @@ async def cancel_order(self, param: dict):

async def get_order(self, param: dict):
try:
order_id = self.order_id_by_client_order_id.get(param["client_order_id"])
client_order_id = param["client_order_id"]
order_id = self.order_id_by_client_order_id.get(client_order_id)
symbol = param["symbol"]

if order_id is None:
raise ValueError(f"order_id not found for {client_order_id}")

exchange = await self.get_exchange()
order = await exchange.fetch_order({"id": order_id, "symbol": symbol})

Expand Down

0 comments on commit ea97791

Please sign in to comment.