From 12c909d8a8498b687422d62a3544599c2bef7edb Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 12 Mar 2022 07:00:57 +0100 Subject: [PATCH] Add can_short to sample strategies --- freqtrade/strategy/interface.py | 1 + freqtrade/templates/base_strategy.py.j2 | 3 +++ freqtrade/templates/sample_short_strategy.py | 3 +++ freqtrade/templates/sample_strategy.py | 15 +++++++++------ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 09f611b1e..12ec06483 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -81,6 +81,7 @@ class IStrategy(ABC, HyperStrategyMixin): trailing_only_offset_is_reached = False use_custom_stoploss: bool = False + # Can this strategy go short? can_short: bool = False # associated timeframe diff --git a/freqtrade/templates/base_strategy.py.j2 b/freqtrade/templates/base_strategy.py.j2 index 701909bf6..0a20eaf2a 100644 --- a/freqtrade/templates/base_strategy.py.j2 +++ b/freqtrade/templates/base_strategy.py.j2 @@ -40,6 +40,9 @@ class {{ strategy }}(IStrategy): # Optimal timeframe for the strategy. timeframe = '5m' + # Can this strategy go short? + can_short: bool = False + # Minimal ROI designed for the strategy. # This attribute will be overridden if the config file contains "minimal_roi". minimal_roi = { diff --git a/freqtrade/templates/sample_short_strategy.py b/freqtrade/templates/sample_short_strategy.py index c33327715..535c2222d 100644 --- a/freqtrade/templates/sample_short_strategy.py +++ b/freqtrade/templates/sample_short_strategy.py @@ -38,6 +38,9 @@ class SampleShortStrategy(IStrategy): # Check the documentation or the Sample strategy to get the latest version. INTERFACE_VERSION = 2 + # Can this strategy go short? + can_short: bool = True + # Minimal ROI designed for the strategy. # This attribute will be overridden if the config file contains "minimal_roi". minimal_roi = { diff --git a/freqtrade/templates/sample_strategy.py b/freqtrade/templates/sample_strategy.py index b3f1ae1c8..3da92fa0b 100644 --- a/freqtrade/templates/sample_strategy.py +++ b/freqtrade/templates/sample_strategy.py @@ -37,6 +37,9 @@ class SampleStrategy(IStrategy): # Check the documentation or the Sample strategy to get the latest version. INTERFACE_VERSION = 2 + # Can this strategy go short? + can_short: bool = False + # Minimal ROI designed for the strategy. # This attribute will be overridden if the config file contains "minimal_roi". minimal_roi = { @@ -55,12 +58,6 @@ class SampleStrategy(IStrategy): # trailing_stop_positive = 0.01 # trailing_stop_positive_offset = 0.0 # Disabled / not configured - # Hyperoptable parameters - buy_rsi = IntParameter(low=1, high=50, default=30, space='buy', optimize=True, load=True) - sell_rsi = IntParameter(low=50, high=100, default=70, space='sell', optimize=True, load=True) - short_rsi = IntParameter(low=51, high=100, default=70, space='sell', optimize=True, load=True) - exit_short_rsi = IntParameter(low=1, high=50, default=30, space='buy', optimize=True, load=True) - # Optimal timeframe for the strategy. timeframe = '5m' @@ -72,6 +69,12 @@ class SampleStrategy(IStrategy): sell_profit_only = False ignore_roi_if_buy_signal = False + # Hyperoptable parameters + buy_rsi = IntParameter(low=1, high=50, default=30, space='buy', optimize=True, load=True) + sell_rsi = IntParameter(low=50, high=100, default=70, space='sell', optimize=True, load=True) + short_rsi = IntParameter(low=51, high=100, default=70, space='sell', optimize=True, load=True) + exit_short_rsi = IntParameter(low=1, high=50, default=30, space='buy', optimize=True, load=True) + # Number of candles the strategy requires before producing valid signals startup_candle_count: int = 30