Add signals trading enabled
This commit is contained in:
parent
5c090433a3
commit
3854bdcc7d
|
@ -130,6 +130,8 @@ class StrategyForm(RestrictedFormMixin, ModelForm):
|
||||||
"entry_signals",
|
"entry_signals",
|
||||||
"exit_signals",
|
"exit_signals",
|
||||||
"trend_signals",
|
"trend_signals",
|
||||||
|
"signal_trading_enabled",
|
||||||
|
"active_management_enabled",
|
||||||
"enabled",
|
"enabled",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -144,6 +146,8 @@ class StrategyForm(RestrictedFormMixin, ModelForm):
|
||||||
"entry_signals": "Callbacks received to these signals will trigger a trade.",
|
"entry_signals": "Callbacks received to these signals will trigger a trade.",
|
||||||
"exit_signals": "Callbacks received to these signals will close all trades for the symbol on the account.",
|
"exit_signals": "Callbacks received to these signals will close all trades for the symbol on the account.",
|
||||||
"trend_signals": "Callbacks received to these signals will limit the trading direction of the given symbol to the callback direction until further notice.",
|
"trend_signals": "Callbacks received to these signals will limit the trading direction of the given symbol to the callback direction until further notice.",
|
||||||
|
"signal_trading_enabled": "Whether the strategy will place trades based on signals.",
|
||||||
|
"active_management_enabled": "Whether the strategy will amend/remove trades on the account that violate the rules.",
|
||||||
"enabled": "Whether the strategy is enabled.",
|
"enabled": "Whether the strategy is enabled.",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 4.1.6 on 2023-02-15 19:14
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0069_remove_strategy_order_type_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='strategy',
|
||||||
|
name='active_management_enabled',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='strategy',
|
||||||
|
name='signal_trading_enabled',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
|
@ -379,6 +379,8 @@ class Strategy(models.Model):
|
||||||
Signal, related_name="trend_strategies", blank=True
|
Signal, related_name="trend_strategies", blank=True
|
||||||
)
|
)
|
||||||
enabled = models.BooleanField(default=False)
|
enabled = models.BooleanField(default=False)
|
||||||
|
signal_trading_enabled = models.BooleanField(default=False)
|
||||||
|
active_management_enabled = models.BooleanField(default=False)
|
||||||
trends = models.JSONField(null=True, blank=True)
|
trends = models.JSONField(null=True, blank=True)
|
||||||
|
|
||||||
asset_group = models.ForeignKey(
|
asset_group = models.ForeignKey(
|
||||||
|
|
|
@ -517,7 +517,9 @@ def process_callback(callback):
|
||||||
|
|
||||||
# Scan for trend
|
# Scan for trend
|
||||||
log.debug("Scanning for trend strategies...")
|
log.debug("Scanning for trend strategies...")
|
||||||
strategies = Strategy.objects.filter(trend_signals=callback.signal, enabled=True)
|
strategies = Strategy.objects.filter(
|
||||||
|
trend_signals=callback.signal, signal_trading_enabled=True, enabled=True
|
||||||
|
)
|
||||||
log.debug(f"Matched strategies: {strategies}")
|
log.debug(f"Matched strategies: {strategies}")
|
||||||
for strategy in strategies:
|
for strategy in strategies:
|
||||||
log.debug(f"Executing strategy {strategy}")
|
log.debug(f"Executing strategy {strategy}")
|
||||||
|
@ -528,7 +530,9 @@ def process_callback(callback):
|
||||||
|
|
||||||
# Scan for entry
|
# Scan for entry
|
||||||
log.debug("Scanning for entry strategies...")
|
log.debug("Scanning for entry strategies...")
|
||||||
strategies = Strategy.objects.filter(entry_signals=callback.signal, enabled=True)
|
strategies = Strategy.objects.filter(
|
||||||
|
entry_signals=callback.signal, signal_trading_enabled=True, enabled=True
|
||||||
|
)
|
||||||
log.debug(f"Matched strategies: {strategies}")
|
log.debug(f"Matched strategies: {strategies}")
|
||||||
for strategy in strategies:
|
for strategy in strategies:
|
||||||
log.debug(f"Executing strategy {strategy}")
|
log.debug(f"Executing strategy {strategy}")
|
||||||
|
@ -539,7 +543,9 @@ def process_callback(callback):
|
||||||
|
|
||||||
# Scan for exit
|
# Scan for exit
|
||||||
log.debug("Scanning for exit strategies...")
|
log.debug("Scanning for exit strategies...")
|
||||||
strategies = Strategy.objects.filter(exit_signals=callback.signal, enabled=True)
|
strategies = Strategy.objects.filter(
|
||||||
|
exit_signals=callback.signal, signal_trading_enabled=True, enabled=True
|
||||||
|
)
|
||||||
log.debug(f"Matched strategies: {strategies}")
|
log.debug(f"Matched strategies: {strategies}")
|
||||||
for strategy in strategies:
|
for strategy in strategies:
|
||||||
log.debug(f"Executing strategy {strategy}")
|
log.debug(f"Executing strategy {strategy}")
|
||||||
|
|
Loading…
Reference in New Issue