diff --git a/core/tests/trading/test_assetfilter.py b/core/tests/trading/test_assetfilter.py index 5664589..9953cd9 100644 --- a/core/tests/trading/test_assetfilter.py +++ b/core/tests/trading/test_assetfilter.py @@ -1,7 +1,8 @@ from django.test import TestCase -from core.trading.assetfilter import get_allowed from core.models import AssetGroup, User +from core.trading.assetfilter import get_allowed + class AssetfilterTestCase(TestCase): def setUp(self): @@ -15,7 +16,6 @@ class AssetfilterTestCase(TestCase): description="Test group", ) - def test_get_allowed(self): """ Test that the asset filter works. @@ -25,4 +25,4 @@ class AssetfilterTestCase(TestCase): self.assertFalse(get_allowed(self.group, "EUR_GBP", "sell")) # Default true - self.assertTrue(get_allowed(self.group, "nonexistent", "sell")) \ No newline at end of file + self.assertTrue(get_allowed(self.group, "nonexistent", "sell")) diff --git a/core/trading/market.py b/core/trading/market.py index 345f623..e39d7f7 100644 --- a/core/trading/market.py +++ b/core/trading/market.py @@ -328,12 +328,18 @@ def execute_strategy(callback, strategy, func): # Callback now verified # Check against the asset groups - if func == "entry": - if strategy.assetgroup is not None: - allowed = assetfilter.get_allowed(strategy, symbol, direction) - if not allowed: - log.debug(f"Asset trading not allowed for {strategy}: {symbol}") - return + if func == "entry" and strategy.assetgroup is not None: + allowed = assetfilter.get_allowed(strategy, symbol, direction) + if not allowed: + log.debug( + f"Denied trading {symbol} due to asset filter {strategy.assetgroup}" + ) + sendmsg( + user, + f"Denied trading {symbol} due to asset filter {strategy.assetgroup}", + title="Asset filter denied", + ) + return if func == "exit": check_exit = crossfilter(account, symbol, direction, func)