Skip to content

Commit

Permalink
Merge pull request #12 from rhettre/feature/get-strategy-values
Browse files Browse the repository at this point in the history
Update test_alphasquared.py
  • Loading branch information
rhettre authored Sep 8, 2024
2 parents 607903e + 55025c6 commit bd9eed6
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions tests/test_alphasquared.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,38 @@ def test_get_current_risk(self):
self.assertEqual(risk, 42.5)

def test_get_strategy_value_for_risk(self):
self.api.get_strategy_values = Mock(return_value={
"buy_values": {"risk_50": "100", "risk_60": "120"},
"sell_values": {"risk_50": "90", "risk_60": "80"}
})

# Test buy scenario
action, value = self.api.get_strategy_value_for_risk("Test Strategy", 55)
self.assertEqual(action, "buy")
self.assertEqual(value, 100.0)

# Test sell scenario
action, value = self.api.get_strategy_value_for_risk("Test Strategy", 65)
self.assertEqual(action, "sell")
self.assertEqual(value, 80.0)

# Test equal values scenario (should default to buy)
self.api.get_strategy_values = Mock(return_value={
"buy_values": {"risk_50": "100"},
"sell_values": {"risk_50": "90"}
"sell_values": {"risk_50": "100"}
})
action, value = self.api.get_strategy_value_for_risk("Test Strategy", 50)
self.assertEqual(action, "buy")
self.assertEqual(value, 100.0)

# Test no values scenario
self.api.get_strategy_values = Mock(return_value={
"buy_values": {},
"sell_values": {}
})
buy_value = self.api.get_strategy_value_for_risk("Test Strategy", 50, "buy")
sell_value = self.api.get_strategy_value_for_risk("Test Strategy", 50, "sell")
self.assertEqual(buy_value, 100.0)
self.assertEqual(sell_value, 90.0)
action, value = self.api.get_strategy_value_for_risk("Test Strategy", 50)
self.assertEqual(action, "buy")
self.assertEqual(value, 0.0)

if __name__ == '__main__':
unittest.main()

0 comments on commit bd9eed6

Please sign in to comment.