added checks for python3.8 or lower since ast_comments.unparse() needs python 3.9 or higher.

testing with python 3.8 would make the build fail tests, skipping it there.
This commit is contained in:
hippocritical 2023-03-10 08:59:07 +01:00
parent 1bb697e58c
commit bfc7f48f17
2 changed files with 143 additions and 131 deletions

View File

@ -1,4 +1,5 @@
import logging
import sys
import time
from pathlib import Path
from typing import Any, Dict
@ -19,6 +20,12 @@ 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.")
else:
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
strategy_objs = StrategyResolver.search_all_objects(

View File

@ -1,12 +1,17 @@
# pragma pylint: disable=missing-docstring, protected-access, invalid-name
import sys
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:
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():
@ -17,62 +22,62 @@ class testClass(IStrategy):
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 = {
@ -81,7 +86,7 @@ class someStrategy(IStrategy):
# This is the 4th comment
stoploss = -0.1
""")
""")
# currently still missing:
# Webhook terminology, Telegram notification settings, Strategy/Config settings