fix tests
This commit is contained in:
parent
4dcd15da1d
commit
523a9a603c
@ -780,10 +780,11 @@ def buy_order_fee():
|
|||||||
'fee': None
|
'fee': None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def edge_conf(default_conf):
|
def edge_conf(default_conf):
|
||||||
default_conf['edge'] = {
|
default_conf['edge'] = {
|
||||||
"enabled": False,
|
"enabled": True,
|
||||||
"process_throttle_secs": 1800,
|
"process_throttle_secs": 1800,
|
||||||
"calculate_since_number_of_days": 14,
|
"calculate_since_number_of_days": 14,
|
||||||
"total_capital_in_stake_currency": 0.5,
|
"total_capital_in_stake_currency": 0.5,
|
||||||
|
@ -31,7 +31,7 @@ class BTContainer(NamedTuple):
|
|||||||
|
|
||||||
def _get_frame_time_from_offset(offset):
|
def _get_frame_time_from_offset(offset):
|
||||||
return ticker_start_time.shift(
|
return ticker_start_time.shift(
|
||||||
minutes=(offset * ticker_interval_in_minute)).datetime
|
minutes=(offset * ticker_interval_in_minute)).datetime.replace(tzinfo=None)
|
||||||
|
|
||||||
|
|
||||||
def _build_backtest_dataframe(ticker_with_signals):
|
def _build_backtest_dataframe(ticker_with_signals):
|
||||||
|
@ -246,12 +246,11 @@ def test_get_trade_stake_amount_unlimited_amount(default_conf,
|
|||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
|
|
||||||
def test_edge_overrides_stake_amount(mocker, default_conf) -> None:
|
def test_edge_overrides_stake_amount(mocker, edge_conf) -> None:
|
||||||
default_conf['edge']['enabled'] = True
|
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
patch_edge(mocker)
|
patch_edge(mocker)
|
||||||
freqtrade = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(edge_conf)
|
||||||
|
|
||||||
# strategy stoploss should be ignored
|
# strategy stoploss should be ignored
|
||||||
freqtrade.strategy.stoploss = -0.05
|
freqtrade.strategy.stoploss = -0.05
|
||||||
@ -261,14 +260,8 @@ def test_edge_overrides_stake_amount(mocker, default_conf) -> None:
|
|||||||
assert freqtrade._get_trade_stake_amount('LTC/BTC') == 0.02381
|
assert freqtrade._get_trade_stake_amount('LTC/BTC') == 0.02381
|
||||||
|
|
||||||
|
|
||||||
def test_edge_overrides_stoploss(
|
def test_edge_overrides_stoploss(limit_buy_order, fee, markets, caplog, mocker, edge_conf) -> None:
|
||||||
limit_buy_order,
|
|
||||||
fee,
|
|
||||||
markets,
|
|
||||||
caplog,
|
|
||||||
mocker,
|
|
||||||
default_conf) -> None:
|
|
||||||
default_conf['edge']['enabled'] = True
|
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
patch_edge(mocker)
|
patch_edge(mocker)
|
||||||
@ -292,7 +285,8 @@ def test_edge_overrides_stoploss(
|
|||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
# Create a trade with "limit_buy_order" price
|
# Create a trade with "limit_buy_order" price
|
||||||
freqtrade = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(edge_conf)
|
||||||
|
freqtrade.active_pair_whitelist = ['NEO/BTC']
|
||||||
patch_get_signal(freqtrade)
|
patch_get_signal(freqtrade)
|
||||||
freqtrade.strategy.min_roi_reached = lambda trade, current_profit, current_time: False
|
freqtrade.strategy.min_roi_reached = lambda trade, current_profit, current_time: False
|
||||||
freqtrade.create_trade()
|
freqtrade.create_trade()
|
||||||
@ -302,14 +296,12 @@ def test_edge_overrides_stoploss(
|
|||||||
|
|
||||||
# stoploss shoud be hit
|
# stoploss shoud be hit
|
||||||
assert freqtrade.handle_trade(trade) is True
|
assert freqtrade.handle_trade(trade) is True
|
||||||
|
|
||||||
assert log_has('executed sell, reason: SellType.STOP_LOSS', caplog.record_tuples)
|
assert log_has('executed sell, reason: SellType.STOP_LOSS', caplog.record_tuples)
|
||||||
assert trade.sell_reason == SellType.STOP_LOSS.value
|
assert trade.sell_reason == SellType.STOP_LOSS.value
|
||||||
|
|
||||||
|
|
||||||
def test_edge_should_ignore_strategy_stoploss(limit_buy_order, fee, markets,
|
def test_edge_should_ignore_strategy_stoploss(limit_buy_order, fee, markets,
|
||||||
mocker, default_conf) -> None:
|
mocker, edge_conf) -> None:
|
||||||
default_conf['edge']['enabled'] = True
|
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
patch_edge(mocker)
|
patch_edge(mocker)
|
||||||
@ -333,7 +325,8 @@ def test_edge_should_ignore_strategy_stoploss(limit_buy_order, fee, markets,
|
|||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
# Create a trade with "limit_buy_order" price
|
# Create a trade with "limit_buy_order" price
|
||||||
freqtrade = FreqtradeBot(default_conf)
|
freqtrade = FreqtradeBot(edge_conf)
|
||||||
|
freqtrade.active_pair_whitelist = ['NEO/BTC']
|
||||||
patch_get_signal(freqtrade)
|
patch_get_signal(freqtrade)
|
||||||
freqtrade.strategy.min_roi_reached = lambda trade, current_profit, current_time: False
|
freqtrade.strategy.min_roi_reached = lambda trade, current_profit, current_time: False
|
||||||
freqtrade.create_trade()
|
freqtrade.create_trade()
|
||||||
@ -341,7 +334,7 @@ def test_edge_should_ignore_strategy_stoploss(limit_buy_order, fee, markets,
|
|||||||
trade.update(limit_buy_order)
|
trade.update(limit_buy_order)
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
# stoploss shoud be hit
|
# stoploss shoud not be hit
|
||||||
assert freqtrade.handle_trade(trade) is False
|
assert freqtrade.handle_trade(trade) is False
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user