Begin work on increasing position size

This commit is contained in:
Mark Veidemanis 2023-02-28 07:20:12 +00:00
parent 5843000df6
commit b4424a7782
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
4 changed files with 33 additions and 0 deletions

View File

@ -80,6 +80,14 @@ ADJUST_CLOSE_NOTIFY_CHOICES = (
("adjust", "Adjust violating trades"),
)
ADJUST_WITH_DIRECTION_CHOICES = (
("none", "None"),
("close", "Close violating trades"),
("notify", "Notify only"),
("adjust", "Increase and reduce"),
("adjust_up", "Increase only"),
("adjust_down", "Reduce only"),
)
# class Plan(models.Model):
# name = models.CharField(max_length=255, unique=True)

View File

@ -283,6 +283,15 @@ class ActiveManagementTestCase(StrategyMixin, SymbolPriceMock, TestCase):
},
)
def test_position_size_violated_increase_only(self):
pass
def test_position_size_violated_decrease_only(self):
pass
def test_position_size_violated_increase_decrease(self):
pass
def test_protection_violated(self):
self.trades[0]["takeProfitOrder"] = {"price": "0.0001"}
self.trades[0]["stopLossOrder"] = {"price": "0.0001"}

View File

@ -203,6 +203,15 @@ class ActiveManagementLiveTestCase(ElasticMock, StrategyMixin, LiveBase, TestCas
trades = self.account.client.get_all_open_trades()
self.assertEqual(len(trades), 0)
def test_ams_position_size_violated_increase(self):
pass
def test_ams_position_size_violated_decrease(self):
pass
def test_ams_position_size_violated_increase_decrease(self):
pass
def test_ams_protection_violated(self):
self.active_management_policy.when_protection_violated = "close"
self.active_management_policy.save()

View File

@ -44,6 +44,13 @@ def check_max_risk(risk_model, account_balance_usd, account_trades):
return allowed
def check_max_trade_risk(risk_model, account_balance_usd, trade):
"""
Check that the trade is within the max trade risk percentage of the account size.
"""
pass
def check_max_open_trades(risk_model, account_trades):
"""
Check that the number of trades in the account is within the max open trades limit.