Allow exchange-minimum Kelly layers
This commit is contained in:
@@ -394,6 +394,60 @@ def test_torch_forecast_kelly_buys_only_remaining_symbol_allocation(make_setting
|
||||
assert filled.diagnostics["checks"]["risk_size_ok"] is False
|
||||
|
||||
|
||||
def test_torch_forecast_kelly_allows_next_exchange_minimum_layer(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(
|
||||
tmp_path,
|
||||
strategy_mode="torch_forecast",
|
||||
min_position_usdt=1,
|
||||
max_position_usdt=8,
|
||||
max_symbol_exposure_usdt=25,
|
||||
max_total_exposure_usdt=75,
|
||||
max_positions_per_symbol=6,
|
||||
stop_loss_percent=0.04,
|
||||
take_profit_percent=0.035,
|
||||
kelly_sizing_enabled=True,
|
||||
kelly_fraction=0.25,
|
||||
kelly_max_fraction=0.20,
|
||||
time_series_min_edge_percent=0.10,
|
||||
time_series_min_probability_up=0.47,
|
||||
time_series_min_confidence=0.4,
|
||||
)
|
||||
strategy = SpotStrategy(settings)
|
||||
ticker = Ticker("HYPEUSDT", 63.14, 63.13, 63.15, 10_000_000, 1000, 1.0)
|
||||
|
||||
signal = strategy.entry_signal(
|
||||
"HYPEUSDT",
|
||||
[],
|
||||
ticker,
|
||||
open_positions_for_symbol=1,
|
||||
forecast={
|
||||
"usable": True,
|
||||
"model": "torch_gru",
|
||||
"expected_return_percent": 0.2115,
|
||||
"probability_up": 0.5163,
|
||||
"skill": 0.0156,
|
||||
"block_entry": False,
|
||||
},
|
||||
account={
|
||||
"equity": 98.6,
|
||||
"cash": 88.54,
|
||||
"exposure": 10.07,
|
||||
"symbol": "HYPEUSDT",
|
||||
"symbol_exposure_usdt": 5.05,
|
||||
"open_positions_for_symbol": 1,
|
||||
"exchange_min_entry_usdt": 5.07,
|
||||
},
|
||||
)
|
||||
|
||||
sizing = signal.diagnostics["position_sizing"]
|
||||
assert signal.action == "BUY"
|
||||
assert signal.diagnostics["checks"]["risk_size_ok"] is True
|
||||
assert sizing["kelly_target_notional_usdt"] < sizing["kelly_open_symbol_exposure_usdt"]
|
||||
assert sizing["kelly_raw_remaining_notional_usdt"] == 0.0
|
||||
assert sizing["kelly_layer_mode"] is True
|
||||
assert signal.diagnostics["position_notional_usdt"] == 5.07
|
||||
|
||||
|
||||
def test_torch_forecast_blocks_failed_quality_gate(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(
|
||||
tmp_path,
|
||||
|
||||
Reference in New Issue
Block a user