Squashed 'docs/standards/playbook/' changes from c3f8137..25d895d

25d895d 🐛 fix(gitea_workflow): clean up temp repos after job steps
2bc3b11 🐛 fix(gitea_workflow): clean up temporary repo dirs in workflows
98c3f30 📝 docs(agent_rules): allow plan execution on current branch
16c7230 📝 docs(prompts): define custom verify layering
8efc4dd 🐛 fix(skills): quote commit-message description
bc8498f 🐛 fix(ci): install tomli for gitea tests
55cda3b 🐛 fix(tests): report missing toml parser clearly
c0729c7 🐛 fix(playbook): import Optional for cli compatibility
63e24bf 📦 deps(skills): sync thirdparty skills
d2f9356 🐛 fix(ci): isolate gitea workflow repos
588b81d 🐛 fix(ci): inline gitea workflow bootstrap
e0b1c3a ♻️ refactor(skills): standardize first-party skill contracts
2c5050d ♻️ refactor(skills): rename repo skills source dir
f049dfb 📦 deps(skills): drop duplicate first-party superpowers skills
234b335  feat(workflow): add superpowers planning and execution state tracking
c1702a6 📝 docs(markdown): format tracked markdown and drop stale templates
2325409 📝 docs(markdown): clarify optional markdownlint usage
214c44e 🔧 chore(markdown): add markdownlint baseline and lint fixes
a22b324 📝 docs(templates): add execution and memory-bank prompt templates
223a797 📝 docs(templates): update README for Claude Code and current features
4ac8672 📝 docs: simplify README + platform-agnostic tools + auto-create local rules
2431c9d 📝 docs: add claude_md config and use cross-platform paths
d64b248 📝 docs: fix README.md inaccuracies and add Claude Code info
c8d6bf2 🐛 fix(playbook): use relative paths in CLAUDE.md when not at project root
6518f0f  feat(playbook): auto-create CLAUDE.md with path discovery
6ec9a45  feat(skills): add skill_link symlink support + platform-agnostic prompt
9f8b6b5 📝 docs: update README and config example for Claude Code support
79cff6c 📝 docs(skills): add Claude Code platform support
452c6f5  feat(playbook): auto-inject AGENTS.md into CLAUDE.md
e1dbf3c 🐛 fix(skills): remove dual-path from commit-message skill
f3a7259 🔧 chore(ci): use prepare_repo.sh in both workflows
da08212 🔧 chore(ci): extract prepare_repo.sh and clean up workflows
7ade85e 🗑️ remove(tsl): drop syntax_book/, data/ source and build script
f94dba0 ♻️ refactor(skills): update playbook.py and tests for thirdparty/ layout
b3df412 ♻️ refactor(skills): separate thirdparty skills into thirdparty/ subdirectory
64950e7 📦 deps(skills): sync thirdparty skills
a2e3cb0  feat(playbook): add no_backup deploy controls
8609d59 🐛 fix(docs): repair reference catalog source links
956da11 🐛 fix(playbook): publish hidden ci test fixes
3f67754 📦 deps(skills): sync thirdparty skills
08ca87b 📦 deps(skills): add karpathy thirdparty sync
96b705b 📝 docs(tsl): rebuild canonical syntax and routing manual
3ed5052 📦 deps(skills): sync thirdparty skills
60108dd 📦 deps(skills): sync thirdparty skills
da85d4e 🐛 fix(thirdparty): prune nested project snapshots
a2a697e 📦 deps(skills): sync thirdparty skills
9df610a 🐛 fix(thirdparty): exclude duplicated superpowers skills
33dd5bb 🐛 fix(thirdparty): preserve optional manifest fields
91b0ea7 🐛 fix(thirdparty): preserve manifest during snapshot update
2e26f98 🔧 chore(thirdparty): generalize skills sync pipeline
5b9c1e3 📦 deps(skills): sync superpowers
2f2d34a 📝 docs(readme): normalize subtree command spacing
62db7db 🐛 fix(ci): serialize superpowers update and sync
3463223 🐛 fix(ci): use literal superpowers sync paths
48f6de8 📦 deps(skills): sync superpowers
4b23529 🔧 chore(ci): merge superpowers update and sync workflow
a56d75b 📦 deps(skills): sync superpowers
84bcefa 🔧 chore(ci): use ci[bot] commit author name
00a07e5 📦 deps(skills): sync superpowers
7b84daf 🐛 fix(templates): enforce main loop progress tracking
51373d7 🔧 chore(ci): automate superpowers sync workflow
eaaa39c 🐛 fix(ci): prevent stale superpowers sync from restoring skills block
79755c6 📦 deps(skills): sync superpowers
836d878 📦 deps(skills): sync superpowers
8216c9f 📦 deps(skills): sync superpowers
9439505 🐛 fix(playbook): address reported repo issues

