Skip to content

Commit

Permalink
Merge pull request #10 from midassystems/fix_margin_call
Browse files Browse the repository at this point in the history
Margin call update maintenance margin v. net liquidation.
  • Loading branch information
anthonyb8 authored Feb 12, 2025
2 parents ae4c5ee + f75b732 commit 9bfa77d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion midastrader/structs/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def check_margin_call(self) -> bool:
Returns:
bool: True if a margin call is triggered, False otherwise.
"""
return self.full_available_funds < self.full_maint_margin_req
return self.net_liquidation < self.full_maint_margin_req

def to_dict(self, prefix: str = "") -> dict:
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/execution/dummy/test_dummy_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def test_mark_to_market(self):

def test_check_margin_call(self):
# Margin Call
self.broker.account.full_available_funds = 100
self.broker.account.net_liquidation = 100
self.broker.account.full_maint_margin_req = 2000

# Test
Expand All @@ -382,7 +382,7 @@ def test_check_margin_call(self):

def test_check_margin_call_no_call(self):
# No Margin Call
self.broker.account.full_available_funds = 2000
self.broker.account.net_liquidation = 2000
self.broker.account.full_maint_margin_req = 200

# Test
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/structs/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_equity_value(self):
self.assertEqual(equity_value, expected)

def test_check_margin_call_true(self):
self.account_obj.full_available_funds = 0
self.account_obj.net_liquidation = 0

# Test
result = self.account_obj.check_margin_call()
Expand Down

0 comments on commit 9bfa77d

Please sign in to comment.