|
1 | 1 | # QuantRuntimeSettings |
2 | 2 |
|
3 | | -<!-- qsl-doc-overview:start --> |
| 3 | +[Chinese README](README.zh-CN.md) |
4 | 4 |
|
5 | | -> ⚠️ 投资有风险,不构成投资建议,仅供学习交流用途。 |
6 | 5 | > ⚠️ Investing involves risk. This project does not provide investment advice and is for educational and research purposes only. |
7 | 6 |
|
8 | | -## Open-source overview / 开源项目入口 |
| 7 | +## What this project does |
9 | 8 |
|
10 | | -| Item | Description | |
11 | | -| --- | --- | |
12 | | -| Project type | runtime settings | |
13 | | -| What it does | Runtime settings schema and tooling for QuantStrategyLab deployments. | |
14 | | -| 中文说明 | 运行时配置 schema 与工具,帮助各部署统一账户、profile、dry-run/live 参数。 | |
15 | | -| Current status | Configuration tooling. It should not contain secrets or live account identifiers. | |
| 9 | +QuantRuntimeSettings is a **Runtime configuration package** in the QuantStrategyLab ecosystem. It defines schemas and tooling for shared QuantStrategyLab runtime settings. |
16 | 10 |
|
17 | | -### Quick start |
| 11 | +## Who this is for |
18 | 12 |
|
19 | | -- `python -m pip install -e '.[test]'` |
20 | | -- `python -m pytest -q` |
| 13 | +- Engineers and researchers who want to inspect, reproduce, or extend this part of the QuantStrategyLab stack. |
| 14 | +- Operators who need a clear entry point before reading the deeper runbooks or workflow files. |
| 15 | +- Reviewers who need to understand the repository purpose, safety boundary, and evidence requirements before enabling automation. |
21 | 16 |
|
22 | | -### Deploy / operate safely |
| 17 | +## Current status |
23 | 18 |
|
24 | | -Consume generated settings from platform repositories; validate redaction and environment-specific overrides before use. |
| 19 | +Shared configuration contract; changes can affect multiple platforms. |
25 | 20 |
|
26 | | -### Strategy performance / evidence boundary |
| 21 | +## Repository layout |
27 | 22 |
|
28 | | -Not a strategy repository; correctness is schema/test coverage and safe downstream consumption. |
| 23 | +- `tests/`: unit and contract tests. |
| 24 | +- `.github/workflows/`: CI, scheduled jobs, and deployment workflows. |
| 25 | +- `scripts/`: operator scripts and local helpers. |
29 | 26 |
|
30 | | -> Detailed runbooks, migration notes, workflow internals, and historical decisions are kept below. Start with this overview before using the lower-level operational sections. |
| 27 | +## Quick start |
31 | 28 |
|
32 | | -<!-- qsl-doc-overview:end --> |
33 | | - |
34 | | -> ⚠️ 投资有风险,不构成投资建议,仅供学习交流用途。 |
35 | | -
|
36 | | -[English](#english) | [中文](#中文) |
37 | | - |
38 | | ---- |
39 | | - |
40 | | -<a id="english"></a> |
41 | | -## English |
42 | | - |
43 | | -Declarative runtime settings tooling for QuantStrategyLab deployments. |
44 | | - |
45 | | -This repository provides the schema and tooling for "which platform runs which strategy". It does not contain live runtime assignments, strategy logic, broker execution code, credentials, or secrets. |
46 | | - |
47 | | -## Public Repository Policy |
48 | | - |
49 | | -Live target files must not be committed to this public repository. Keep real deployment choices in GitHub Variables/Environments, GitHub Secrets, Secret Manager, or ignored local files under `local/`. |
50 | | - |
51 | | -Use repository or environment variables for non-secret runtime choices such as `TARGET_SPEC_JSON`, `RUNTIME_TARGET_JSON`, and plugin mount declarations. Use secrets only for credentials, tokens, and private keys. |
52 | | - |
53 | | -If a deployment needs private validation policy, keep it in ignored local files such as `local/policy.json`. |
54 | | - |
55 | | -## Boundaries |
56 | | - |
57 | | -- `UsEquityStrategies` owns allocation logic, strategy defaults, and risk rules. |
58 | | -- Platform repositories own broker adapters, runtime input collection, notifications, and execution. |
59 | | -- This repository owns runtime target schemas, examples, validation, and rendering tools. |
60 | | -- Secret values are intentionally excluded. Use secret names or platform repository secrets when needed. |
61 | | - |
62 | | -## Commands |
63 | | - |
64 | | -Validate examples, or local targets when `local/targets/**/*.json` exists: |
65 | | - |
66 | | -```bash |
67 | | -python3 scripts/runtime_settings.py validate |
68 | | -``` |
69 | | - |
70 | | -Render assignments for an example: |
71 | | - |
72 | | -```bash |
73 | | -python3 scripts/runtime_settings.py render examples/targets/schwab/live.example.json |
74 | | -``` |
75 | | - |
76 | | -Preview GitHub variable updates for an ignored local target: |
77 | | - |
78 | | -```bash |
79 | | -python3 scripts/runtime_settings.py apply local/targets/longbridge/sg.json |
80 | | -``` |
81 | | - |
82 | | -Apply GitHub variable updates: |
| 29 | +From a fresh clone: |
83 | 30 |
|
84 | 31 | ```bash |
85 | | -python3 scripts/runtime_settings.py apply --yes local/targets/longbridge/sg.json |
| 32 | +python -m pip install -e . |
| 33 | +python -m pytest -q |
86 | 34 | ``` |
87 | 35 |
|
88 | | -`RUNTIME_TARGET_JSON` is canonical. Compatibility variables such as `STRATEGY_PROFILE` are generated from it so they cannot drift independently. |
89 | | - |
90 | | -For daily strategies that want both a precheck pass and an execution pass, declare them in `runtime_target.execution_windows`. Keep the strategy logic unchanged; let the platform layer decide whether a window is `notify_only`, `dry_run`, `paper`, or `live`. |
91 | | - |
92 | | -## Architecture |
93 | | - |
94 | | -This repo acts as a small bridge between strategy selection and platform deployment without exposing live assignments: |
95 | | - |
96 | | -- A target file declares the desired runtime target. |
97 | | -- The validator checks that required runtime fields and plugin mounts are coherent. |
98 | | -- Optional ignored local policy can add private strategy/plugin requirements. |
99 | | -- The renderer converts the declaration into platform-specific GitHub variables. |
100 | | -- Platform repositories keep their existing adapter code and consume the generated variables. |
101 | | - |
102 | | ---- |
103 | | - |
104 | | -<a id="中文"></a> |
105 | | -## 中文 |
| 36 | +If a command requires credentials, run it only after reading the relevant workflow or runbook and configuring secrets outside Git. |
106 | 37 |
|
107 | | -QuantStrategyLab 部署运行设置的声明式 schema 和工具仓库。 |
| 38 | +## Deployment and operation |
108 | 39 |
|
109 | | -这个仓库用于描述和校验“哪个平台运行哪个策略”的配置格式,但不保存真实线上运行分配、策略逻辑、券商执行代码、凭据或密钥。 |
| 40 | +Use the schemas in platform repositories and CI validation. Roll out setting changes through review, dry-run validation, and controlled platform deployment. |
110 | 41 |
|
111 | | -## 公开仓库策略 |
| 42 | +Prefer manual or dry-run execution first. Enable schedules or live execution only after logs, artifacts, permissions, and rollback steps are reviewed. |
112 | 43 |
|
113 | | -真实 target 文件不能提交到这个公开仓库。真实部署选择应保存在 GitHub Variables / Environments、GitHub Secrets、Secret Manager,或放在被忽略的 `local/` 目录下。 |
| 44 | +## Strategy performance and evidence |
114 | 45 |
|
115 | | -非敏感运行选择,例如 `TARGET_SPEC_JSON`、`RUNTIME_TARGET_JSON` 和插件挂载声明,可以放在 repository 或 environment variables 中。凭据、token、private key 等必须使用 secrets。 |
| 46 | +Not a strategy repository. Quality is measured by compatibility, validation coverage, and reducing configuration mistakes. |
116 | 47 |
|
117 | | -如果某个部署需要私有校验策略,请放在被忽略的本地文件里,例如 `local/policy.json`。 |
| 48 | +README files are intentionally not a source of dated performance promises. Re-run the relevant tests, backtests, or pipeline jobs before relying on any result. |
118 | 49 |
|
119 | | -## 边界 |
120 | | - |
121 | | -- `UsEquityStrategies` 负责分配逻辑、策略默认值和风险规则。 |
122 | | -- 平台仓库负责券商 adapter、运行时输入采集、通知和执行。 |
123 | | -- 本仓库负责运行 target 的 schema、示例、校验和渲染工具。 |
124 | | -- 本仓库不保存 secret value;需要时只引用 secret name 或平台仓库自身的 secret。 |
125 | | - |
126 | | -## 命令 |
127 | | - |
128 | | -校验示例;如果存在 `local/targets/**/*.json`,则优先校验本地 target: |
129 | | - |
130 | | -```bash |
131 | | -python3 scripts/runtime_settings.py validate |
132 | | -``` |
133 | | - |
134 | | -渲染一个示例 target: |
135 | | - |
136 | | -```bash |
137 | | -python3 scripts/runtime_settings.py render examples/targets/schwab/live.example.json |
138 | | -``` |
139 | | - |
140 | | -预览被忽略本地 target 对应的 GitHub variable 更新: |
141 | | - |
142 | | -```bash |
143 | | -python3 scripts/runtime_settings.py apply local/targets/longbridge/sg.json |
144 | | -``` |
145 | | - |
146 | | -实际应用 GitHub variable 更新: |
147 | | - |
148 | | -```bash |
149 | | -python3 scripts/runtime_settings.py apply --yes local/targets/longbridge/sg.json |
150 | | -``` |
| 50 | +## Safety notes |
151 | 51 |
|
152 | | -`RUNTIME_TARGET_JSON` 是唯一 canonical source。兼容变量,例如 `STRATEGY_PROFILE`,由它生成,避免多个配置源互相漂移。 |
| 52 | +- Never commit API keys, broker credentials, OAuth tokens, cookies, or account identifiers. |
| 53 | +- Run new strategies and platform changes in dry-run or paper mode before any live execution. |
| 54 | +- Review generated orders, artifacts, and logs manually before enabling schedules. |
153 | 55 |
|
154 | | -对于希望同时有预检和执行两次运行的日频策略,可以在 `runtime_target.execution_windows` 里显式声明两个窗口。策略逻辑保持不变,由平台层决定某个窗口是 `notify_only`、`dry_run`、`paper` 还是 `live`。 |
| 56 | +## Contributing |
155 | 57 |
|
156 | | -## 架构 |
| 58 | +Keep changes small, reproducible, and covered by the narrowest useful tests. For strategy-facing changes, include the evidence artifact or command used to validate behavior. |
157 | 59 |
|
158 | | -这个仓库在策略选择和平台部署之间提供一个轻量 bridge,同时避免公开真实运行分配: |
| 60 | +## License |
159 | 61 |
|
160 | | -- target 文件声明期望的运行目标。 |
161 | | -- validator 检查必填运行字段和插件挂载是否一致。 |
162 | | -- 可选的 ignored local policy 可以添加私有策略/插件要求。 |
163 | | -- renderer 把声明转换成平台专属 GitHub variables。 |
164 | | -- 平台仓库保持现有 adapter 代码,并消费生成后的变量。 |
| 62 | +See [LICENSE](LICENSE) if present in this repository. |
0 commit comments