diff --git a/pyproject.toml b/pyproject.toml index 25ca86e..ffddefe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ requires-python = ">=3.11" dependencies = [ "pandas>=2.0", "pytz>=2024.1", - "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@68c51590da8a5097b7de6d75b4ccb6a175318b48", + "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@a90937621a7a05c9f72d0ca8a29be3fcb18a327c", ] [tool.setuptools] diff --git a/qsl.toml b/qsl.toml index 039a704..5bdb5f7 100644 --- a/qsl.toml +++ b/qsl.toml @@ -6,5 +6,5 @@ bundle = "2026.09.1" requires = [ "pandas>=2.0", "pytz>=2024.1", - "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@68c51590da8a5097b7de6d75b4ccb6a175318b48", + "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@a90937621a7a05c9f72d0ca8a29be3fcb18a327c", ] diff --git a/src/us_equity_strategies/entrypoints/_common.py b/src/us_equity_strategies/entrypoints/_common.py index 0fc3b8b..52eec82 100644 --- a/src/us_equity_strategies/entrypoints/_common.py +++ b/src/us_equity_strategies/entrypoints/_common.py @@ -107,6 +107,12 @@ def apply_risk_gate( } if "runtime_risk_limits" in capabilities: qpk_kwargs["runtime_risk_limits"] = capabilities["runtime_risk_limits"] + if "small_account_hold_policy" in capabilities: + qpk_kwargs["small_account_hold_policy"] = capabilities["small_account_hold_policy"] + if "current_portfolio_weights" in capabilities: + qpk_kwargs["current_portfolio_weights"] = capabilities["current_portfolio_weights"] + if "cash_only_execution" in capabilities: + qpk_kwargs["cash_only_execution"] = capabilities["cash_only_execution"] return _qpk_apply_risk_gate( decision, **qpk_kwargs, diff --git a/tests/test_entrypoint_risk_gate.py b/tests/test_entrypoint_risk_gate.py index d20395c..a8a402c 100644 --- a/tests/test_entrypoint_risk_gate.py +++ b/tests/test_entrypoint_risk_gate.py @@ -673,6 +673,39 @@ def _gate(decision, **kwargs): assert captured["enforce_value_target_exposure"] is True +def test_apply_risk_gate_forwards_small_account_hold_capabilities( + monkeypatch, +) -> None: + captured: dict[str, object] = {} + + def _gate(decision, **kwargs): + captured.update(kwargs) + return decision + + hold_policy = object() + ctx = StrategyContext( + as_of=datetime(2026, 7, 9, tzinfo=timezone.utc), + portfolio=None, + market_data={}, + state={}, + runtime_config={}, + capabilities={ + "small_account_hold_policy": hold_policy, + "cash_only_execution": True, + "current_portfolio_weights": {"SOXL": 0.9}, + }, + ) + monkeypatch.setattr(common, "_qpk_apply_risk_gate", _gate) + decision = StrategyDecision( + positions=(PositionTarget(symbol="SOXL", target_weight=0.9),) + ) + + assert apply_risk_gate(decision, ctx=ctx) is decision + assert captured["small_account_hold_policy"] is hold_policy + assert captured["cash_only_execution"] is True + assert captured["current_portfolio_weights"] == {"SOXL": 0.9} + + def test_apply_risk_gate_omits_runtime_risk_limits_kwarg_when_capability_absent( monkeypatch, ) -> None: diff --git a/tests/test_qsl_compat_metadata.py b/tests/test_qsl_compat_metadata.py index 825a551..6fbafd3 100644 --- a/tests/test_qsl_compat_metadata.py +++ b/tests/test_qsl_compat_metadata.py @@ -3,7 +3,7 @@ ROOT = Path(__file__).resolve().parents[1] -QPK_REVISION = "68c51590da8a5097b7de6d75b4ccb6a175318b48" +QPK_REVISION = "a90937621a7a05c9f72d0ca8a29be3fcb18a327c" QPK_URL = ( "quant-platform-kit @ git+https://github.com/QuantStrategyLab/" f"QuantPlatformKit.git@{QPK_REVISION}" diff --git a/uv.lock b/uv.lock index 2778f91..de2b3a7 100644 --- a/uv.lock +++ b/uv.lock @@ -241,7 +241,7 @@ wheels = [ [[package]] name = "quant-platform-kit" version = "1.0.0" -source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=68c51590da8a5097b7de6d75b4ccb6a175318b48#68c51590da8a5097b7de6d75b4ccb6a175318b48" } +source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=a90937621a7a05c9f72d0ca8a29be3fcb18a327c#a90937621a7a05c9f72d0ca8a29be3fcb18a327c" } [[package]] name = "six" @@ -275,5 +275,5 @@ dependencies = [ requires-dist = [ { name = "pandas", specifier = ">=2.0" }, { name = "pytz", specifier = ">=2024.1" }, - { name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=68c51590da8a5097b7de6d75b4ccb6a175318b48" }, + { name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=a90937621a7a05c9f72d0ca8a29be3fcb18a327c" }, ]