diff --git a/pyproject.toml b/pyproject.toml index fd52ba0..a7a20bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "pytest", "pytz", "requests", - "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@2d572658df6e1e82ce822e782e4a717beda4cf83", + "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@d420441d0e96a020e333ec678ee88f5d964bbb43", "us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@26c9b908c486ca60123414eda42cd509c0f17c62", ] license = "MIT" @@ -82,5 +82,5 @@ show_missing = true [tool.uv] override-dependencies = [ - "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@2d572658df6e1e82ce822e782e4a717beda4cf83", + "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@d420441d0e96a020e333ec678ee88f5d964bbb43", ] diff --git a/runtime_config_support.py b/runtime_config_support.py index b49e9ce..0a94279 100644 --- a/runtime_config_support.py +++ b/runtime_config_support.py @@ -27,6 +27,7 @@ build_runtime_target, resolve_runtime_target_from_env, ) +from quant_platform_kit.common.live_continuity import runtime_target_permits_standard_execution from strategy_registry import ( FIRSTRADE_PLATFORM, resolve_strategy_definition, @@ -189,7 +190,10 @@ def load_platform_runtime_settings( tg_token=_get_credential("firstrade-telegram-token", "TELEGRAM_TOKEN"), tg_chat_id=os.getenv("QSL_GLOBAL_TELEGRAM_CHAT_ID") or os.getenv("GLOBAL_TELEGRAM_CHAT_ID"), dry_run_only=dry_run_only, - runtime_target_enabled=_runtime_target_enabled_env(), + runtime_target_enabled=( + _runtime_target_enabled_env() + and runtime_target_permits_standard_execution(runtime_target) + ), cash_only_execution=resolve_cash_only_execution_env( os.environ, platform_env_prefix="FIRSTRADE", diff --git a/tests/test_runtime_config_support.py b/tests/test_runtime_config_support.py index 4aad109..49e477f 100644 --- a/tests/test_runtime_config_support.py +++ b/tests/test_runtime_config_support.py @@ -1,5 +1,7 @@ from __future__ import annotations +import json + import pytest from runtime_config_support import ( @@ -174,6 +176,32 @@ def test_runtime_target_enabled_loads_from_env(monkeypatch): assert settings.runtime_target_enabled is False +def test_live_continuity_paused_state_disables_standard_execution(monkeypatch): + runtime_target = { + "platform_id": "firstrade", + "strategy_profile": "ibit_smart_dca", + "dry_run_only": False, + "execution_mode": "live", + "live_continuity": { + "state": "PAUSED", + "baseline_kind": "legacy_authorized", + "baseline_id": "ibit-firstrade-lkg-20260830", + "baseline_target_sha256": "a" * 64, + "captured_at": "2026-08-30", + }, + } + from quant_platform_kit.common.live_continuity import runtime_target_fingerprint + + runtime_target["live_continuity"]["baseline_target_sha256"] = runtime_target_fingerprint(runtime_target) + monkeypatch.setenv("RUNTIME_TARGET_JSON", json.dumps(runtime_target)) + monkeypatch.setenv("FIRSTRADE_DRY_RUN_ONLY", "false") + monkeypatch.setenv("RUNTIME_TARGET_ENABLED", "true") + + settings = load_platform_runtime_settings(project_id_resolver=lambda: "project-1") + + assert settings.runtime_target_enabled is False + + def test_invalid_runtime_target_enabled_is_rejected(monkeypatch): monkeypatch.setenv("RUNTIME_TARGET_JSON", _target_json()) monkeypatch.setenv("RUNTIME_TARGET_ENABLED", "maybe") diff --git a/uv.lock b/uv.lock index 2303203..7a8cd2c 100644 --- a/uv.lock +++ b/uv.lock @@ -17,7 +17,7 @@ resolution-markers = [ ] [manifest] -overrides = [{ name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=2d572658df6e1e82ce822e782e4a717beda4cf83" }] +overrides = [{ name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=d420441d0e96a020e333ec678ee88f5d964bbb43" }] [[package]] name = "blinker" @@ -446,7 +446,7 @@ requires-dist = [ { name = "pytest", marker = "extra == 'test'" }, { name = "pytest-cov", marker = "extra == 'test'" }, { name = "pytz" }, - { name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=2d572658df6e1e82ce822e782e4a717beda4cf83" }, + { name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=d420441d0e96a020e333ec678ee88f5d964bbb43" }, { name = "requests" }, { name = "ruff", marker = "extra == 'test'" }, { name = "us-equity-strategies", git = "https://github.com/QuantStrategyLab/UsEquityStrategies.git?rev=26c9b908c486ca60123414eda42cd509c0f17c62" }, @@ -1102,7 +1102,7 @@ wheels = [ [[package]] name = "quant-platform-kit" version = "0.10.0" -source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=2d572658df6e1e82ce822e782e4a717beda4cf83#2d572658df6e1e82ce822e782e4a717beda4cf83" } +source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=d420441d0e96a020e333ec678ee88f5d964bbb43#d420441d0e96a020e333ec678ee88f5d964bbb43" } [[package]] name = "requests"