Test "get-signal"

This commit is contained in:
Matthias 2021-10-31 10:51:56 +01:00
parent dffe76f109
commit 6b90b4a144
3 changed files with 17 additions and 4 deletions

View File

@ -420,7 +420,7 @@ class FreqtradeBot(LoggingMixin):
return False
# running get_signal on historical data fetched
(buy, sell, buy_tag, exit_tag) = self.strategy.get_signal(
(buy, sell, buy_tag, _) = self.strategy.get_signal(
pair,
self.strategy.timeframe,
analyzed_df
@ -707,7 +707,7 @@ class FreqtradeBot(LoggingMixin):
analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(trade.pair,
self.strategy.timeframe)
(buy, sell, buy_tag, exit_tag) = self.strategy.get_signal(
(buy, sell, _, exit_tag) = self.strategy.get_signal(
trade.pair,
self.strategy.timeframe,
analyzed_df

View File

@ -30,7 +30,7 @@ _STRATEGY = StrategyTestV2(config={})
_STRATEGY.dp = DataProvider({}, None, None)
def test_returns_latest_signal(mocker, default_conf, ohlcv_history):
def test_returns_latest_signal(ohlcv_history):
ohlcv_history.loc[1, 'date'] = arrow.utcnow()
# Take a copy to correctly modify the call
mocked_history = ohlcv_history.copy()
@ -60,6 +60,18 @@ def test_returns_latest_signal(mocker, default_conf, ohlcv_history):
'buy_signal_01',
None)
mocked_history.loc[1, 'buy_tag'] = None
mocked_history.loc[1, 'exit_tag'] = 'sell_signal_01'
assert _STRATEGY.get_signal(
'ETH/BTC',
'5m',
mocked_history) == (
True,
False,
None,
'sell_signal_01')
def test_analyze_pair_empty(default_conf, mocker, caplog, ohlcv_history):
mocker.patch.object(_STRATEGY.dp, 'ohlcv', return_value=ohlcv_history)

View File

@ -1808,7 +1808,7 @@ def test_handle_trade(default_conf_usdt, limit_buy_order_usdt, limit_sell_order_
assert trade.is_open is True
freqtrade.wallets.update()
patch_get_signal(freqtrade, value=(False, True, None, None))
patch_get_signal(freqtrade, value=(False, True, None, 'sell_signal1'))
assert freqtrade.handle_trade(trade) is True
assert trade.open_order_id == limit_sell_order_usdt['id']
@ -1819,6 +1819,7 @@ def test_handle_trade(default_conf_usdt, limit_buy_order_usdt, limit_sell_order_
assert trade.close_profit == 0.09451372
assert trade.calc_profit() == 5.685
assert trade.close_date is not None
assert trade.sell_reason == 'sell_signal1'
def test_handle_overlapping_signals(default_conf_usdt, ticker_usdt, limit_buy_order_usdt_open,