Merge branch 'develop' into doc/pricing_reasons
This commit is contained in:
@@ -77,7 +77,7 @@ def get_patched_exchange(mocker, config, api_mock=None, id='bittrex',
|
||||
patch_exchange(mocker, api_mock, id, mock_markets)
|
||||
config["exchange"]["name"] = id
|
||||
try:
|
||||
exchange = ExchangeResolver(id, config).exchange
|
||||
exchange = ExchangeResolver.load_exchange(id, config)
|
||||
except ImportError:
|
||||
exchange = Exchange(config)
|
||||
return exchange
|
||||
|
@@ -124,19 +124,19 @@ def test_exchange_resolver(default_conf, mocker, caplog):
|
||||
mocker.patch('freqtrade.exchange.Exchange._load_async_markets', MagicMock())
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_pairs', MagicMock())
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes', MagicMock())
|
||||
exchange = ExchangeResolver('Bittrex', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('Bittrex', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert log_has_re(r"No .* specific subclass found. Using the generic class instead.", caplog)
|
||||
caplog.clear()
|
||||
|
||||
exchange = ExchangeResolver('kraken', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('kraken', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Kraken)
|
||||
assert not isinstance(exchange, Binance)
|
||||
assert not log_has_re(r"No .* specific subclass found. Using the generic class instead.",
|
||||
caplog)
|
||||
|
||||
exchange = ExchangeResolver('binance', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('binance', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Binance)
|
||||
assert not isinstance(exchange, Kraken)
|
||||
@@ -145,7 +145,7 @@ def test_exchange_resolver(default_conf, mocker, caplog):
|
||||
caplog)
|
||||
|
||||
# Test mapping
|
||||
exchange = ExchangeResolver('binanceus', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('binanceus', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Binance)
|
||||
assert not isinstance(exchange, Kraken)
|
||||
|
@@ -163,7 +163,7 @@ def test_hyperoptresolver(mocker, default_conf, caplog) -> None:
|
||||
MagicMock(return_value=hyperopt(default_conf))
|
||||
)
|
||||
default_conf.update({'hyperopt': 'DefaultHyperOpt'})
|
||||
x = HyperOptResolver(default_conf).hyperopt
|
||||
x = HyperOptResolver.load_hyperopt(default_conf)
|
||||
assert not hasattr(x, 'populate_indicators')
|
||||
assert not hasattr(x, 'populate_buy_trend')
|
||||
assert not hasattr(x, 'populate_sell_trend')
|
||||
@@ -180,7 +180,7 @@ def test_hyperoptresolver_wrongname(mocker, default_conf, caplog) -> None:
|
||||
default_conf.update({'hyperopt': "NonExistingHyperoptClass"})
|
||||
|
||||
with pytest.raises(OperationalException, match=r'Impossible to load Hyperopt.*'):
|
||||
HyperOptResolver(default_conf).hyperopt
|
||||
HyperOptResolver.load_hyperopt(default_conf)
|
||||
|
||||
|
||||
def test_hyperoptresolver_noname(default_conf):
|
||||
@@ -188,7 +188,7 @@ def test_hyperoptresolver_noname(default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match="No Hyperopt set. Please use `--hyperopt` to specify "
|
||||
"the Hyperopt class to use."):
|
||||
HyperOptResolver(default_conf)
|
||||
HyperOptResolver.load_hyperopt(default_conf)
|
||||
|
||||
|
||||
def test_hyperoptlossresolver(mocker, default_conf, caplog) -> None:
|
||||
@@ -198,7 +198,7 @@ def test_hyperoptlossresolver(mocker, default_conf, caplog) -> None:
|
||||
'freqtrade.resolvers.hyperopt_resolver.HyperOptLossResolver._load_hyperoptloss',
|
||||
MagicMock(return_value=hl)
|
||||
)
|
||||
x = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
x = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
assert hasattr(x, "hyperopt_loss_function")
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ def test_hyperoptlossresolver_wrongname(mocker, default_conf, caplog) -> None:
|
||||
default_conf.update({'hyperopt_loss': "NonExistingLossClass"})
|
||||
|
||||
with pytest.raises(OperationalException, match=r'Impossible to load HyperoptLoss.*'):
|
||||
HyperOptLossResolver(default_conf).hyperopt
|
||||
HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
|
||||
|
||||
def test_start_not_installed(mocker, default_conf, caplog, import_fails) -> None:
|
||||
@@ -286,7 +286,7 @@ def test_start_filelock(mocker, default_conf, caplog) -> None:
|
||||
|
||||
|
||||
def test_loss_calculation_prefer_correct_trade_count(default_conf, hyperopt_results) -> None:
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, 600)
|
||||
over = hl.hyperopt_loss_function(hyperopt_results, 600 + 100)
|
||||
under = hl.hyperopt_loss_function(hyperopt_results, 600 - 100)
|
||||
@@ -298,7 +298,7 @@ def test_loss_calculation_prefer_shorter_trades(default_conf, hyperopt_results)
|
||||
resultsb = hyperopt_results.copy()
|
||||
resultsb.loc[1, 'trade_duration'] = 20
|
||||
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
longer = hl.hyperopt_loss_function(hyperopt_results, 100)
|
||||
shorter = hl.hyperopt_loss_function(resultsb, 100)
|
||||
assert shorter < longer
|
||||
@@ -310,7 +310,7 @@ def test_loss_calculation_has_limited_profit(default_conf, hyperopt_results) ->
|
||||
results_under = hyperopt_results.copy()
|
||||
results_under['profit_percent'] = hyperopt_results['profit_percent'] / 2
|
||||
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, 600)
|
||||
over = hl.hyperopt_loss_function(results_over, 600)
|
||||
under = hl.hyperopt_loss_function(results_under, 600)
|
||||
@@ -325,7 +325,7 @@ def test_sharpe_loss_prefers_higher_profits(default_conf, hyperopt_results) -> N
|
||||
results_under['profit_percent'] = hyperopt_results['profit_percent'] / 2
|
||||
|
||||
default_conf.update({'hyperopt_loss': 'SharpeHyperOptLoss'})
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, len(hyperopt_results),
|
||||
datetime(2019, 1, 1), datetime(2019, 5, 1))
|
||||
over = hl.hyperopt_loss_function(results_over, len(hyperopt_results),
|
||||
@@ -343,7 +343,7 @@ def test_onlyprofit_loss_prefers_higher_profits(default_conf, hyperopt_results)
|
||||
results_under['profit_percent'] = hyperopt_results['profit_percent'] / 2
|
||||
|
||||
default_conf.update({'hyperopt_loss': 'OnlyProfitHyperOptLoss'})
|
||||
hl = HyperOptLossResolver(default_conf).hyperoptloss
|
||||
hl = HyperOptLossResolver.load_hyperoptloss(default_conf)
|
||||
correct = hl.hyperopt_loss_function(hyperopt_results, len(hyperopt_results),
|
||||
datetime(2019, 1, 1), datetime(2019, 5, 1))
|
||||
over = hl.hyperopt_loss_function(results_over, len(hyperopt_results),
|
||||
|
@@ -53,7 +53,8 @@ def test_load_pairlist_noexist(mocker, markets, default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Impossible to load Pairlist 'NonexistingPairList'. "
|
||||
r"This class does not exist or contains Python code errors."):
|
||||
PairListResolver('NonexistingPairList', bot.exchange, plm, default_conf, {}, 1)
|
||||
PairListResolver.load_pairlist('NonexistingPairList', bot.exchange, plm,
|
||||
default_conf, {}, 1)
|
||||
|
||||
|
||||
def test_refresh_market_pair_not_in_whitelist(mocker, markets, static_pl_conf):
|
||||
|
@@ -302,6 +302,19 @@ def test_is_pair_locked(default_conf):
|
||||
# ETH/BTC locked for 4 minutes
|
||||
assert strategy.is_pair_locked(pair)
|
||||
|
||||
# Test lock does not change
|
||||
lock = strategy._pair_locked_until[pair]
|
||||
strategy.lock_pair(pair, arrow.utcnow().shift(minutes=2).datetime)
|
||||
assert lock == strategy._pair_locked_until[pair]
|
||||
|
||||
# XRP/BTC should not be locked now
|
||||
pair = 'XRP/BTC'
|
||||
assert not strategy.is_pair_locked(pair)
|
||||
|
||||
# Unlocking a pair that's not locked should not raise an error
|
||||
strategy.unlock_pair(pair)
|
||||
|
||||
# Unlock original pair
|
||||
pair = 'ETH/BTC'
|
||||
strategy.unlock_pair(pair)
|
||||
assert not strategy.is_pair_locked(pair)
|
||||
|
@@ -39,8 +39,8 @@ def test_load_strategy(default_conf, result):
|
||||
default_conf.update({'strategy': 'SampleStrategy',
|
||||
'strategy_path': str(Path(__file__).parents[2] / 'freqtrade/templates')
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
|
||||
|
||||
def test_load_strategy_base64(result, caplog, default_conf):
|
||||
@@ -48,8 +48,8 @@ def test_load_strategy_base64(result, caplog, default_conf):
|
||||
encoded_string = urlsafe_b64encode(file.read()).decode("utf-8")
|
||||
default_conf.update({'strategy': 'SampleStrategy:{}'.format(encoded_string)})
|
||||
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
# Make sure strategy was loaded from base64 (using temp directory)!!
|
||||
assert log_has_re(r"Using resolved strategy SampleStrategy from '"
|
||||
r".*(/|\\).*(/|\\)SampleStrategy\.py'\.\.\.", caplog)
|
||||
@@ -57,13 +57,13 @@ def test_load_strategy_base64(result, caplog, default_conf):
|
||||
|
||||
def test_load_strategy_invalid_directory(result, caplog, default_conf):
|
||||
default_conf['strategy'] = 'DefaultStrategy'
|
||||
resolver = StrategyResolver(default_conf)
|
||||
extra_dir = Path.cwd() / 'some/path'
|
||||
resolver._load_strategy('DefaultStrategy', config=default_conf, extra_dir=extra_dir)
|
||||
strategy = StrategyResolver._load_strategy('DefaultStrategy', config=default_conf,
|
||||
extra_dir=extra_dir)
|
||||
|
||||
assert log_has_re(r'Path .*' + r'some.*path.*' + r'.* does not exist', caplog)
|
||||
|
||||
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
assert 'rsi' in strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
|
||||
|
||||
def test_load_not_found_strategy(default_conf):
|
||||
@@ -71,7 +71,7 @@ def test_load_not_found_strategy(default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Impossible to load Strategy 'NotFoundStrategy'. "
|
||||
r"This class does not exist or contains Python code errors."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_load_strategy_noname(default_conf):
|
||||
@@ -79,30 +79,30 @@ def test_load_strategy_noname(default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match="No strategy set. Please use `--strategy` to specify "
|
||||
"the strategy class to use."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_strategy(result, default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
assert resolver.strategy.minimal_roi[0] == 0.04
|
||||
assert strategy.minimal_roi[0] == 0.04
|
||||
assert default_conf["minimal_roi"]['0'] == 0.04
|
||||
|
||||
assert resolver.strategy.stoploss == -0.10
|
||||
assert strategy.stoploss == -0.10
|
||||
assert default_conf['stoploss'] == -0.10
|
||||
|
||||
assert resolver.strategy.ticker_interval == '5m'
|
||||
assert strategy.ticker_interval == '5m'
|
||||
assert default_conf['ticker_interval'] == '5m'
|
||||
|
||||
df_indicators = resolver.strategy.advise_indicators(result, metadata=metadata)
|
||||
df_indicators = strategy.advise_indicators(result, metadata=metadata)
|
||||
assert 'adx' in df_indicators
|
||||
|
||||
dataframe = resolver.strategy.advise_buy(df_indicators, metadata=metadata)
|
||||
dataframe = strategy.advise_buy(df_indicators, metadata=metadata)
|
||||
assert 'buy' in dataframe.columns
|
||||
|
||||
dataframe = resolver.strategy.advise_sell(df_indicators, metadata=metadata)
|
||||
dataframe = strategy.advise_sell(df_indicators, metadata=metadata)
|
||||
assert 'sell' in dataframe.columns
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ def test_strategy_override_minimal_roi(caplog, default_conf):
|
||||
"0": 0.5
|
||||
}
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.minimal_roi[0] == 0.5
|
||||
assert strategy.minimal_roi[0] == 0.5
|
||||
assert log_has("Override strategy 'minimal_roi' with value in config file: {'0': 0.5}.", caplog)
|
||||
|
||||
|
||||
@@ -126,9 +126,9 @@ def test_strategy_override_stoploss(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'stoploss': -0.5
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.stoploss == -0.5
|
||||
assert strategy.stoploss == -0.5
|
||||
assert log_has("Override strategy 'stoploss' with value in config file: -0.5.", caplog)
|
||||
|
||||
|
||||
@@ -138,10 +138,10 @@ def test_strategy_override_trailing_stop(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'trailing_stop': True
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.trailing_stop
|
||||
assert isinstance(resolver.strategy.trailing_stop, bool)
|
||||
assert strategy.trailing_stop
|
||||
assert isinstance(strategy.trailing_stop, bool)
|
||||
assert log_has("Override strategy 'trailing_stop' with value in config file: True.", caplog)
|
||||
|
||||
|
||||
@@ -153,13 +153,13 @@ def test_strategy_override_trailing_stop_positive(caplog, default_conf):
|
||||
'trailing_stop_positive_offset': -0.2
|
||||
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.trailing_stop_positive == -0.1
|
||||
assert strategy.trailing_stop_positive == -0.1
|
||||
assert log_has("Override strategy 'trailing_stop_positive' with value in config file: -0.1.",
|
||||
caplog)
|
||||
|
||||
assert resolver.strategy.trailing_stop_positive_offset == -0.2
|
||||
assert strategy.trailing_stop_positive_offset == -0.2
|
||||
assert log_has("Override strategy 'trailing_stop_positive' with value in config file: -0.1.",
|
||||
caplog)
|
||||
|
||||
@@ -172,10 +172,10 @@ def test_strategy_override_ticker_interval(caplog, default_conf):
|
||||
'ticker_interval': 60,
|
||||
'stake_currency': 'ETH'
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.ticker_interval == 60
|
||||
assert resolver.strategy.stake_currency == 'ETH'
|
||||
assert strategy.ticker_interval == 60
|
||||
assert strategy.stake_currency == 'ETH'
|
||||
assert log_has("Override strategy 'ticker_interval' with value in config file: 60.",
|
||||
caplog)
|
||||
|
||||
@@ -187,9 +187,9 @@ def test_strategy_override_process_only_new_candles(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'process_only_new_candles': True
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.process_only_new_candles
|
||||
assert strategy.process_only_new_candles
|
||||
assert log_has("Override strategy 'process_only_new_candles' with value in config file: True.",
|
||||
caplog)
|
||||
|
||||
@@ -207,11 +207,11 @@ def test_strategy_override_order_types(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'order_types': order_types
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.order_types
|
||||
assert strategy.order_types
|
||||
for method in ['buy', 'sell', 'stoploss', 'stoploss_on_exchange']:
|
||||
assert resolver.strategy.order_types[method] == order_types[method]
|
||||
assert strategy.order_types[method] == order_types[method]
|
||||
|
||||
assert log_has("Override strategy 'order_types' with value in config file:"
|
||||
" {'buy': 'market', 'sell': 'limit', 'stoploss': 'limit',"
|
||||
@@ -225,7 +225,7 @@ def test_strategy_override_order_types(caplog, default_conf):
|
||||
with pytest.raises(ImportError,
|
||||
match=r"Impossible to load Strategy 'DefaultStrategy'. "
|
||||
r"Order-types mapping is incomplete."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_strategy_override_order_tif(caplog, default_conf):
|
||||
@@ -240,11 +240,11 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
'strategy': 'DefaultStrategy',
|
||||
'order_time_in_force': order_time_in_force
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.order_time_in_force
|
||||
assert strategy.order_time_in_force
|
||||
for method in ['buy', 'sell']:
|
||||
assert resolver.strategy.order_time_in_force[method] == order_time_in_force[method]
|
||||
assert strategy.order_time_in_force[method] == order_time_in_force[method]
|
||||
|
||||
assert log_has("Override strategy 'order_time_in_force' with value in config file:"
|
||||
" {'buy': 'fok', 'sell': 'gtc'}.", caplog)
|
||||
@@ -257,7 +257,7 @@ def test_strategy_override_order_tif(caplog, default_conf):
|
||||
with pytest.raises(ImportError,
|
||||
match=r"Impossible to load Strategy 'DefaultStrategy'. "
|
||||
r"Order-time-in-force mapping is incomplete."):
|
||||
StrategyResolver(default_conf)
|
||||
StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
|
||||
def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
@@ -265,9 +265,9 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert resolver.strategy.use_sell_signal
|
||||
assert isinstance(resolver.strategy.use_sell_signal, bool)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert strategy.use_sell_signal
|
||||
assert isinstance(strategy.use_sell_signal, bool)
|
||||
# must be inserted to configuration
|
||||
assert 'use_sell_signal' in default_conf['ask_strategy']
|
||||
assert default_conf['ask_strategy']['use_sell_signal']
|
||||
@@ -278,10 +278,10 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
|
||||
'use_sell_signal': False,
|
||||
},
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert not resolver.strategy.use_sell_signal
|
||||
assert isinstance(resolver.strategy.use_sell_signal, bool)
|
||||
assert not strategy.use_sell_signal
|
||||
assert isinstance(strategy.use_sell_signal, bool)
|
||||
assert log_has("Override strategy 'use_sell_signal' with value in config file: False.", caplog)
|
||||
|
||||
|
||||
@@ -290,9 +290,9 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
default_conf.update({
|
||||
'strategy': 'DefaultStrategy',
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
assert not resolver.strategy.sell_profit_only
|
||||
assert isinstance(resolver.strategy.sell_profit_only, bool)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
assert not strategy.sell_profit_only
|
||||
assert isinstance(strategy.sell_profit_only, bool)
|
||||
# must be inserted to configuration
|
||||
assert 'sell_profit_only' in default_conf['ask_strategy']
|
||||
assert not default_conf['ask_strategy']['sell_profit_only']
|
||||
@@ -303,10 +303,10 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
|
||||
'sell_profit_only': True,
|
||||
},
|
||||
})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
|
||||
assert resolver.strategy.sell_profit_only
|
||||
assert isinstance(resolver.strategy.sell_profit_only, bool)
|
||||
assert strategy.sell_profit_only
|
||||
assert isinstance(strategy.sell_profit_only, bool)
|
||||
assert log_has("Override strategy 'sell_profit_only' with value in config file: True.", caplog)
|
||||
|
||||
|
||||
@@ -315,11 +315,11 @@ def test_deprecate_populate_indicators(result, default_conf):
|
||||
default_location = path.join(path.dirname(path.realpath(__file__)))
|
||||
default_conf.update({'strategy': 'TestStrategyLegacy',
|
||||
'strategy_path': default_location})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# Cause all warnings to always be triggered.
|
||||
warnings.simplefilter("always")
|
||||
indicators = resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
indicators = strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
|
||||
assert len(w) == 1
|
||||
assert issubclass(w[-1].category, DeprecationWarning)
|
||||
assert "deprecated - check out the Sample strategy to see the current function headers!" \
|
||||
@@ -328,7 +328,7 @@ def test_deprecate_populate_indicators(result, default_conf):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# Cause all warnings to always be triggered.
|
||||
warnings.simplefilter("always")
|
||||
resolver.strategy.advise_buy(indicators, {'pair': 'ETH/BTC'})
|
||||
strategy.advise_buy(indicators, {'pair': 'ETH/BTC'})
|
||||
assert len(w) == 1
|
||||
assert issubclass(w[-1].category, DeprecationWarning)
|
||||
assert "deprecated - check out the Sample strategy to see the current function headers!" \
|
||||
@@ -337,7 +337,7 @@ def test_deprecate_populate_indicators(result, default_conf):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# Cause all warnings to always be triggered.
|
||||
warnings.simplefilter("always")
|
||||
resolver.strategy.advise_sell(indicators, {'pair': 'ETH_BTC'})
|
||||
strategy.advise_sell(indicators, {'pair': 'ETH_BTC'})
|
||||
assert len(w) == 1
|
||||
assert issubclass(w[-1].category, DeprecationWarning)
|
||||
assert "deprecated - check out the Sample strategy to see the current function headers!" \
|
||||
@@ -349,47 +349,47 @@ def test_call_deprecated_function(result, monkeypatch, default_conf):
|
||||
default_location = path.join(path.dirname(path.realpath(__file__)))
|
||||
default_conf.update({'strategy': 'TestStrategyLegacy',
|
||||
'strategy_path': default_location})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
|
||||
# Make sure we are using a legacy function
|
||||
assert resolver.strategy._populate_fun_len == 2
|
||||
assert resolver.strategy._buy_fun_len == 2
|
||||
assert resolver.strategy._sell_fun_len == 2
|
||||
assert resolver.strategy.INTERFACE_VERSION == 1
|
||||
assert strategy._populate_fun_len == 2
|
||||
assert strategy._buy_fun_len == 2
|
||||
assert strategy._sell_fun_len == 2
|
||||
assert strategy.INTERFACE_VERSION == 1
|
||||
|
||||
indicator_df = resolver.strategy.advise_indicators(result, metadata=metadata)
|
||||
indicator_df = strategy.advise_indicators(result, metadata=metadata)
|
||||
assert isinstance(indicator_df, DataFrame)
|
||||
assert 'adx' in indicator_df.columns
|
||||
|
||||
buydf = resolver.strategy.advise_buy(result, metadata=metadata)
|
||||
buydf = strategy.advise_buy(result, metadata=metadata)
|
||||
assert isinstance(buydf, DataFrame)
|
||||
assert 'buy' in buydf.columns
|
||||
|
||||
selldf = resolver.strategy.advise_sell(result, metadata=metadata)
|
||||
selldf = strategy.advise_sell(result, metadata=metadata)
|
||||
assert isinstance(selldf, DataFrame)
|
||||
assert 'sell' in selldf
|
||||
|
||||
|
||||
def test_strategy_interface_versioning(result, monkeypatch, default_conf):
|
||||
default_conf.update({'strategy': 'DefaultStrategy'})
|
||||
resolver = StrategyResolver(default_conf)
|
||||
strategy = StrategyResolver.load_strategy(default_conf)
|
||||
metadata = {'pair': 'ETH/BTC'}
|
||||
|
||||
# Make sure we are using a legacy function
|
||||
assert resolver.strategy._populate_fun_len == 3
|
||||
assert resolver.strategy._buy_fun_len == 3
|
||||
assert resolver.strategy._sell_fun_len == 3
|
||||
assert resolver.strategy.INTERFACE_VERSION == 2
|
||||
assert strategy._populate_fun_len == 3
|
||||
assert strategy._buy_fun_len == 3
|
||||
assert strategy._sell_fun_len == 3
|
||||
assert strategy.INTERFACE_VERSION == 2
|
||||
|
||||
indicator_df = resolver.strategy.advise_indicators(result, metadata=metadata)
|
||||
indicator_df = strategy.advise_indicators(result, metadata=metadata)
|
||||
assert isinstance(indicator_df, DataFrame)
|
||||
assert 'adx' in indicator_df.columns
|
||||
|
||||
buydf = resolver.strategy.advise_buy(result, metadata=metadata)
|
||||
buydf = strategy.advise_buy(result, metadata=metadata)
|
||||
assert isinstance(buydf, DataFrame)
|
||||
assert 'buy' in buydf.columns
|
||||
|
||||
selldf = resolver.strategy.advise_sell(result, metadata=metadata)
|
||||
selldf = strategy.advise_sell(result, metadata=metadata)
|
||||
assert isinstance(selldf, DataFrame)
|
||||
assert 'sell' in selldf
|
||||
|
@@ -100,7 +100,7 @@ def test_init_dryrun_db(default_conf, mocker):
|
||||
|
||||
init(default_conf['db_url'], default_conf['dry_run'])
|
||||
assert create_engine_mock.call_count == 1
|
||||
assert create_engine_mock.mock_calls[0][1][0] == 'sqlite://'
|
||||
assert create_engine_mock.mock_calls[0][1][0] == 'sqlite:///tradesv3.dryrun.sqlite'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
|
Reference in New Issue
Block a user