mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-12 19:23:55 +00:00
Sorry matthias, did not see that you already committed something and did overwrite you.
Added your version to it instead of mine and pushed again (since it was already overwritten by me).
This commit is contained in:
parent
5f8202e1b5
commit
a3988f56b2
|
@ -20,34 +20,31 @@ def start_strategy_update(args: Dict[str, Any]) -> None:
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if sys.version_info <= (3, 8):
|
if sys.version_info == (3, 8): # pragma: no cover
|
||||||
print("This code requires Python 3.9 or higher. "
|
sys.exit("Freqtrade strategy updater requires Python version >= 3.9")
|
||||||
"We cannot continue. "
|
|
||||||
"Please upgrade your python version to use this command.")
|
|
||||||
|
|
||||||
else:
|
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
||||||
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
|
||||||
|
|
||||||
strategy_objs = StrategyResolver.search_all_objects(
|
strategy_objs = StrategyResolver.search_all_objects(
|
||||||
config, enum_failed=False, recursive=config.get('recursive_strategy_search', False))
|
config, enum_failed=False, recursive=config.get('recursive_strategy_search', False))
|
||||||
|
|
||||||
filtered_strategy_objs = []
|
filtered_strategy_objs = []
|
||||||
if 'strategy_list' in args:
|
if 'strategy_list' in args:
|
||||||
for args_strategy in args['strategy_list']:
|
for args_strategy in args['strategy_list']:
|
||||||
for strategy_obj in strategy_objs:
|
|
||||||
if (strategy_obj['name'] == args_strategy
|
|
||||||
and strategy_obj not in filtered_strategy_objs):
|
|
||||||
filtered_strategy_objs.append(strategy_obj)
|
|
||||||
break
|
|
||||||
|
|
||||||
for filtered_strategy_obj in filtered_strategy_objs:
|
|
||||||
start_conversion(filtered_strategy_obj, config)
|
|
||||||
else:
|
|
||||||
processed_locations = set()
|
|
||||||
for strategy_obj in strategy_objs:
|
for strategy_obj in strategy_objs:
|
||||||
if strategy_obj['location'] not in processed_locations:
|
if (strategy_obj['name'] == args_strategy
|
||||||
processed_locations.add(strategy_obj['location'])
|
and strategy_obj not in filtered_strategy_objs):
|
||||||
start_conversion(strategy_obj, config)
|
filtered_strategy_objs.append(strategy_obj)
|
||||||
|
break
|
||||||
|
|
||||||
|
for filtered_strategy_obj in filtered_strategy_objs:
|
||||||
|
start_conversion(filtered_strategy_obj, config)
|
||||||
|
else:
|
||||||
|
processed_locations = set()
|
||||||
|
for strategy_obj in strategy_objs:
|
||||||
|
if strategy_obj['location'] not in processed_locations:
|
||||||
|
processed_locations.add(strategy_obj['location'])
|
||||||
|
start_conversion(strategy_obj, config)
|
||||||
|
|
||||||
|
|
||||||
def start_conversion(strategy_obj, config):
|
def start_conversion(strategy_obj, config):
|
||||||
|
|
|
@ -2,134 +2,136 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from freqtrade.strategy.strategyupdater import StrategyUpdater
|
from freqtrade.strategy.strategyupdater import StrategyUpdater
|
||||||
|
|
||||||
|
|
||||||
def test_strategy_updater(default_conf, caplog) -> None:
|
def test_strategy_updater(default_conf, caplog) -> None:
|
||||||
if sys.version_info <= (3, 8):
|
if sys.version_info < (3, 9):
|
||||||
print("skipped tests since python version is 3.8 or lower.")
|
pytest.skip("StrategyUpdater is not compatible with Python 3.8", allow_module_level=True)
|
||||||
else:
|
|
||||||
instance_strategy_updater = StrategyUpdater()
|
instance_strategy_updater = StrategyUpdater()
|
||||||
modified_code1 = instance_strategy_updater.update_code("""
|
modified_code1 = instance_strategy_updater.update_code("""
|
||||||
class testClass(IStrategy):
|
class testClass(IStrategy):
|
||||||
def populate_buy_trend():
|
def populate_buy_trend():
|
||||||
pass
|
|
||||||
def populate_sell_trend():
|
|
||||||
pass
|
|
||||||
def check_buy_timeout():
|
|
||||||
pass
|
|
||||||
def check_sell_timeout():
|
|
||||||
pass
|
|
||||||
def custom_sell():
|
|
||||||
pass
|
|
||||||
""")
|
|
||||||
modified_code2 = instance_strategy_updater.update_code("""
|
|
||||||
ticker_interval = '15m'
|
|
||||||
buy_some_parameter = IntParameter(space='buy')
|
|
||||||
sell_some_parameter = IntParameter(space='sell')
|
|
||||||
""")
|
|
||||||
modified_code3 = instance_strategy_updater.update_code("""
|
|
||||||
use_sell_signal = True
|
|
||||||
sell_profit_only = True
|
|
||||||
sell_profit_offset = True
|
|
||||||
ignore_roi_if_buy_signal = True
|
|
||||||
forcebuy_enable = True
|
|
||||||
""")
|
|
||||||
modified_code4 = instance_strategy_updater.update_code("""
|
|
||||||
dataframe.loc[reduce(lambda x, y: x & y, conditions), ["buy", "buy_tag"]] = (1, "buy_signal_1")
|
|
||||||
dataframe.loc[reduce(lambda x, y: x & y, conditions), 'sell'] = 1
|
|
||||||
""")
|
|
||||||
modified_code5 = instance_strategy_updater.update_code("""
|
|
||||||
def confirm_trade_exit(sell_reason: str):
|
|
||||||
pass
|
pass
|
||||||
""")
|
def populate_sell_trend():
|
||||||
modified_code6 = instance_strategy_updater.update_code("""
|
pass
|
||||||
order_time_in_force = {
|
def check_buy_timeout():
|
||||||
'buy': 'gtc',
|
pass
|
||||||
'sell': 'ioc'
|
def check_sell_timeout():
|
||||||
|
pass
|
||||||
|
def custom_sell():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
modified_code2 = instance_strategy_updater.update_code("""
|
||||||
|
ticker_interval = '15m'
|
||||||
|
buy_some_parameter = IntParameter(space='buy')
|
||||||
|
sell_some_parameter = IntParameter(space='sell')
|
||||||
|
""")
|
||||||
|
modified_code3 = instance_strategy_updater.update_code("""
|
||||||
|
use_sell_signal = True
|
||||||
|
sell_profit_only = True
|
||||||
|
sell_profit_offset = True
|
||||||
|
ignore_roi_if_buy_signal = True
|
||||||
|
forcebuy_enable = True
|
||||||
|
""")
|
||||||
|
modified_code4 = instance_strategy_updater.update_code("""
|
||||||
|
dataframe.loc[reduce(lambda x, y: x & y, conditions), ["buy", "buy_tag"]] = (1, "buy_signal_1")
|
||||||
|
dataframe.loc[reduce(lambda x, y: x & y, conditions), 'sell'] = 1
|
||||||
|
""")
|
||||||
|
modified_code5 = instance_strategy_updater.update_code("""
|
||||||
|
def confirm_trade_exit(sell_reason: str):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
modified_code6 = instance_strategy_updater.update_code("""
|
||||||
|
order_time_in_force = {
|
||||||
|
'buy': 'gtc',
|
||||||
|
'sell': 'ioc'
|
||||||
|
}
|
||||||
|
order_types = {
|
||||||
|
'buy': 'limit',
|
||||||
|
'sell': 'market',
|
||||||
|
'stoploss': 'market',
|
||||||
|
'stoploss_on_exchange': False
|
||||||
|
}
|
||||||
|
unfilledtimeout = {
|
||||||
|
'buy': 1,
|
||||||
|
'sell': 2
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
|
||||||
|
modified_code7 = instance_strategy_updater.update_code("""
|
||||||
|
def confirm_trade_exit(sell_reason):
|
||||||
|
if (sell_reason == 'stop_loss'):
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
modified_code8 = instance_strategy_updater.update_code("""
|
||||||
|
sell_reason == 'sell_signal'
|
||||||
|
sell_reason == 'force_sell'
|
||||||
|
sell_reason == 'emergency_sell'
|
||||||
|
""")
|
||||||
|
modified_code9 = instance_strategy_updater.update_code("""
|
||||||
|
# This is the 1st comment
|
||||||
|
import talib.abstract as ta
|
||||||
|
# This is the 2nd comment
|
||||||
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
|
|
||||||
|
|
||||||
|
class someStrategy(IStrategy):
|
||||||
|
# This is the 3rd comment
|
||||||
|
# This attribute will be overridden if the config file contains "minimal_roi"
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.50
|
||||||
}
|
}
|
||||||
order_types = {
|
|
||||||
'buy': 'limit',
|
|
||||||
'sell': 'market',
|
|
||||||
'stoploss': 'market',
|
|
||||||
'stoploss_on_exchange': False
|
|
||||||
}
|
|
||||||
unfilledtimeout = {
|
|
||||||
'buy': 1,
|
|
||||||
'sell': 2
|
|
||||||
}
|
|
||||||
""")
|
|
||||||
|
|
||||||
modified_code7 = instance_strategy_updater.update_code("""
|
# This is the 4th comment
|
||||||
def confirm_trade_exit(sell_reason):
|
stoploss = -0.1
|
||||||
if (sell_reason == 'stop_loss'):
|
""")
|
||||||
pass
|
# currently still missing:
|
||||||
""")
|
# Webhook terminology, Telegram notification settings, Strategy/Config settings
|
||||||
modified_code8 = instance_strategy_updater.update_code("""
|
|
||||||
sell_reason == 'sell_signal'
|
|
||||||
sell_reason == 'force_sell'
|
|
||||||
sell_reason == 'emergency_sell'
|
|
||||||
""")
|
|
||||||
modified_code9 = instance_strategy_updater.update_code("""
|
|
||||||
# This is the 1st comment
|
|
||||||
import talib.abstract as ta
|
|
||||||
# This is the 2nd comment
|
|
||||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
|
||||||
|
|
||||||
|
assert "populate_entry_trend" in modified_code1
|
||||||
|
assert "populate_exit_trend" in modified_code1
|
||||||
|
assert "check_entry_timeout" in modified_code1
|
||||||
|
assert "check_exit_timeout" in modified_code1
|
||||||
|
assert "custom_exit" in modified_code1
|
||||||
|
assert "INTERFACE_VERSION = 3" in modified_code1
|
||||||
|
|
||||||
class someStrategy(IStrategy):
|
assert "timeframe" in modified_code2
|
||||||
# This is the 3rd comment
|
# check for not editing hyperopt spaces
|
||||||
# This attribute will be overridden if the config file contains "minimal_roi"
|
assert "space='buy'" in modified_code2
|
||||||
minimal_roi = {
|
assert "space='sell'" in modified_code2
|
||||||
"0": 0.50
|
|
||||||
}
|
|
||||||
|
|
||||||
# This is the 4th comment
|
assert "use_exit_signal" in modified_code3
|
||||||
stoploss = -0.1
|
assert "exit_profit_only" in modified_code3
|
||||||
""")
|
assert "exit_profit_offset" in modified_code3
|
||||||
# currently still missing:
|
assert "ignore_roi_if_entry_signal" in modified_code3
|
||||||
# Webhook terminology, Telegram notification settings, Strategy/Config settings
|
assert "force_entry_enable" in modified_code3
|
||||||
|
|
||||||
assert "populate_entry_trend" in modified_code1
|
assert "enter_long" in modified_code4
|
||||||
assert "populate_exit_trend" in modified_code1
|
assert "exit_long" in modified_code4
|
||||||
assert "check_entry_timeout" in modified_code1
|
assert "enter_tag" in modified_code4
|
||||||
assert "check_exit_timeout" in modified_code1
|
|
||||||
assert "custom_exit" in modified_code1
|
|
||||||
assert "INTERFACE_VERSION = 3" in modified_code1
|
|
||||||
|
|
||||||
assert "timeframe" in modified_code2
|
assert "exit_reason" in modified_code5
|
||||||
# check for not editing hyperopt spaces
|
|
||||||
assert "space='buy'" in modified_code2
|
|
||||||
assert "space='sell'" in modified_code2
|
|
||||||
|
|
||||||
assert "use_exit_signal" in modified_code3
|
assert "'entry': 'gtc'" in modified_code6
|
||||||
assert "exit_profit_only" in modified_code3
|
assert "'exit': 'ioc'" in modified_code6
|
||||||
assert "exit_profit_offset" in modified_code3
|
assert "'entry': 'limit'" in modified_code6
|
||||||
assert "ignore_roi_if_entry_signal" in modified_code3
|
assert "'exit': 'market'" in modified_code6
|
||||||
assert "force_entry_enable" in modified_code3
|
assert "'entry': 1" in modified_code6
|
||||||
|
assert "'exit': 2" in modified_code6
|
||||||
|
|
||||||
assert "enter_long" in modified_code4
|
assert "exit_reason" in modified_code7
|
||||||
assert "exit_long" in modified_code4
|
assert "exit_reason == 'stop_loss'" in modified_code7
|
||||||
assert "enter_tag" in modified_code4
|
|
||||||
|
|
||||||
assert "exit_reason" in modified_code5
|
# those tests currently don't work, next in line.
|
||||||
|
assert "exit_signal" in modified_code8
|
||||||
|
assert "exit_reason" in modified_code8
|
||||||
|
assert "force_exit" in modified_code8
|
||||||
|
assert "emergency_exit" in modified_code8
|
||||||
|
|
||||||
assert "'entry': 'gtc'" in modified_code6
|
assert "This is the 1st comment" in modified_code9
|
||||||
assert "'exit': 'ioc'" in modified_code6
|
assert "This is the 2nd comment" in modified_code9
|
||||||
assert "'entry': 'limit'" in modified_code6
|
assert "This is the 3rd comment" in modified_code9
|
||||||
assert "'exit': 'market'" in modified_code6
|
|
||||||
assert "'entry': 1" in modified_code6
|
|
||||||
assert "'exit': 2" in modified_code6
|
|
||||||
|
|
||||||
assert "exit_reason" in modified_code7
|
|
||||||
assert "exit_reason == 'stop_loss'" in modified_code7
|
|
||||||
|
|
||||||
# those tests currently don't work, next in line.
|
|
||||||
assert "exit_signal" in modified_code8
|
|
||||||
assert "exit_reason" in modified_code8
|
|
||||||
assert "force_exit" in modified_code8
|
|
||||||
assert "emergency_exit" in modified_code8
|
|
||||||
|
|
||||||
assert "This is the 1st comment" in modified_code9
|
|
||||||
assert "This is the 2nd comment" in modified_code9
|
|
||||||
assert "This is the 3rd comment" in modified_code9
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user