mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
A few more formatting updates
This commit is contained in:
@@ -47,7 +47,8 @@ def test_strategy_updater_start(user_dir, capsys) -> None:
|
||||
|
||||
def test_strategy_updater_methods(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
modified_code1 = instance_strategy_updater.update_code("""
|
||||
modified_code1 = instance_strategy_updater.update_code(
|
||||
"""
|
||||
class testClass(IStrategy):
|
||||
def populate_buy_trend():
|
||||
pass
|
||||
@@ -59,7 +60,8 @@ class testClass(IStrategy):
|
||||
pass
|
||||
def custom_sell():
|
||||
pass
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
assert "populate_entry_trend" in modified_code1
|
||||
assert "populate_exit_trend" in modified_code1
|
||||
@@ -72,11 +74,13 @@ class testClass(IStrategy):
|
||||
def test_strategy_updater_params(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
|
||||
modified_code2 = instance_strategy_updater.update_code("""
|
||||
modified_code2 = instance_strategy_updater.update_code(
|
||||
"""
|
||||
ticker_interval = '15m'
|
||||
buy_some_parameter = IntParameter(space='buy')
|
||||
sell_some_parameter = IntParameter(space='sell')
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
assert "timeframe" in modified_code2
|
||||
# check for not editing hyperopt spaces
|
||||
@@ -86,13 +90,15 @@ sell_some_parameter = IntParameter(space='sell')
|
||||
|
||||
def test_strategy_updater_constants(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
modified_code3 = instance_strategy_updater.update_code("""
|
||||
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
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
assert "use_exit_signal" in modified_code3
|
||||
assert "exit_profit_only" in modified_code3
|
||||
@@ -103,10 +109,12 @@ forcebuy_enable = True
|
||||
|
||||
def test_strategy_updater_df_columns(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
modified_code = instance_strategy_updater.update_code("""
|
||||
modified_code = 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
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
assert "enter_long" in modified_code
|
||||
assert "exit_long" in modified_code
|
||||
@@ -115,18 +123,21 @@ dataframe.loc[reduce(lambda x, y: x & y, conditions), 'sell'] = 1
|
||||
|
||||
def test_strategy_updater_method_params(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
modified_code = instance_strategy_updater.update_code("""
|
||||
modified_code = instance_strategy_updater.update_code(
|
||||
"""
|
||||
def confirm_trade_exit(sell_reason: str):
|
||||
nr_orders = trade.nr_of_successful_buys
|
||||
pass
|
||||
""")
|
||||
"""
|
||||
)
|
||||
assert "exit_reason" in modified_code
|
||||
assert "nr_orders = trade.nr_of_successful_entries" in modified_code
|
||||
|
||||
|
||||
def test_strategy_updater_dicts(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
modified_code = instance_strategy_updater.update_code("""
|
||||
modified_code = instance_strategy_updater.update_code(
|
||||
"""
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'ioc'
|
||||
@@ -141,7 +152,8 @@ unfilledtimeout = {
|
||||
'buy': 1,
|
||||
'sell': 2
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
assert "'entry': 'gtc'" in modified_code
|
||||
assert "'exit': 'ioc'" in modified_code
|
||||
@@ -153,11 +165,13 @@ unfilledtimeout = {
|
||||
|
||||
def test_strategy_updater_comparisons(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
modified_code = instance_strategy_updater.update_code("""
|
||||
modified_code = instance_strategy_updater.update_code(
|
||||
"""
|
||||
def confirm_trade_exit(sell_reason):
|
||||
if (sell_reason == 'stop_loss'):
|
||||
pass
|
||||
""")
|
||||
"""
|
||||
)
|
||||
assert "exit_reason" in modified_code
|
||||
assert "exit_reason == 'stop_loss'" in modified_code
|
||||
|
||||
@@ -165,11 +179,13 @@ def confirm_trade_exit(sell_reason):
|
||||
def test_strategy_updater_strings(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
|
||||
modified_code = instance_strategy_updater.update_code("""
|
||||
modified_code = instance_strategy_updater.update_code(
|
||||
"""
|
||||
sell_reason == 'sell_signal'
|
||||
sell_reason == 'force_sell'
|
||||
sell_reason == 'emergency_sell'
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
# those tests currently don't work, next in line.
|
||||
assert "exit_signal" in modified_code
|
||||
@@ -180,7 +196,8 @@ sell_reason == 'emergency_sell'
|
||||
|
||||
def test_strategy_updater_comments(default_conf, caplog) -> None:
|
||||
instance_strategy_updater = StrategyUpdater()
|
||||
modified_code = instance_strategy_updater.update_code("""
|
||||
modified_code = instance_strategy_updater.update_code(
|
||||
"""
|
||||
# This is the 1st comment
|
||||
import talib.abstract as ta
|
||||
# This is the 2nd comment
|
||||
@@ -197,7 +214,8 @@ class someStrategy(IStrategy):
|
||||
|
||||
# This is the 4th comment
|
||||
stoploss = -0.1
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
assert "This is the 1st comment" in modified_code
|
||||
assert "This is the 2nd comment" in modified_code
|
||||
|
||||
Reference in New Issue
Block a user