Fix open trades checks

This commit is contained in:
2023-02-17 22:23:12 +00:00
parent d262f208b5
commit 3e35214e82
5 changed files with 33 additions and 13 deletions

View File

@@ -393,8 +393,23 @@ class ActiveManagementTestCase(StrategyMixin, SymbolPriceMock, TestCase):
self.trades[10:], # Only close newer trades
)
def test_max_open_trades_per_symbol_violated(self):
pass
@patch("core.trading.active_management.ActiveManagement.handle_violation")
def test_max_open_trades_per_symbol_violated(self, handle_violation):
for x in range(2):
self.add_trade(
str(x),
"EUR_USD",
"long",
f"2023-02-13T12:39:1{x}.302917985Z",
)
self.ams.run_checks()
self.check_violation(
"max_open_trades_per_symbol",
handle_violation.call_args_list,
"close",
self.trades[2:], # Only close newer trades
)
def test_max_loss_violated(self):
pass

View File

@@ -2,6 +2,8 @@ from django.test import TestCase
from core.exchanges import convert
from core.models import RiskModel, User
import core.trading.market # to avoid messy circular import
from core.trading import risk