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:
hippocritical 2023-03-10 09:23:56 +01:00
parent 5f8202e1b5
commit a3988f56b2
2 changed files with 138 additions and 139 deletions

View File

@ -20,12 +20,9 @@ def start_strategy_update(args: Dict[str, Any]) -> None:
:return: None
"""
if sys.version_info <= (3, 8):
print("This code requires Python 3.9 or higher. "
"We cannot continue. "
"Please upgrade your python version to use this command.")
if sys.version_info == (3, 8): # pragma: no cover
sys.exit("Freqtrade strategy updater requires Python version >= 3.9")
else:
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
strategy_objs = StrategyResolver.search_all_objects(

View File

@ -2,16 +2,18 @@
import sys
import pytest
from freqtrade.strategy.strategyupdater import StrategyUpdater
def test_strategy_updater(default_conf, caplog) -> None:
if sys.version_info <= (3, 8):
print("skipped tests since python version is 3.8 or lower.")
else:
if sys.version_info < (3, 9):
pytest.skip("StrategyUpdater is not compatible with Python 3.8", allow_module_level=True)
instance_strategy_updater = StrategyUpdater()
modified_code1 = instance_strategy_updater.update_code("""
class testClass(IStrategy):
class testClass(IStrategy):
def populate_buy_trend():
pass
def populate_sell_trend():
@ -22,62 +24,62 @@ def test_strategy_updater(default_conf, caplog) -> None:
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')
""")
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
""")
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
""")
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):
def confirm_trade_exit(sell_reason: str):
pass
""")
modified_code6 = instance_strategy_updater.update_code("""
order_time_in_force = {
order_time_in_force = {
'buy': 'gtc',
'sell': 'ioc'
}
order_types = {
}
order_types = {
'buy': 'limit',
'sell': 'market',
'stoploss': 'market',
'stoploss_on_exchange': False
}
unfilledtimeout = {
}
unfilledtimeout = {
'buy': 1,
'sell': 2
}
""")
}
""")
modified_code7 = instance_strategy_updater.update_code("""
def confirm_trade_exit(sell_reason):
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'
""")
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
# 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):
class someStrategy(IStrategy):
# This is the 3rd comment
# This attribute will be overridden if the config file contains "minimal_roi"
minimal_roi = {
@ -86,7 +88,7 @@ def test_strategy_updater(default_conf, caplog) -> None:
# This is the 4th comment
stoploss = -0.1
""")
""")
# currently still missing:
# Webhook terminology, Telegram notification settings, Strategy/Config settings