Skip to content

Commit

Permalink
simplify drift_client get perp/spot position
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Nov 28, 2023
1 parent 9badb23 commit 2f67405
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/driftpy/drift_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1214,29 +1214,14 @@ def get_spot_position(
market_index: int,
sub_account_id: int = 0,
) -> Optional[SpotPosition]:
user = self.get_user_account(sub_account_id)

for position in user.spot_positions:
if (
position.market_index == market_index
and not is_spot_position_available(position)
):
return position

return None
return self.get_user(sub_account_id).get_spot_position(market_index)

def get_perp_position(
self,
market_index: int,
sub_account_id: int = 0,
) -> Optional[PerpPosition]:
user = self.get_user(sub_account_id).get_user_account()

for position in user.perp_positions:
if position.market_index == market_index and not is_available(position):
return position

return None
return self.get_user(sub_account_id).get_perp_position(market_index)

async def liquidate_spot(
self,
Expand Down

0 comments on commit 2f67405

Please sign in to comment.