Skip to content

Commit

Permalink
Reject long term market orders for dYdX
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsblom committed Nov 16, 2024
1 parent cf25e5c commit 9e6afac
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nautilus_trader/adapters/dydx/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,13 +1016,22 @@ async def _submit_order_single(self, order) -> None:
good_til_date_secs: int | None = None
good_til_block: int | None = None

if dydx_order_tags.is_short_term_order is False and order.order_type == OrderType.MARKET:
rejection_reason = "Cannot submit order: long term market order not supported by dYdX."
self.generate_order_rejected(
strategy_id=order.strategy_id,
instrument_id=order.instrument_id,
client_order_id=order.client_order_id,
reason=rejection_reason,
ts_event=self._clock.timestamp_ns(),
)
return

if dydx_order_tags.is_short_term_order:
try:
latest_block = await self._grpc_account.latest_block_height()
except AioRpcError as e:
rejection_reason = f"Failed to submit the order while retrieve the latest block height: code {e.code} {e.details}"
self._log.error(rejection_reason)

self.generate_order_rejected(
strategy_id=order.strategy_id,
instrument_id=order.instrument_id,
Expand Down Expand Up @@ -1071,8 +1080,6 @@ async def _submit_order_single(self, order) -> None:
rejection_reason = (
f"Cannot submit order: order type `{order.order_type}` not (yet) supported."
)
self._log.error(rejection_reason)

self.generate_order_rejected(
strategy_id=order.strategy_id,
instrument_id=order.instrument_id,
Expand Down

0 comments on commit 9e6afac

Please sign in to comment.