Skip to content

Commit

Permalink
Merge pull request hummingbot#180 from CoinAlpha/fix/gateway-v2-missi…
Browse files Browse the repository at this point in the history
…ng-cex-completion

fix / gateway v2 missing cex completion
  • Loading branch information
Martin Kou authored Mar 31, 2022
2 parents 862f7c8 + f16b3be commit d1dedad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 0 additions & 3 deletions hummingbot/connector/gateway_EVM_AMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,6 @@ async def update_order_status(self, tracked_orders: List[GatewayInFlightOrder]):
)
)
tracked_order.last_state = "FILLED"
self.logger().info(f"The {tracked_order.trade_type.name} order "
f"{tracked_order.client_order_id} has completed "
f"according to order status API.")
event_tag: MarketEvent = (
MarketEvent.BuyOrderCompleted if tracked_order.trade_type is TradeType.BUY
else MarketEvent.SellOrderCompleted
Expand Down
22 changes: 22 additions & 0 deletions hummingbot/strategy/amm_arb/amm_arb.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,31 @@ def set_order_completed(self, order_id: str):
def did_complete_buy_order(self, order_completed_event: BuyOrderCompletedEvent):
self.set_order_completed(order_id=order_completed_event.order_id)

market_info: MarketTradingPairTuple = self.order_tracker.get_market_pair_from_order_id(
order_completed_event.order_id
)
log_msg: str = f"Buy order completed on {market_info.market.name}: {order_completed_event.order_id}."
if self.is_gateway_market(market_info):
log_msg += f" txHash: {order_completed_event.exchange_order_id}"
self.log_with_clock(logging.INFO, log_msg)
self.notify_hb_app_with_timestamp(f"Bought {order_completed_event.base_asset_amount:.8f} "
f"{order_completed_event.base_asset}-{order_completed_event.quote_asset} "
f"on {market_info.market.name}.")

def did_complete_sell_order(self, order_completed_event: SellOrderCompletedEvent):
self.set_order_completed(order_id=order_completed_event.order_id)

market_info: MarketTradingPairTuple = self.order_tracker.get_market_pair_from_order_id(
order_completed_event.order_id
)
log_msg: str = f"Sell order completed on {market_info.market.name}: {order_completed_event.order_id}."
if self.is_gateway_market(market_info):
log_msg += f" txHash: {order_completed_event.exchange_order_id}"
self.log_with_clock(logging.INFO, log_msg)
self.notify_hb_app_with_timestamp(f"Sold {order_completed_event.base_asset_amount:.8f} "
f"{order_completed_event.base_asset}-{order_completed_event.quote_asset} "
f"on {market_info.market.name}.")

def did_fail_order(self, order_failed_event: MarketOrderFailureEvent):
self.set_order_completed(order_id=order_failed_event.order_id)

Expand Down

0 comments on commit d1dedad

Please sign in to comment.