Skip to content

Commit 53b4022

Browse files
committed
Initial runtime settings control plane
0 parents  commit 53b4022

10 files changed

Lines changed: 791 additions & 0 deletions

File tree

.github/workflows/validate.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Validate
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
validate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: "3.12"
15+
- name: Validate runtime targets
16+
run: python3 scripts/runtime_settings.py validate
17+
- name: Run unit tests
18+
run: python3 -m unittest discover -s tests -v
19+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__pycache__/
2+
.pytest_cache/
3+
.ruff_cache/
4+
.venv/
5+

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# QuantRuntimeSettings
2+
3+
Declarative runtime settings for QuantStrategyLab live deployments.
4+
5+
This repository is the control plane for "which platform runs which strategy". It does not contain strategy logic, broker execution code, credentials, or secrets.
6+
7+
## Current Targets
8+
9+
| Target | Repository | Scope | Strategy | Execution |
10+
| --- | --- | --- | --- | --- |
11+
| `schwab/live` | `QuantStrategyLab/CharlesSchwabPlatform` | repository variables | `soxl_soxx_trend_income` | live |
12+
| `longbridge/sg` | `QuantStrategyLab/LongBridgePlatform` | `longbridge-sg` environment variables | `soxl_soxx_trend_income` | live |
13+
| `ibkr/default` | `QuantStrategyLab/InteractiveBrokersPlatform` | repository variables | `mega_cap_leader_rotation_top50_balanced` | live |
14+
15+
## Boundaries
16+
17+
- `UsEquityStrategies` owns allocation logic, strategy defaults, and risk rules.
18+
- Platform repositories own broker adapters, runtime input collection, notifications, and execution.
19+
- This repository owns runtime target declarations and emits GitHub variable updates.
20+
- Secret values are intentionally excluded. Use secret names or platform repository secrets when needed.
21+
22+
## Commands
23+
24+
Validate all targets:
25+
26+
```bash
27+
python3 scripts/runtime_settings.py validate
28+
```
29+
30+
Render assignments for a target:
31+
32+
```bash
33+
python3 scripts/runtime_settings.py render targets/schwab/live.json
34+
```
35+
36+
Preview GitHub variable updates:
37+
38+
```bash
39+
python3 scripts/runtime_settings.py apply targets/longbridge/sg.json
40+
```
41+
42+
Apply GitHub variable updates:
43+
44+
```bash
45+
python3 scripts/runtime_settings.py apply --yes targets/longbridge/sg.json
46+
```
47+
48+
`RUNTIME_TARGET_JSON` is canonical. Compatibility variables such as `STRATEGY_PROFILE` are generated from it so they cannot drift independently.
49+
50+
## Architecture
51+
52+
This repo acts as a small bridge between strategy selection and platform deployment:
53+
54+
- A target file declares the desired runtime target.
55+
- The validator checks that required runtime fields and plugin mounts are coherent.
56+
- The renderer converts the declaration into platform-specific GitHub variables.
57+
- Platform repositories keep their existing adapter code and consume the generated variables.
58+

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[project]
2+
name = "quant-runtime-settings"
3+
version = "0.1.0"
4+
description = "Declarative runtime target settings for QuantStrategyLab deployments"
5+
requires-python = ">=3.11"
6+
7+
[tool.ruff]
8+
line-length = 120
9+
target-version = "py311"
10+

schemas/runtime-target.schema.json

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://github.com/QuantStrategyLab/QuantRuntimeSettings/schemas/runtime-target.schema.json",
4+
"title": "Quant runtime target",
5+
"type": "object",
6+
"required": ["target_id", "github", "runtime_target"],
7+
"additionalProperties": false,
8+
"properties": {
9+
"$schema": {
10+
"type": "string"
11+
},
12+
"target_id": {
13+
"type": "string",
14+
"pattern": "^[a-z0-9_-]+/[a-z0-9_-]+$"
15+
},
16+
"description": {
17+
"type": "string"
18+
},
19+
"github": {
20+
"type": "object",
21+
"required": ["repository", "variable_scope"],
22+
"additionalProperties": false,
23+
"properties": {
24+
"repository": {
25+
"type": "string",
26+
"pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"
27+
},
28+
"variable_scope": {
29+
"type": "string",
30+
"enum": ["repository", "environment"]
31+
},
32+
"environment": {
33+
"type": "string"
34+
}
35+
}
36+
},
37+
"runtime_target": {
38+
"type": "object",
39+
"required": [
40+
"platform_id",
41+
"strategy_profile",
42+
"dry_run_only",
43+
"deployment_selector",
44+
"account_selector",
45+
"account_scope",
46+
"service_name",
47+
"execution_mode"
48+
],
49+
"additionalProperties": false,
50+
"properties": {
51+
"platform_id": {
52+
"type": "string"
53+
},
54+
"strategy_profile": {
55+
"type": "string"
56+
},
57+
"dry_run_only": {
58+
"type": "boolean"
59+
},
60+
"deployment_selector": {
61+
"type": "string"
62+
},
63+
"account_selector": {
64+
"type": "array",
65+
"items": {
66+
"type": "string"
67+
},
68+
"minItems": 1
69+
},
70+
"account_scope": {
71+
"type": "string"
72+
},
73+
"service_name": {
74+
"type": "string"
75+
},
76+
"execution_mode": {
77+
"type": "string",
78+
"enum": ["live", "paper", "dry_run"]
79+
}
80+
}
81+
},
82+
"plugin_mounts_variable": {
83+
"type": "string"
84+
},
85+
"plugin_mounts": {
86+
"type": "array",
87+
"items": {
88+
"type": "object",
89+
"required": ["strategy", "plugin", "signal_path", "enabled", "expected_mode"],
90+
"additionalProperties": false,
91+
"properties": {
92+
"strategy": {
93+
"type": "string"
94+
},
95+
"plugin": {
96+
"type": "string"
97+
},
98+
"signal_path": {
99+
"type": "string"
100+
},
101+
"enabled": {
102+
"type": "boolean"
103+
},
104+
"expected_mode": {
105+
"type": "string"
106+
}
107+
}
108+
}
109+
},
110+
"extra_variables": {
111+
"type": "object",
112+
"additionalProperties": {
113+
"type": ["string", "number", "integer", "boolean", "object", "array", "null"]
114+
}
115+
}
116+
}
117+
}
118+

0 commit comments

Comments
 (0)