Skip to content

Commit

Permalink
Update strategy_version to INTERFACE_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Aug 26, 2019
1 parent 92011f8 commit 0e62b8b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion freqtrade/resolvers/strategy_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _load_strategy(
if any([x == 2 for x in [strategy._populate_fun_len,
strategy._buy_fun_len,
strategy._sell_fun_len]]):
strategy.strategy_version = 1
strategy.INTERFACE_VERSION = 1

try:
return import_strategy(strategy, config=config)
Expand Down
2 changes: 1 addition & 1 deletion freqtrade/strategy/default_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DefaultStrategy(IStrategy):
Default Strategy provided by freqtrade bot.
You can override it with your own strategy
"""
strategy_version: int = 2
INTERFACE_VERSION = 2

# Minimal ROI designed for the strategy
minimal_roi = {
Expand Down
4 changes: 2 additions & 2 deletions freqtrade/strategy/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class IStrategy(ABC):
"""
# Strategy interface version
# Default to version 2
# version 1 is the initial interface without metadata dict
# Version 1 is the initial interface without metadata dict
# Version 2 populate_* include metadata dict
strategy_version: int = 2
INTERFACE_VERSION: int = 2

_populate_fun_len: int = 0
_buy_fun_len: int = 0
Expand Down
6 changes: 3 additions & 3 deletions freqtrade/tests/strategy/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def test_call_deprecated_function(result, monkeypatch, default_conf):
assert resolver.strategy._populate_fun_len == 2
assert resolver.strategy._buy_fun_len == 2
assert resolver.strategy._sell_fun_len == 2
assert resolver.strategy.strategy_version == 1
assert resolver.strategy.INTERFACE_VERSION == 1

indicator_df = resolver.strategy.advise_indicators(result, metadata=metadata)
assert isinstance(indicator_df, DataFrame)
Expand All @@ -395,7 +395,7 @@ def test_call_deprecated_function(result, monkeypatch, default_conf):
assert 'sell' in selldf


def test_strategy_versioning(result, monkeypatch, default_conf):
def test_strategy_interface_versioning(result, monkeypatch, default_conf):
default_conf.update({'strategy': 'DefaultStrategy'})
resolver = StrategyResolver(default_conf)
metadata = {'pair': 'ETH/BTC'}
Expand All @@ -404,7 +404,7 @@ def test_strategy_versioning(result, monkeypatch, default_conf):
assert resolver.strategy._populate_fun_len == 3
assert resolver.strategy._buy_fun_len == 3
assert resolver.strategy._sell_fun_len == 3
assert resolver.strategy.strategy_version == 2
assert resolver.strategy.INTERFACE_VERSION == 2

indicator_df = resolver.strategy.advise_indicators(result, metadata=metadata)
assert isinstance(indicator_df, DataFrame)
Expand Down
2 changes: 1 addition & 1 deletion user_data/strategies/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TestStrategy(IStrategy):
"""
# Strategy intervace version - allow new iterations of the strategy interface.
# Check the documentation or the Sample strategy to get the latest version.
strategy_version: int = 2
INTERFACE_VERSION = 2

# Minimal ROI designed for the strategy.
# This attribute will be overridden if the config file contains "minimal_roi"
Expand Down

0 comments on commit 0e62b8b

Please sign in to comment.