Use Kelly allocation for Torch position scaling
This commit is contained in:
+28
-1
@@ -60,7 +60,7 @@ def test_paper_broker_uses_signal_notional_and_pair_exposure(make_settings, tmp_
|
||||
max_symbol_exposure_usdt=6,
|
||||
max_total_exposure_usdt=50,
|
||||
max_open_positions=20,
|
||||
max_positions_per_symbol=1,
|
||||
max_positions_per_symbol=6,
|
||||
max_entries_per_minute=0,
|
||||
)
|
||||
storage = Storage(settings.database_path)
|
||||
@@ -218,6 +218,33 @@ def test_torch_forecast_broker_allows_dynamic_entries_until_total_limit(make_set
|
||||
assert len(broker.open_positions()) == 3
|
||||
|
||||
|
||||
def test_torch_forecast_broker_respects_configured_symbol_position_limit(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(
|
||||
tmp_path,
|
||||
strategy_mode="torch_forecast",
|
||||
min_position_usdt=1,
|
||||
max_position_usdt=20,
|
||||
max_symbol_exposure_usdt=20,
|
||||
max_total_exposure_usdt=80,
|
||||
max_open_positions=20,
|
||||
max_positions_per_symbol=2,
|
||||
max_entries_per_minute=0,
|
||||
)
|
||||
storage = Storage(settings.database_path)
|
||||
broker = PaperBroker(settings, storage)
|
||||
ticker = Ticker("BTCUSDT", 100, 99.9, 100.1, 10_000_000, 100, 0)
|
||||
instrument = Instrument("BTCUSDT", "BTC", "USDT", "Trading", 0.01, 0.000001, 0.000001, 1)
|
||||
|
||||
first = broker.buy(Signal("BTCUSDT", "BUY", 0.8, "first", {"position_notional_usdt": 2}), ticker, instrument, {"BTCUSDT": 100})
|
||||
second = broker.buy(Signal("BTCUSDT", "BUY", 0.8, "second", {"position_notional_usdt": 2}), ticker, instrument, {"BTCUSDT": 100})
|
||||
third = broker.buy(Signal("BTCUSDT", "BUY", 0.8, "third", {"position_notional_usdt": 2}), ticker, instrument, {"BTCUSDT": 100})
|
||||
|
||||
assert first is not None
|
||||
assert second is not None
|
||||
assert third is None
|
||||
assert len(broker.open_positions()) == 2
|
||||
|
||||
|
||||
def test_trend_macd_closes_old_paper_positions_outside_symbol_universe(make_settings, tmp_path) -> None:
|
||||
settings = make_settings(
|
||||
tmp_path,
|
||||
|
||||
Reference in New Issue
Block a user