Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
]
6 changes: 5 additions & 1 deletion runtime_config_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
28 changes: 28 additions & 0 deletions tests/test_runtime_config_support.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import json

import pytest

from runtime_config_support import (
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.