Add Torch probe entries and Pi artifact sync
This commit is contained in:
@@ -284,6 +284,80 @@ def test_torch_forecast_blocks_without_valid_torch_model(make_settings, tmp_path
|
||||
assert signal.diagnostics["checks"]["torch_model_ok"] is False
|
||||
|
||||
|
||||
def test_torch_forecast_probe_buys_on_positive_high_probability(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(
|
||||
tmp_path,
|
||||
strategy_mode="torch_forecast",
|
||||
time_series_min_edge_percent=0.10,
|
||||
time_series_min_probability_up=0.52,
|
||||
time_series_probe_enabled=True,
|
||||
time_series_probe_min_edge_percent=0.02,
|
||||
time_series_probe_min_probability_up=0.55,
|
||||
time_series_probe_size_multiplier=0.40,
|
||||
max_position_usdt=25,
|
||||
stop_loss_percent=0.04,
|
||||
risk_per_trade_percent=0.01,
|
||||
)
|
||||
strategy = SpotStrategy(settings)
|
||||
ticker = Ticker("SOLUSDT", 65, 64.99, 65.01, 10_000_000, 1000, 1.0)
|
||||
|
||||
signal = strategy.entry_signal(
|
||||
"SOLUSDT",
|
||||
[],
|
||||
ticker,
|
||||
open_positions_for_symbol=0,
|
||||
forecast={
|
||||
"usable": True,
|
||||
"model": "torch_gru",
|
||||
"expected_return_percent": 0.04,
|
||||
"probability_up": 0.57,
|
||||
"skill": 0.05,
|
||||
"block_entry": False,
|
||||
},
|
||||
account={"equity": 100.0},
|
||||
)
|
||||
|
||||
assert signal.action == "BUY"
|
||||
assert signal.diagnostics["edge_mode"] == "probe"
|
||||
assert signal.diagnostics["checks"]["expected_edge_ok"] is True
|
||||
assert signal.diagnostics["position_sizing"]["edge_mode"] == "probe"
|
||||
assert settings.min_position_usdt <= signal.diagnostics["position_notional_usdt"] < settings.max_position_usdt
|
||||
|
||||
|
||||
def test_torch_forecast_probe_blocks_negative_expected_return(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(
|
||||
tmp_path,
|
||||
strategy_mode="torch_forecast",
|
||||
time_series_min_edge_percent=0.10,
|
||||
time_series_min_probability_up=0.52,
|
||||
time_series_probe_enabled=True,
|
||||
time_series_probe_min_edge_percent=0.02,
|
||||
time_series_probe_min_probability_up=0.55,
|
||||
)
|
||||
strategy = SpotStrategy(settings)
|
||||
ticker = Ticker("BTCUSDT", 59_000, 58_999, 59_001, 10_000_000, 1000, 1.0)
|
||||
|
||||
signal = strategy.entry_signal(
|
||||
"BTCUSDT",
|
||||
[],
|
||||
ticker,
|
||||
open_positions_for_symbol=0,
|
||||
forecast={
|
||||
"usable": True,
|
||||
"model": "torch_gru",
|
||||
"expected_return_percent": -0.03,
|
||||
"probability_up": 0.60,
|
||||
"skill": 0.16,
|
||||
"block_entry": False,
|
||||
},
|
||||
account={"equity": 100.0},
|
||||
)
|
||||
|
||||
assert signal.action == "HOLD"
|
||||
assert signal.diagnostics["edge_mode"] == "blocked"
|
||||
assert signal.diagnostics["checks"]["expected_edge_ok"] is False
|
||||
|
||||
|
||||
def test_torch_forecast_exits_when_forecast_turns_negative(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(tmp_path, strategy_mode="torch_forecast", stop_loss_percent=0.04)
|
||||
strategy = SpotStrategy(settings)
|
||||
|
||||
Reference in New Issue
Block a user