From e652b08abf11404ff123a6c262d0d0fc2a63adc1 Mon Sep 17 00:00:00 2001 From: sina <20732540+SinaKhalili@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:05:48 -0700 Subject: [PATCH] Update perp position to return zero on nonexistent position --- src/driftpy/drift_user.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/driftpy/drift_user.py b/src/driftpy/drift_user.py index 59673da1..d23cc826 100644 --- a/src/driftpy/drift_user.py +++ b/src/driftpy/drift_user.py @@ -142,6 +142,9 @@ def get_perp_market_liability( signed: bool = False, ): perp_position = self.get_perp_position(market_index) + if perp_position is None: + return 0 + return self.calculate_weighted_perp_position_liability( perp_position, margin_category,