create compatibility code
This commit is contained in:
parent
3e895ae74a
commit
09fe3c6f5e
@ -67,3 +67,9 @@ def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None:
|
|||||||
"'tradable_balance_ratio' and remove 'capital_available_percentage' "
|
"'tradable_balance_ratio' and remove 'capital_available_percentage' "
|
||||||
"from the edge configuration."
|
"from the edge configuration."
|
||||||
)
|
)
|
||||||
|
if 'ticker_interval' in config:
|
||||||
|
logger.warning(
|
||||||
|
"DEPRECATED: "
|
||||||
|
"Please use 'timeframe' instead of 'ticker_interval."
|
||||||
|
)
|
||||||
|
config['timeframe'] = config['ticker_interval']
|
||||||
|
@ -71,7 +71,6 @@ CONF_SCHEMA = {
|
|||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
'max_open_trades': {'type': ['integer', 'number'], 'minimum': -1},
|
'max_open_trades': {'type': ['integer', 'number'], 'minimum': -1},
|
||||||
'ticker_interval': {'type': 'string'},
|
|
||||||
'timeframe': {'type': 'string'},
|
'timeframe': {'type': 'string'},
|
||||||
'stake_currency': {'type': 'string'},
|
'stake_currency': {'type': 'string'},
|
||||||
'stake_amount': {
|
'stake_amount': {
|
||||||
|
@ -50,6 +50,14 @@ class StrategyResolver(IResolver):
|
|||||||
if 'ask_strategy' not in config:
|
if 'ask_strategy' not in config:
|
||||||
config['ask_strategy'] = {}
|
config['ask_strategy'] = {}
|
||||||
|
|
||||||
|
if hasattr(strategy, 'ticker_interval') and not hasattr(strategy, 'timeframe'):
|
||||||
|
# Assign ticker_interval to timeframe to keep compatibility
|
||||||
|
if 'timeframe' not in config:
|
||||||
|
logger.warning(
|
||||||
|
"DEPRECATED: Please migrate to using timeframe instead of ticker_interval."
|
||||||
|
)
|
||||||
|
strategy.timeframe = strategy.ticker_interval
|
||||||
|
|
||||||
# Set attributes
|
# Set attributes
|
||||||
# Check if we need to override configuration
|
# Check if we need to override configuration
|
||||||
# (Attribute name, default, subkey)
|
# (Attribute name, default, subkey)
|
||||||
@ -80,6 +88,9 @@ class StrategyResolver(IResolver):
|
|||||||
StrategyResolver._override_attribute_helper(strategy, config,
|
StrategyResolver._override_attribute_helper(strategy, config,
|
||||||
attribute, default)
|
attribute, default)
|
||||||
|
|
||||||
|
# Assign deprecated variable - to not break users code relying on this.
|
||||||
|
strategy.ticker_interval = strategy.timeframe
|
||||||
|
|
||||||
# Loop this list again to have output combined
|
# Loop this list again to have output combined
|
||||||
for attribute, _, subkey in attributes:
|
for attribute, _, subkey in attributes:
|
||||||
if subkey and attribute in config[subkey]:
|
if subkey and attribute in config[subkey]:
|
||||||
|
@ -85,8 +85,8 @@ class IStrategy(ABC):
|
|||||||
trailing_stop_positive_offset: float = 0.0
|
trailing_stop_positive_offset: float = 0.0
|
||||||
trailing_only_offset_is_reached = False
|
trailing_only_offset_is_reached = False
|
||||||
|
|
||||||
# associated ticker interval
|
# associated timeframe
|
||||||
ticker_interval: str
|
timeframe: str
|
||||||
|
|
||||||
# Optional order types
|
# Optional order types
|
||||||
order_types: Dict = {
|
order_types: Dict = {
|
||||||
|
@ -18,7 +18,6 @@ def test_default_strategy(result):
|
|||||||
metadata = {'pair': 'ETH/BTC'}
|
metadata = {'pair': 'ETH/BTC'}
|
||||||
assert type(strategy.minimal_roi) is dict
|
assert type(strategy.minimal_roi) is dict
|
||||||
assert type(strategy.stoploss) is float
|
assert type(strategy.stoploss) is float
|
||||||
assert type(strategy.ticker_interval) is str
|
|
||||||
assert type(strategy.timeframe) is str
|
assert type(strategy.timeframe) is str
|
||||||
indicators = strategy.populate_indicators(result, metadata)
|
indicators = strategy.populate_indicators(result, metadata)
|
||||||
assert type(indicators) is DataFrame
|
assert type(indicators) is DataFrame
|
||||||
|
Loading…
Reference in New Issue
Block a user