mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-17 03:30:33 +00:00
test: extend backtest-detail tests for exit_adjust
This commit is contained in:
@@ -45,6 +45,7 @@ class BTContainer(NamedTuple):
|
||||
leverage: float = 1.0
|
||||
timeout: int | None = None
|
||||
adjust_entry_price: float | None = None
|
||||
adjust_exit_price: float | None = None
|
||||
adjust_trade_position: list[float] | None = None
|
||||
|
||||
|
||||
|
||||
@@ -1217,6 +1217,26 @@ tc57 = BTContainer(
|
||||
],
|
||||
)
|
||||
|
||||
# Test 58: Custom-exit-price short - below all candles
|
||||
tc58 = BTContainer(
|
||||
data=[
|
||||
# D O H L C V EL XL ES Xs BT
|
||||
[0, 5000, 5050, 4950, 5000, 6172, 0, 0, 1, 0],
|
||||
[1, 5000, 5200, 4951, 5000, 6172, 0, 0, 0, 0], # enter trade (signal on last candle)
|
||||
[2, 4900, 5250, 4900, 5100, 6172, 0, 0, 0, 1], # Exit - delayed
|
||||
[3, 5100, 5100, 4650, 4750, 6172, 0, 0, 0, 0], #
|
||||
[4, 4750, 5100, 4350, 4750, 6172, 0, 0, 0, 0],
|
||||
],
|
||||
stop_loss=-0.10,
|
||||
roi={"0": 1.00},
|
||||
profit_perc=-0.01,
|
||||
use_exit_signal=True,
|
||||
timeout=1000,
|
||||
custom_exit_price=4300,
|
||||
adjust_exit_price=5050,
|
||||
trades=[BTrade(exit_reason=ExitType.EXIT_SIGNAL, open_tick=1, close_tick=4, is_short=True)],
|
||||
)
|
||||
|
||||
|
||||
TESTS = [
|
||||
tc0,
|
||||
@@ -1277,6 +1297,7 @@ TESTS = [
|
||||
tc55,
|
||||
tc56,
|
||||
tc57,
|
||||
tc58,
|
||||
]
|
||||
|
||||
|
||||
@@ -1330,6 +1351,8 @@ def test_backtest_results(default_conf, mocker, caplog, data: BTContainer) -> No
|
||||
)
|
||||
if data.adjust_entry_price:
|
||||
backtesting.strategy.adjust_entry_price = MagicMock(return_value=data.adjust_entry_price)
|
||||
if data.adjust_exit_price:
|
||||
backtesting.strategy.adjust_exit_price = MagicMock(return_value=data.adjust_exit_price)
|
||||
|
||||
backtesting.strategy.use_custom_stoploss = data.use_custom_stoploss
|
||||
backtesting.strategy.leverage = lambda **kwargs: data.leverage
|
||||
|
||||
Reference in New Issue
Block a user