Avoid fee-negative ATR exits
This commit is contained in:
@@ -917,6 +917,43 @@ def test_torch_forecast_holds_fee_churn_exit_after_min_hold(make_settings, tmp_p
|
||||
assert signal.diagnostics["forecast_exit_blocked_by_cost"] is True
|
||||
|
||||
|
||||
def test_torch_forecast_holds_atr_trailing_exit_that_does_not_cover_fees(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(tmp_path, strategy_mode="torch_forecast", min_hold_seconds=60)
|
||||
strategy = SpotStrategy(settings)
|
||||
candles = _trend_entry_candles(close=100.2)
|
||||
candles[-1].atr_14 = 0.8
|
||||
position = Position(
|
||||
1,
|
||||
"MNTUSDT",
|
||||
1,
|
||||
100,
|
||||
100,
|
||||
0.1,
|
||||
96,
|
||||
120,
|
||||
102,
|
||||
opened_at=utc_now() - timedelta(seconds=600),
|
||||
)
|
||||
ticker = Ticker("MNTUSDT", 100.2, 100.19, 100.21, 10_000_000, 1000, 1.0)
|
||||
|
||||
signal = strategy.exit_signal(
|
||||
position,
|
||||
candles,
|
||||
ticker,
|
||||
forecast={
|
||||
"usable": True,
|
||||
"model": "torch_lstm",
|
||||
"expected_return_percent": 0.4,
|
||||
"probability_up": 0.58,
|
||||
"skill": 0.18,
|
||||
"block_entry": False,
|
||||
},
|
||||
)
|
||||
|
||||
assert signal.action == "HOLD"
|
||||
assert signal.diagnostics["atr_exit_blocked_by_cost"] is True
|
||||
|
||||
|
||||
def test_torch_forecast_rebound_fallback_holds_without_model(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(tmp_path, strategy_mode="torch_forecast", min_hold_seconds=180)
|
||||
strategy = SpotStrategy(settings)
|
||||
|
||||
Reference in New Issue
Block a user