Skip to content

Commit

Permalink
add cancel and place orders to drift client
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Nov 27, 2023
1 parent 34300b6 commit 5008c89
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/driftpy/drift_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,40 @@ def get_cancel_orders_ix(
),
)

async def cancel_and_place_orders(
self,
cancel_params: (
Optional[MarketType],
Optional[int],
Optional[PositionDirection],
),
place_order_params: List[OrderParams],
sub_account_id: int = 0,
):
return await self.send_ixs(
self.get_cancel_and_place_orders_ix(
cancel_params, place_order_params, sub_account_id
),
)

def get_cancel_and_place_orders_ix(
self,
cancel_params: (
Optional[MarketType],
Optional[int],
Optional[PositionDirection],
),
place_order_params: List[OrderParams],
sub_account_id: int = 0,
):
market_type, market_index, direction = cancel_params

cancel_orders_ix = self.get_cancel_orders_ix(
market_type, market_index, direction, sub_account_id
)
place_orders_ix = self.get_place_orders_ix(place_order_params, sub_account_id)
return [cancel_orders_ix, place_orders_ix]

async def place_and_take_perp_order(
self,
order_params: OrderParams,
Expand Down

0 comments on commit 5008c89

Please sign in to comment.