git-subtree-dir: docs/standards/playbook
git-subtree-split: 25d895d8b3f56624ccfe99ad7289e9eb49e0f316
This commit is contained in:
csh
2026-05-24 13:04:14 +08:00
parent 35e6a301aa
commit 3d83740f88
292 changed files with 30774 additions and 218828 deletions
+39 -52
View File
@@ -1,66 +1,53 @@
# 策略回测框架 TSBackTesting
## 定位
文档类型:模块摘要
是否可直接用于生成代码:否
是否含已验证可执行示例:否
是否含已验证反例:否
遇到不确定时跳转到:项目实际接口定义、[../finance/backtest_and_trade_flow.md](../finance/backtest_and_trade_flow.md)、[index.md](index.md)
- 提供统一的策略回测框架(股票/期货/期权/组合等),覆盖资金、交易约束、清算与绩效输出
本页不足以直接生成回测代码,只用于确认回测任务的组织顺序,以及哪些地方必须回到项目实际接口定义继续核对
## 结构索引
- 只要任务已经进入对象创建、交易输入入口、结果读取方法或项目封装差异,就先停止生成,直接回项目实际接口定义,不要先拼调用链。
- 策略回测流程
- 成员变量
- 成员方法
- 查询用接口
- 回测范例
- 债券品种回测说明
- 期权组合策略回测说明
- 常见问题
## 适用场景
## 回测流程概览
- 任务已经进入“回测框架怎么配置、怎么执行、怎么读结果”。
- 你处理的是组合型任务,而不是单纯的表达式或单次筛选。
- 你已经知道自己要做比例类组合还是数量类组合,或者正在先判断这件事。
- 组合类型选择 → 交易数据准备 → 回测执行 → 结果查询与分析。
## 当前只确认的范围
## 组合类型
- 当前页已经确认的范围是:对象名 `TSBackTesting`、典型任务顺序、组合类型差异、常见字段组和常见结果接口类别。
- 下面出现的字段名和结果接口名,只用于检索候选和理解类别,不是可以直接假定存在的项目接口真值。
- 任务顺序可以先按这条主线理解:组合类型选择 → 交易数据准备 → 回测执行 → 结果查询与分析。
- 组合类型先按两类理解:比例类组合提供目标权重,数量类组合提供成交量或成交价等交易明细。
- 常见字段组可以先按以下几类检索:
- 时间与周期:`FBegT``FEndT``FCycle`
- 组合类型:`FGroupType`
- 资金与价格:`FIniCash``FPriceType``FPriceType1..4`
- 交易约束:`FNoZT``FNoDT``FMinVol``FMinAmount``FMaxVolPercent``FMaxAmountPercent`
- 费用与分红:`FFeeType``FlowestFeeType``FDividendType`
- 基准与输出:`FBMType``FBMDetail``FBMOption``FHFDataOutPut`
- 常见结果接口可以先按以下类别检索:`GetTimeSeries``GetTradeOrder``GetNetAssetValue` / `GetAssetData` / `GetHoldData``GetPercent``GetIRRReturn``ReturnBenchmark`
- 比例类组合:提供目标权重。
- 数量类组合:提供成交量/成交价等交易明细。
## 任务骨架(非代码模板)
## 关键成员变量(分组摘要)
1. 先判断任务属于比例类组合还是数量类组合。
2. 然后先回到项目实际接口定义,确认最小可用对象模型、对象创建方式、最小必填项和交易数据输入入口。
3. 再确认起止时间、组合类型和初始资金是不是项目里的最小必填项。
4. 执行回测。
5. 最后先按项目实际接口定义确认结果读取链路,再读取净值时间序列、成交结果或持仓结果,再补看绩效指标。
- **时间与周期**`FBegT``FEndT``FCycle`
- **组合类型**`FGroupType`(比例类/数量类)
- **资金与价格**`FIniCash``FPriceType``FPriceType1..4`
- **交易约束**`FNoZT``FNoDT``FMinVol``FMinAmount``FMaxVolPercent``FMaxAmountPercent`
- **费用与分红**`FFeeType``FlowestFeeType``FDividendType`
- **期权与期货特性**`FOptionRs``FMainFutureMap`
- **基准与输出**`FBMType``FBMDetail``FBMOption``FHFDataOutPut`
## 不要猜的部分
> 详细取值及说明以实际接口定义为准
- 当前页没有确认的范围是:对象创建方式、最小必填字段的强制集合、交易数据入口名、最小输入结构、结果读取完整链路
- 如果没有项目实际接口定义,不要根据本页直接写 `new TSBackTesting()``SetTradeData(...)` 或其他具体调用链。
- 各字段可选值和更细接口,以实际接口定义为准;当前页只负责告诉你要核对哪些位置,不负责补全细节。
## 关键成员方法(常用)
## 跳转指引
- `BackTest`:执行回测
- `GetTimeSeries`:返回净值/收益率时间序列
- `GetTradeOrder`:返回调仓/成交数据
- `GetNetAssetValue` / `GetAssetData` / `GetHoldData`:资产与持仓
- `GetPercent``GetIRRReturn``ReturnBenchmark`:绩效指标
- `GetClearancePrice` / `GetIntVol` / `GetOtherData`:扩展查询
## 最小流程示例(概念化)
```tsl
// 1) 初始化参数
backtest := new TSBackTesting();
backtest.FBegT := 20240101T;
backtest.FEndT := 20241231T;
backtest.FGroupType := 1; // 比例类
backtest.FIniCash := 1000000;
// 2) 设置交易数据(比例类:目标持仓)
// backtest.SetTradeData(trade_data);
// 3) 执行回测
backtest.BackTest();
// 4) 获取结果
return backtest.GetTimeSeries();
```
- 业务组织问题:见 [../finance/backtest_and_trade_flow.md](../finance/backtest_and_trade_flow.md)
- 具体字段、交易数据入口、对象创建方式和结果接口真值:回项目实际接口定义
- 回到模块入口:见 [index.md](index.md)
- 只在需要查 TSL 通用函数归类时,才回 [../reference/index.md](../reference/index.md)