完成反复活跃频次与持有期矩阵研究
This commit is contained in:
parent
bf2cce4d2c
commit
8c79c4610d
|
|
@ -2496,3 +2496,12 @@ QMT仍有序号缺口,16:23确认1441965、最高1442003、暂存32条。16:24
|
|||
每边30基点下,810组2026年平均单批净收益均为负。预设0.8/0.7/5日账户2026收益−21.77%、最大回撤−25.73%;只筛smart≥0.7为−21.12%。2025训练选出的smart≥0.8、2日方案为−38.66%,分阶段方案为−35.24%。阶段判断对沪深300或中证2000分类敏感;没有将任何研究参数写入运行系统。
|
||||
|
||||
开发机9项配置隔离、断网测试通过;3个逐笔账户重建最大误差5.22e-14,36条账户现金守恒通过,10种持有期训练截断复算一致,旧热度基线全路径复现。4幅研究图已检查。源表没有历史入库时刻或版本号,支持覆盖旧值,因此只称现存历史评分回放;缺评分日、缺历史资格和期末残仓已披露。待补不可覆盖快照、历史可用时间、完整退市与实际成交容量证据。未改应用代码、未部署或重建线上容器。
|
||||
|
||||
|
||||
## 2026-10-29 反复活跃股票频次与持有期矩阵
|
||||
|
||||
北京时间09:36,按用户要求完成单分数、市场阶段、收益指数及此前20日达标次数隔离。协议09:10冻结,total和smart分别扫描6档门槛、0至20次、1至10交易日及3种当天/历史条件,共5160组;交付201,240行分组结果、42条预设账户、自包含矩阵浏览器及6幅PNG。入口为`docs/反复活跃矩阵研究接续_2026-10-29.md`,报告与代码在`research/score_recurrence_20261029/`。
|
||||
|
||||
缺评分不记0次,统一完整20日观察池后有389个可用信号日。每边30基点下,2026有94组最低展示样本要求内的平均批次净收益为正,60基点下剩44组;高频次正格多为少数股票,不能当独立验证或账户盈利。固定smart≥0.8、K≥5、H5的2026批次净收益−0.84%,相对K0改善0.062个百分点;加当天达标未延续改善。固定H5、两年皆正的仅历史频次条件有5组,但2026日均入选仅1.7至4.2只。
|
||||
|
||||
开发机9项配置隔离、断网测试通过;1200次直接历史窗口计数、6项旧基线和36项指数区间核验通过;3个账户逐笔独立重建、42条账户现金守恒及21条30基点前缀核验通过。本地Chrome完成矩阵与表格联动、独立阶段/指数切片、CSV/PNG导出及手机布局验收,外部请求0。沿用历史可覆盖快照,首次可用时间、完整退市覆盖及实际成交容量仍未解决。未改应用、运行参数、持仓或容器,未部署。
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
# 反复活跃股票矩阵研究接续
|
||||
|
||||
核验时间:北京时间2026年10月29日09:36。当前状态:用户要求的变量隔离、此前20日频次与1至10日持有期矩阵已完成。仅使用开发机上一轮快照,未连接数据库、未改应用或运行参数,未部署或重建业务容器。
|
||||
|
||||
## 结果入口
|
||||
|
||||
- [离线矩阵浏览器](../research/score_recurrence_20261029/反复活跃矩阵浏览器.html):可切换分数、门槛、次数、持有期、年份、阶段分类指数、收益对照指数和费用,导出当前CSV或PNG。
|
||||
- [完整研究报告](../research/score_recurrence_20261029/反复活跃与持有期矩阵研究.md):包含6幅可导出热力图、固定条件持有1至10日表、跨年正收益区域、账户和局限。
|
||||
- 实验目录:`research/score_recurrence_20261029/`。协议09:10冻结,结果为5160组参数、201,240行分组数据和42条预设现金账户。
|
||||
|
||||
## 口径与主要结果
|
||||
|
||||
total_score与smart_score分开测试,门槛0.5/0.6/0.7/0.8/0.9/0.95。次数取信号日前20个交易日,不含当天,K为最少次数,范围0至20;分别测试仅当天、仅历史次数、历史次数且当天达标。持有期1至10交易日,沿用次日开盘和卖出受阻顺延。阶段指数与收益对照指数分别可选沪深300、中证500、中证1000、中证2000,全市场股票池固定;不是按历史指数成分股筛选,也不是beta中性化。
|
||||
|
||||
要求完整20日历史观察后,共同信号窗口从2025年1月22日开始,至2026年9月30日;行情截至10月23日。410个日历交易日中389日可形成信号:2025年229日、2026年160日。2026年3月19日缺评分,当日和其后20日不形成信号,不能把缺分当作0次。当天分数对照也使用同一观察池,因此不能把本轮账户值与上轮不同日期范围直接比较。
|
||||
|
||||
固定smart≥0.8、前20日最少5次、持有5日、不要求当天达标,2026平均单批净收益−0.84%,比K=0改善0.062个百分点;再加当天达标后没有相同改善。频次效果不单调,市场阶段和指数口径会改变切片表现。
|
||||
|
||||
每边30基点下,2026有94组达到最低展示样本要求且平均批次为正,60基点下剩44组;这是相关参数网格,不是独立成功次数。固定5日、仅历史频次时,两年都为正的观察点共有5组,其2026日均入选只有1.7至4.2只。例如smart≥0.8、最少18次,2025与2026每批分别+0.37%、+0.54%,60基点下2026变为−0.06%。这些均为看过结果后的诊断,不是训练外验证或上线建议。
|
||||
|
||||
高频次正格需要结合集中度看。smart≥0.8、前20日全部达标、持有5日,2026每批+0.89%,但只有52个成交信号日、115笔完成交易、34只股票;2025同条件为−0.20%,描述性整块抽样区间跨0。正收益格不代表账户累计收益。未按事后最高格追加账户。
|
||||
|
||||
## 验证与未完成事项
|
||||
|
||||
开发机9项内存测试经unit_test_guard隔离配置并断网通过;1200次原始20日窗口计数、6项旧单因子基线、36项实际退出日期指数对齐均通过。3个详细账户独立逐笔重建,42条账户检查现金守恒,21条30基点账户截断前缀一致。浏览器在独立Chrome上下文检查切片、点击格子更新1至10日表、独立指数选择、CSV/PNG下载和430像素布局,外部请求0。
|
||||
|
||||
仍缺评分首次可用时间与不可覆盖版本,结果是现存历史分数回放。历史退市和资格覆盖、整手、最低佣金、开盘冲击及实际资金规模尚未完整验证。高频次条件稀疏且同一股票反复入选,不能把交易笔数当独立样本量。没有生成或执行PMS参数变更。
|
||||
|
||||
原始快照沿用`signal_scores_20261028/`和`macro_timing_20261026/`,派生逐日数据在本目录cache/,不入Git。源摘要在coverage.json,交付摘要在manifest.json;复现命令和依赖在报告中。浏览器为自包含HTML,无需服务器或联网;约15MB,初次打开需载入本地数据。
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
| --- | --- |
|
||||
| 当前微盘接入、参数和运行待办 | [阶段接续与实验意见](微盘轮动阶段接续_2026-10-28.md);需要部署证据再读[50股发布记录](微盘轮动50股参数发布_2026-10-28.md) |
|
||||
| 全市场热度、涨跌幅与持有期标定 | [热度策略研究接续](全市场热度四维标定接续_2026-10-28.md),含回填限制、参数结果和复现入口 |
|
||||
| 综合分与聪明资金分阈值及市场阶段比较 | [评分策略研究接续](综合分与聪明资金分标定接续_2026-10-28.md),含810组结果、历史版本限制和复现入口 |
|
||||
| 综合分与聪明资金分阈值及市场阶段比较 | [评分策略研究接续](综合分与聪明资金分标定接续_2026-10-28.md),含810组结果、历史版本限制和复现入口;[反复活跃矩阵接续](反复活跃矩阵研究接续_2026-10-29.md),含20日次数、1至10日持有期与指数隔离 |
|
||||
| PMS通用迁移与既有修复 | [开发接续](开发接续_2026-10-12.md),按主题查对应节;旧时点未完成项可能已有后续结论 |
|
||||
| 架构与接口 | [README模块地图](../README.md)、[总体设计](../POSITION_MGMT_DESIGN.md);改接口再读[QMT协议](../QMT_WS_PROTOCOL.md)、[bionic接口](../BIONIC_PMS_INTERFACE.md)或[计划接口](../UPSTREAM_PLAN_API.md) |
|
||||
| 后端、前端、测试、研究 | [后端规则](../app/AGENTS.md)、[页面规则](../app/web/AGENTS.md)、[脚本规则](../scripts/AGENTS.md)、[研究规则](../research/AGENTS.md),仅选择所涉及目录 |
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
cache/
|
||||
__pycache__/
|
||||
Binary file not shown.
|
|
@ -0,0 +1,43 @@
|
|||
name,config,score,threshold,mode,k,hold,fee_bps,return,max_drawdown,fees_initial_capital,buy_count,sell_count,skipped_buy,delayed_lots,ending_cash,ending_stock_value,open_lots,max_stock_weight,max_positions,max_stale_valuation,mean_exposure
|
||||
total_current,129,total,0.8,current,0,1,30,-0.6696153127746653,-0.6858382301270084,0.598580239996093,156670,156670,571,243,0.3303846872253346,0.0,0,0.0014315096527357527,1032,0.03543918982395679,0.989800882030804
|
||||
total_current,129,total,0.8,current,0,1,60,-0.8727018644436354,-0.8756693472317271,0.841705332920095,156670,156670,571,243,0.12729813555636457,0.0,0,0.0014314538643828924,1032,0.026346963753969208,0.9900802471176962
|
||||
total_current,129,total,0.8,current,0,5,30,-0.27937045359698853,-0.3137048599736245,0.16825074192390507,156670,156668,571,396,0.7206295464030115,0.0,2,0.00150921028720629,2983,0.05085278914166795,0.8759657556007792
|
||||
total_current,129,total,0.8,current,0,5,60,-0.4047361375046864,-0.4313964165834513,0.30817425987913344,156670,156668,571,396,0.5952638624953136,0.0,2,0.0015094327562249943,2983,0.045783819210928625,0.876114288915675
|
||||
total_current,129,total,0.8,current,0,10,30,-0.22251313564540331,-0.2550234003068239,0.08775267742170069,156670,156662,571,358,0.7771791891340258,0.00030767522057085567,8,0.001497972344478187,3742,0.04777446958840569,0.8619200555308533
|
||||
total_current,129,total,0.8,current,0,10,60,-0.29351695426834457,-0.3183925798798065,0.16770674918313971,156670,156662,571,358,0.7062030456878102,0.0002800000438452066,8,0.0014986377550191277,3742,0.04700072343490809,0.8619378920340349
|
||||
total_frequency,135,total,0.8,frequency,5,1,30,-0.6374014702062183,-0.6522663720664759,0.6444579943936318,289974,289973,969,416,0.3625985297937817,0.0,1,0.0007658671764627189,1970,0.03814144005409616,0.9321736965964261
|
||||
total_frequency,135,total,0.8,frequency,5,1,60,-0.8603537794160658,-0.8624336795434954,0.8990977101211356,289974,289973,969,416,0.1396462205839341,0.0,1,0.0007658366213908376,1970,0.03144386500458467,0.9324553468426666
|
||||
total_frequency,135,total,0.8,frequency,5,5,30,-0.2714670264965293,-0.3149180108297809,0.17403680963556378,289974,289973,969,689,0.7285329735034707,0.0,1,0.0009120689974727795,2253,0.04549409276369874,0.8717749796557186
|
||||
total_frequency,135,total,0.8,frequency,5,5,60,-0.3982366312133463,-0.42629357812798085,0.31868669442812536,289974,289973,969,689,0.6017633687866537,0.0,1,0.0009123488378704036,2253,0.04202882913671588,0.8718993148803446
|
||||
total_frequency,135,total,0.8,frequency,5,10,30,-0.2257599198756315,-0.2731296361375487,0.08898004835984596,289974,289973,969,725,0.7742400801243685,0.0,1,0.0009781778010729593,2559,0.04714057017955234,0.8489148140220215
|
||||
total_frequency,135,total,0.8,frequency,5,10,60,-0.29653160107465626,-0.32981480418754816,0.17007760847489112,289974,289973,969,725,0.7034683989253437,0.0,1,0.0009785904887390374,2559,0.04478880289745352,0.8489371026649053
|
||||
total_both,156,total,0.8,both,5,1,30,-0.6592980138396796,-0.6775227050461402,0.6203516402239974,94613,94613,331,160,0.34070198616032044,0.0,0,0.0035250338196128384,798,0.04167287749848296,0.9960067522679426
|
||||
total_both,156,total,0.8,both,5,1,60,-0.8687335952118047,-0.8723751931153946,0.8676072858818437,94613,94613,331,160,0.13126640478819535,0.0,0,0.0035248846491419566,798,0.028732986873687773,0.9963468261607978
|
||||
total_both,156,total,0.8,both,5,5,30,-0.28513722338261394,-0.31994227806577225,0.17166475469646206,94613,94613,331,213,0.7148627766173861,0.0,0,0.002865717531442346,1569,0.05829937666839854,0.8958374357386553
|
||||
total_both,156,total,0.8,both,5,5,60,-0.4095660314408155,-0.4366236073987909,0.3143434469535633,94613,94613,331,213,0.5904339685591845,0.0,0,0.0028666586805957436,1569,0.052483260776605166,0.895997521734583
|
||||
total_both,156,total,0.8,both,5,10,30,-0.2224201837371359,-0.2629775627965255,0.08972438759436625,94613,94613,331,192,0.7775798162628641,0.0,0,0.0024731937061360653,1916,0.05374395689232224,0.8713343486537454
|
||||
total_both,156,total,0.8,both,5,10,60,-0.29345907034944907,-0.323007893713282,0.17144769873967367,94613,94613,331,192,0.7065409296505509,0.0,0,0.002473604546818817,1916,0.05104588131999259,0.871333575676694
|
||||
smart_current,387,smart,0.8,current,0,1,30,-0.6280464809898485,-0.6443132922670722,0.6446333480946427,87149,87149,285,115,0.3719535190101515,0.0,0,0.0030931146795827934,779,0.03394159381363794,0.9962835661590086
|
||||
smart_current,387,smart,0.8,current,0,1,60,-0.8567373252765992,-0.8592834337299348,0.8983712712945761,87149,87149,285,115,0.14326267472340085,0.0,0,0.0030930093770451025,779,0.028054608322227663,0.9965867012364615
|
||||
smart_current,387,smart,0.8,current,0,5,30,-0.2597455886242016,-0.2935202935309823,0.17290005816574341,87149,87149,285,220,0.7402544113757984,0.0,0,0.002760383226183172,2082,0.045578615593126204,0.9276803725847613
|
||||
smart_current,387,smart,0.8,current,0,5,60,-0.38859462744200945,-0.41165723028943757,0.31652164374823283,87149,87149,285,220,0.6114053725579905,0.0,0,0.0027618164812902276,2082,0.043966666915102814,0.9278330375752318
|
||||
smart_current,387,smart,0.8,current,0,10,30,-0.21312839967412767,-0.2565555498878812,0.08887996776396902,87149,87144,285,221,0.7863348824760552,0.0005367178498171491,5,0.002613987891732812,2716,0.041874281854040483,0.8628128303167998
|
||||
smart_current,387,smart,0.8,current,0,10,60,-0.2850847047454017,-0.3133345295819313,0.16985777417664047,87149,87144,285,221,0.7144269314933418,0.000488363761256517,5,0.002613862182825736,2716,0.041186718903527195,0.8628114542109396
|
||||
smart_frequency,393,smart,0.8,frequency,5,1,30,-0.6260719534120691,-0.6382215020124622,0.6466898283142365,144141,144141,393,180,0.37392804658793083,0.0,0,0.0015832996673948926,1021,0.03213198354738327,0.9551102948112882
|
||||
smart_frequency,393,smart,0.8,frequency,5,1,60,-0.8560364583878233,-0.8569216250940712,0.9012703988576707,144141,144141,393,180,0.14396354161217678,0.0,0,0.001591645035930818,1021,0.02648383303861127,0.9553405361507825
|
||||
smart_frequency,393,smart,0.8,frequency,5,5,30,-0.25248001845555734,-0.3017019307501775,0.17415779155886835,144141,144141,393,335,0.7475199815444427,0.0,0,0.0017884274675092886,1226,0.036765415236826714,0.8917237424363407
|
||||
smart_frequency,393,smart,0.8,frequency,5,5,60,-0.38262586252815045,-0.4100924112228478,0.31883118984696346,144141,144141,393,335,0.6173741374718495,0.0,0,0.0017886023146365451,1226,0.03336919793279328,0.8918366249659903
|
||||
smart_frequency,393,smart,0.8,frequency,5,10,30,-0.2093060116873786,-0.27046706459714964,0.08908519512154614,144141,144139,393,380,0.7905330980680049,0.00016089024461650645,2,0.001998574828354511,1456,0.03981409605969724,0.8724045873197258
|
||||
smart_frequency,393,smart,0.8,frequency,5,10,60,-0.28154529032148035,-0.31459639075975887,0.17025485702720367,144141,144139,393,380,0.7183083893155798,0.0001463203629398686,2,0.0019992142140446757,1456,0.037831888991662906,0.8723820369202632
|
||||
smart_both,414,smart,0.8,both,5,1,30,-0.6278945037688057,-0.6432105517780546,0.6545773630500094,37667,37667,80,38,0.3721054962311943,0.0,0,0.008234796201918616,372,0.030110428147570038,0.9972135350730296
|
||||
smart_both,414,smart,0.8,both,5,1,60,-0.8568225634756353,-0.858983139645346,0.9116079554022045,37667,37667,80,38,0.14317743652436463,0.0,0,0.008231823696802983,372,0.024844617187247606,0.9975136705430767
|
||||
smart_both,414,smart,0.8,both,5,5,30,-0.26450836714120807,-0.3063879363110269,0.17447541661945304,37667,37667,80,85,0.7354916328587919,0.0,0,0.006955525521546635,613,0.03827708563496218,0.9334989617649255
|
||||
smart_both,414,smart,0.8,both,5,5,60,-0.3925678922258372,-0.4182526024138189,0.3194223879727356,37667,37667,80,85,0.6074321077741628,0.0,0,0.006957114847596221,613,0.03693178665083859,0.9335935381265954
|
||||
smart_both,414,smart,0.8,both,5,10,30,-0.21163158290767492,-0.2652089765531309,0.08989488666789257,37667,37665,80,98,0.7878066629445245,0.0005617541478005915,2,0.006811023938043023,897,0.038079306781836686,0.8870181403133945
|
||||
smart_both,414,smart,0.8,both,5,10,60,-0.2837098522142023,-0.3178979839918541,0.17178673290006433,37667,37665,80,98,0.7157793060272591,0.0005108417585385517,2,0.00681235718037254,897,0.03744229355396881,0.8869964510125817
|
||||
universe,1,total,0.5,frequency,0,1,30,-0.635299125194791,-0.6469393854033088,0.6236005758764631,768268,768266,2357,1037,0.36470087480520896,0.0,2,0.00029265026593169267,4947,0.04047897523182674,0.9061361823871565
|
||||
universe,1,total,0.5,frequency,0,1,60,-0.8595767599364622,-0.8603580499378188,0.8737439514503567,768268,768266,2357,1037,0.1404232400635378,0.0,2,0.00029261216107530797,4947,0.03336765331803786,0.9063051315251788
|
||||
universe,1,total,0.5,frequency,0,5,30,-0.2629323802771075,-0.32112558033650584,0.16820767806351614,768268,768255,2357,1813,0.736977438330627,9.018139226549385e-05,13,0.00036513992511248786,4952,0.04636788505538143,0.8627587806537893
|
||||
universe,1,total,0.5,frequency,0,5,60,-0.39124642380833197,-0.41560363788665045,0.3081521107943667,768268,768255,2357,1813,0.6086789125371792,7.466365448886053e-05,13,0.0003652796675147956,4952,0.044738897137398405,0.8628599492321026
|
||||
universe,1,total,0.5,frequency,0,10,30,-0.2134406249755203,-0.27975927518826627,0.0863638174946772,768268,768234,2357,1888,0.7863305547575068,0.000228820266972904,34,0.00042598591633118794,4953,0.04629073438390506,0.8402173548137901
|
||||
universe,1,total,0.5,frequency,0,10,60,-0.28531410097076615,-0.319309541289727,0.1650932066786571,768268,768234,2357,1888,0.7144775427516084,0.00020835627762554108,34,0.0004261292331022441,4953,0.045536916270033666,0.8402084478904
|
||||
|
|
|
@ -0,0 +1,297 @@
|
|||
{
|
||||
"environment": "开发机,经unit_test_guard隔离配置、断网运行",
|
||||
"memory_tests": 9,
|
||||
"raw_window_checks": 1200,
|
||||
"all_threshold_count_prefix_exact": true,
|
||||
"prior_baseline_checks": [
|
||||
{
|
||||
"score": "total",
|
||||
"hold": 1,
|
||||
"error": 8.153200337090993e-17
|
||||
},
|
||||
{
|
||||
"score": "smart",
|
||||
"hold": 1,
|
||||
"error": 7.892991815694472e-17
|
||||
},
|
||||
{
|
||||
"score": "total",
|
||||
"hold": 5,
|
||||
"error": 3.3285006695304986e-17
|
||||
},
|
||||
{
|
||||
"score": "smart",
|
||||
"hold": 5,
|
||||
"error": 5.5185890579512176e-17
|
||||
},
|
||||
{
|
||||
"score": "total",
|
||||
"hold": 10,
|
||||
"error": 1.214306433183765e-17
|
||||
},
|
||||
{
|
||||
"score": "smart",
|
||||
"hold": 10,
|
||||
"error": 6.852157730108388e-17
|
||||
}
|
||||
],
|
||||
"index_actual_exit_checks": [
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "current",
|
||||
"index": "csi300",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "current",
|
||||
"index": "csi500",
|
||||
"error": 6.938893903907228e-18
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "current",
|
||||
"index": "csi1000",
|
||||
"error": 6.938893903907228e-18
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "current",
|
||||
"index": "csi2000",
|
||||
"error": 3.469446951953614e-18
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "frequency",
|
||||
"index": "csi300",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "frequency",
|
||||
"index": "csi500",
|
||||
"error": 1.0408340855860843e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "frequency",
|
||||
"index": "csi1000",
|
||||
"error": 8.673617379884035e-18
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "frequency",
|
||||
"index": "csi2000",
|
||||
"error": 5.204170427930421e-18
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "both",
|
||||
"index": "csi300",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "both",
|
||||
"index": "csi500",
|
||||
"error": 6.938893903907228e-18
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "both",
|
||||
"index": "csi1000",
|
||||
"error": 6.938893903907228e-18
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"mode": "both",
|
||||
"index": "csi2000",
|
||||
"error": 3.469446951953614e-18
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "current",
|
||||
"index": "csi300",
|
||||
"error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "current",
|
||||
"index": "csi500",
|
||||
"error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "current",
|
||||
"index": "csi1000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "current",
|
||||
"index": "csi2000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "frequency",
|
||||
"index": "csi300",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "frequency",
|
||||
"index": "csi500",
|
||||
"error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "frequency",
|
||||
"index": "csi1000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "frequency",
|
||||
"index": "csi2000",
|
||||
"error": 6.938893903907228e-18
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "both",
|
||||
"index": "csi300",
|
||||
"error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "both",
|
||||
"index": "csi500",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "both",
|
||||
"index": "csi1000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"mode": "both",
|
||||
"index": "csi2000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "current",
|
||||
"index": "csi300",
|
||||
"error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "current",
|
||||
"index": "csi500",
|
||||
"error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "current",
|
||||
"index": "csi1000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "current",
|
||||
"index": "csi2000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "frequency",
|
||||
"index": "csi300",
|
||||
"error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "frequency",
|
||||
"index": "csi500",
|
||||
"error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "frequency",
|
||||
"index": "csi1000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "frequency",
|
||||
"index": "csi2000",
|
||||
"error": 1.9081958235744878e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "both",
|
||||
"index": "csi300",
|
||||
"error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "both",
|
||||
"index": "csi500",
|
||||
"error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "both",
|
||||
"index": "csi1000",
|
||||
"error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"mode": "both",
|
||||
"index": "csi2000",
|
||||
"error": 2.0816681711721685e-17
|
||||
}
|
||||
],
|
||||
"event_exit_truncation_holds": [
|
||||
1,
|
||||
5,
|
||||
10
|
||||
],
|
||||
"ledger_rebuilds": [
|
||||
{
|
||||
"mode": "current",
|
||||
"trades": 174298,
|
||||
"error": 5.440092820663267e-14
|
||||
},
|
||||
{
|
||||
"mode": "frequency",
|
||||
"trades": 288282,
|
||||
"error": 6.417089082333405e-14
|
||||
},
|
||||
{
|
||||
"mode": "both",
|
||||
"trades": 75334,
|
||||
"error": 1.6230072841239007e-14
|
||||
}
|
||||
],
|
||||
"event_rebuilds": [
|
||||
{
|
||||
"mode": "current",
|
||||
"completed": 87149,
|
||||
"mean_net30": -0.008764926565963416
|
||||
},
|
||||
{
|
||||
"mode": "frequency",
|
||||
"completed": 144141,
|
||||
"mean_net30": -0.00837378943485991
|
||||
},
|
||||
{
|
||||
"mode": "both",
|
||||
"completed": 37667,
|
||||
"mean_net30": -0.008807958089399392
|
||||
}
|
||||
],
|
||||
"window_example_signal_date": "2026-08-31",
|
||||
"window_example_stocks": 3
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
"""真实快照的独立计数、基线、指数区间及逐笔现金核查;断网执行。"""
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from common import *
|
||||
from engine import future_exits,account
|
||||
|
||||
def main():
|
||||
sys.addaudithook(offline);p,panel,f,cov=load();dates=panel['dates'];t,n=panel['open'].shape;cfg=configuration();rng=np.random.default_rng(20261029)
|
||||
frequency_checks=0
|
||||
for group,key in enumerate(f['group_keys']):
|
||||
field,q=key.split(':');q=float(q)
|
||||
for _ in range(100):
|
||||
day=int(rng.integers(20,t));stock=int(rng.integers(n));actual=int(np.sum(panel[field][day-20:day,stock]>=q));assert actual==f['counts'][group,day,stock];frequency_checks+=1
|
||||
stop=int(np.searchsorted(dates,'2026-01-01'))
|
||||
for group,key in enumerate(f['group_keys']):
|
||||
field,q=key.split(':');short=previous_counts(panel[field][:stop]>=float(q));assert np.array_equal(short,f['counts'][group,:stop])
|
||||
# 验证旧单因子基线:恢复旧信号窗口后应精确得到上轮结果。
|
||||
old=pd.read_csv(PREVIOUS/'grid.csv');oldwindow=(dates>='2025-01-02')&(dates<='2026-09-30');oldchecks=[];indexchecks=[]
|
||||
for h in [1,5,10]:
|
||||
ex,gr=future_exits(panel,h);d=np.load(ROOT/f'cache/daily_{h:02}.npz')
|
||||
for field in ['total','smart']:
|
||||
mask=panel['eligible']&oldwindow[:,None]&(panel[field]>=.8)&np.isfinite(gr)
|
||||
daily=divide(np.where(mask,gr*.997/1.003-1,0).sum(1),mask.sum(1));observed=float(mean(daily))
|
||||
row=old[(old.total==(.8 if field=='total' else 0))&(old.smart==(.8 if field=='smart' else 0))&(old.hold==h)&(old.period=='full')&(old.regime==99)&(old.regime_index=='regime300')&(old.fee_bps==30)].iloc[0]
|
||||
assert abs(observed-row.mean_net)<1e-12;assert mask.sum()==row.completed;oldchecks.append({'score':field,'hold':h,'error':abs(observed-row.mean_net)})
|
||||
for c in [c for c in cfg if c['score']=='smart' and c['threshold']==.8 and (c['mode']=='current' or c['k']==5)]:
|
||||
mask=mask_for(panel,f,c)&np.isfinite(gr)
|
||||
for name,op in zip(f['index_names'],f['index_opens']):
|
||||
# 按实际退出日逐只取指数,不使用计划退出日替代被阻止的卖出。
|
||||
values=np.full((t,n),np.nan)
|
||||
for day in np.flatnonzero(mask.any(1)):
|
||||
stocks=np.flatnonzero(mask[day]);values[day,stocks]=gr[day,stocks]-op[ex[day,stocks]]/op[day+1]
|
||||
direct=divide(np.nansum(values,axis=1),mask.sum(1));saved=d['excess_'+str(name)][:,c['config']]
|
||||
err=float(np.nanmax(np.abs(direct-saved)));assert err<1e-12;indexchecks.append({'hold':h,'mode':c['mode'],'index':str(name),'error':err})
|
||||
# 真正截断日期,保留截至截断日已经退出的同一批次,核验收益标签。
|
||||
short={key:values[:stop] if key!='codes' else values for key,values in panel.items()};sx,sg=future_exits(short,h)
|
||||
valid=np.isfinite(gr[:stop])&(ex[:stop]<stop)
|
||||
assert np.array_equal(np.isfinite(sg),valid);assert np.allclose(sg[valid],gr[:stop][valid])
|
||||
ledgerchecks=[];eventchecks=[]
|
||||
for c in [c for c in cfg if c['score']=='smart' and c['threshold']==.8 and (c['mode']=='current' or c['k']==5)]:
|
||||
mask=mask_for(panel,f,c)&(dates>='2026-01-01')[:,None];aa=account(panel,mask,5,.003,detail=True)
|
||||
byday=defaultdict(list);legs=defaultdict(dict)
|
||||
for tr in aa['journal']:byday[tr['day']].append(tr);legs[tr['signal'],tr['stock']][tr['side']]=tr
|
||||
cash=1.;quantities=np.zeros(n);err=0.
|
||||
for i,row in enumerate(aa['daily']):
|
||||
for tr in byday[i]:
|
||||
j=tr['stock'];value=tr['qty']*tr['price'];assert tr['price']==panel['open'][i,j]
|
||||
if tr['side']=='buy':assert i==tr['signal']+1 and panel['can_buy'][i,j];cash-=value*1.003;quantities[j]+=tr['qty']
|
||||
else:assert i>=tr['signal']+6 and panel['can_sell'][i,j];cash+=value*.997;quantities[j]-=tr['qty']
|
||||
assert cash>=-1e-10 and quantities[j]>=-1e-10
|
||||
value=float(quantities@panel['mark'][i]);err=max(err,abs(cash-row['cash']),abs(value-row['stock_value']),abs(cash+value-row['nav']))
|
||||
assert err<1e-10;ledgerchecks.append({'mode':c['mode'],'trades':len(aa['journal']),'error':err})
|
||||
batches=defaultdict(list)
|
||||
for (sig,j),tr in legs.items():
|
||||
if 'sell' in tr:batches[sig].append(tr['sell']['price']/tr['buy']['price']*.997/1.003-1)
|
||||
dd=np.load(ROOT/'cache/daily_05.npz');expected=mean((dd['gross'][:,c['config']][dates>='2026-01-01']+1)*.997/1.003-1)
|
||||
observed=np.mean([np.mean(v) for v in batches.values()]);assert abs(expected-observed)<1e-12
|
||||
eventchecks.append({'mode':c['mode'],'completed':sum(map(len,batches.values())),'mean_net30':float(observed)})
|
||||
print(c['mode'],'独立逐笔重建完成',flush=True)
|
||||
# 一个事先指定日期的窗口明细,按股票代码顺序展示3只,而非按收益选例。
|
||||
day=int(np.where(dates=='2026-08-31')[0][0]);group=list(f['group_keys']).index('smart:0.8');chosen=np.flatnonzero(f['base'][day]&(f['counts'][group,day]>=5))[:3];trace=[]
|
||||
for stock in chosen:
|
||||
for j in range(day-20,day):trace.append({'signal_date':str(dates[day]),'stock':str(panel['codes'][stock]),'historical_date':str(dates[j]),'smart_score':float(panel['smart'][j,stock]),'hit_ge_0_8':bool(panel['smart'][j,stock]>=.8),'prior20_hits':int(f['counts'][group,day,stock]),'signal_day_score':float(panel['smart'][day,stock])})
|
||||
pd.DataFrame(trace).to_csv(ROOT/'window_examples.csv',index=False,lineterminator='\n')
|
||||
dump(ROOT/'audit.json',{'environment':'开发机,经unit_test_guard隔离配置、断网运行','memory_tests':9,'raw_window_checks':frequency_checks,'all_threshold_count_prefix_exact':True,'prior_baseline_checks':oldchecks,'index_actual_exit_checks':indexchecks,'event_exit_truncation_holds':[1,5,10],'ledger_rebuilds':ledgerchecks,'event_rebuilds':eventchecks,'window_example_signal_date':'2026-08-31','window_example_stocks':len(chosen)})
|
||||
print('全部审计通过',frequency_checks,'次直接20日计数;',len(indexchecks),'项指数区间检查')
|
||||
if __name__=='__main__':main()
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
"""只打开本地研究HTML并阻断外部请求;不访问任何线上业务页面。"""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import pandas as pd
|
||||
from playwright.sync_api import sync_playwright
|
||||
from common import ROOT,dump
|
||||
|
||||
def main():
|
||||
errors=[];external=[];checks=[];grid=pd.read_csv(ROOT/'grid.csv.gz');out=ROOT/'cache';out.mkdir(exist_ok=True)
|
||||
with sync_playwright() as p:
|
||||
browser=p.chromium.launch(executable_path='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',headless=True)
|
||||
context=browser.new_context(viewport={'width':1600,'height':1200},device_scale_factor=1,accept_downloads=True)
|
||||
def route(req):
|
||||
if req.request.url.startswith(('file:','data:','blob:')):req.continue_()
|
||||
else:external.append(req.request.url.split('?')[0]);req.abort()
|
||||
context.route('**/*',route);page=context.new_page();page.on('pageerror',lambda err:errors.append(str(err)))
|
||||
page.goto((ROOT/'反复活跃矩阵浏览器.html').as_uri(),wait_until='load');page.wait_for_function('window.__dashboardReady===true',timeout=30000)
|
||||
assert page.locator('canvas').count()==2;assert page.locator('#details tr').count()==20
|
||||
observed=page.evaluate("getDisplayedCell('2026',.8,5,5)")
|
||||
row=grid[(grid.score=='smart')&(grid.threshold==.8)&(grid['mode']=='frequency')&(grid.k==5)&(grid.hold==5)&(grid.period=='2026')&(grid.phase_index=='all')].iloc[0]
|
||||
assert abs(observed[1]-row.mean_net30)<1e-9;checks.append('默认2025/2026两矩阵、20行持有期表与源数据一致')
|
||||
coords=page.evaluate('({x:charts[0].scales.x.getPixelForValue(4),y:charts[0].scales.y.getPixelForValue(10)})')
|
||||
box=page.locator('canvas').first.bounding_box();page.mouse.click(box['x']+coords['x'],box['y']+coords['y'])
|
||||
assert '10次' in page.locator('#detail-title').inner_text();checks.append('点击K=10、H=5格后,1至10日明细切换成功')
|
||||
page.screenshot(path=str(out/'dashboard-default.png'),full_page=True)
|
||||
with page.expect_download() as download:page.locator('#download-csv').click()
|
||||
path=download.value.path();data=pd.read_csv(path);assert len(data)==420;checks.append('默认420格CSV导出成功')
|
||||
page.locator('#preset-current').click();page.wait_for_function("window.__dashboardState.mode==='current' && window.__dashboardState.view==='threshold_hold'");assert page.locator('#threshold').is_disabled();checks.append('单日分数切换成功')
|
||||
page.select_option('#mode','both');page.select_option('#view','threshold_count');page.select_option('#hold','10');page.select_option('#stage','-1');page.select_option('#phase_index','csi500');page.select_option('#metric','index_excess');page.select_option('#benchmark','csi1000');page.select_option('#period','2026')
|
||||
page.wait_for_function("window.__dashboardState.mode==='both'&&window.__dashboardState.view==='threshold_count'&&window.__dashboardState.hold==='10'&&window.__dashboardState.stage==='-1'&&window.__dashboardState.phase_index==='csi500'&&window.__dashboardState.metric==='index_excess'&&window.__dashboardState.benchmark==='csi1000'&&window.__dashboardState.period==='2026'")
|
||||
observed=page.evaluate("getDisplayedCell('2026',.8,5,10)")
|
||||
row=grid[(grid.score=='smart')&(grid.threshold==.8)&(grid['mode']=='both')&(grid.k==5)&(grid.hold==10)&(grid.period=='2026')&(grid.phase_index=='csi500')&(grid.stage==-1)].iloc[0]
|
||||
assert abs(observed[15]-row.excess_csi1000)<1e-9;assert page.locator('canvas').count()==1
|
||||
displayed=page.evaluate("charts[0].data.datasets[0].data.find(p=>p.q===.8&&p.k===5&&p.h===10).z")
|
||||
assert abs(displayed-(row.excess_csi1000+row.mean_net30-row.mean_gross))<1e-9
|
||||
checks.append('阶段指数与收益指数可独立选择,阈值×次数矩阵一致')
|
||||
with page.expect_download() as download:page.locator('[data-download="0"]').click()
|
||||
download.value.save_as(out/'dashboard-export.png');assert (out/'dashboard-export.png').stat().st_size>10000;checks.append('PNG导出成功')
|
||||
page.screenshot(path=str(out/'dashboard-index.png'),full_page=True)
|
||||
page.set_viewport_size({'width':430,'height':932});page.screenshot(path=str(out/'dashboard-mobile.png'),full_page=True)
|
||||
# 手机可水平滚动图表,页面整体不应越出视口。
|
||||
overflow=page.evaluate('document.documentElement.scrollWidth>window.innerWidth');assert not overflow;checks.append('430像素视口无页面级横向溢出')
|
||||
assert not errors,errors;assert not external,external
|
||||
browser.close()
|
||||
dump(ROOT/'browser_checks.json',{'browser':'本机Google Chrome,无头模式,独立临时上下文','external_requests':external,'page_errors':errors,'checks':checks,'data_comparisons_tolerance':1e-9,'screenshots':'cache/dashboard-*.png(不入Git)'})
|
||||
print('浏览器验收通过',len(checks),'项;外部请求0')
|
||||
if __name__=='__main__':main()
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"browser": "本机Google Chrome,无头模式,独立临时上下文",
|
||||
"external_requests": [],
|
||||
"page_errors": [],
|
||||
"checks": [
|
||||
"默认2025/2026两矩阵、20行持有期表与源数据一致",
|
||||
"点击K=10、H=5格后,1至10日明细切换成功",
|
||||
"默认420格CSV导出成功",
|
||||
"单日分数切换成功",
|
||||
"阶段指数与收益指数可独立选择,阈值×次数矩阵一致",
|
||||
"PNG导出成功",
|
||||
"430像素视口无页面级横向溢出"
|
||||
],
|
||||
"data_comparisons_tolerance": 1e-09,
|
||||
"screenshots": "cache/dashboard-*.png(不入Git)"
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
"""把分组结果分块嵌入独立HTML;浏览器只解压当前筛选,无联网请求。"""
|
||||
import base64,gzip,json,sys
|
||||
import pandas as pd
|
||||
from common import ROOT,dump,digest,offline
|
||||
COLUMNS=['mean_gross','mean_net30','mean_net60','win30','active_days','completed','mean_selected','filled','unresolved','delayed','delta_k0_net30','delta_current_net30','delta_universe_net30','excess_csi300','excess_csi500','excess_csi1000','excess_csi2000']
|
||||
def main():
|
||||
sys.addaudithook(offline);g=pd.read_csv(ROOT/'grid.csv.gz');payload={}
|
||||
for key,z in g.groupby(['score','period','phase_index','stage']):
|
||||
z=z.sort_values(['config','hold']);assert len(z)==2580
|
||||
raw=z[COLUMNS].to_json(orient='values',double_precision=10).encode();payload['|'.join(map(str,key))]=base64.b64encode(gzip.compress(raw,mtime=0)).decode()
|
||||
chart=(ROOT/'vendor/chart.umd.js').read_text();expected='jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ'
|
||||
import hashlib
|
||||
assert base64.b64encode(hashlib.sha384(chart.encode()).digest()).decode()==expected
|
||||
html=(ROOT/'dashboard.html.tpl').read_text().replace('/*__CHARTJS__*/',chart).replace('/*__PAYLOAD__*/',json.dumps(payload,separators=(',',':')))
|
||||
assert '<script src=' not in html
|
||||
dest=ROOT/'反复活跃矩阵浏览器.html';dest.write_text(html)
|
||||
dump(ROOT/'dashboard_manifest.json',{'chunks':len(payload),'rows_per_chunk':2580,'columns':COLUMNS,'html_bytes':dest.stat().st_size,'html_sha256':digest(dest),'chartjs_version':'4.5.1','chartjs_sha384':expected,'external_runtime_requests':0,'data_source':'grid.csv.gz','data_source_sha256':digest(ROOT/'grid.csv.gz'),'default':'smart>=0.8,历史频次,2025/2026并排,30基点,全部阶段'})
|
||||
print('独立矩阵浏览器',dest.stat().st_size,'字节;',len(payload),'个按需本地分块')
|
||||
if __name__=='__main__':main()
|
||||
|
|
@ -0,0 +1,862 @@
|
|||
{
|
||||
"grid_rows": 201240,
|
||||
"combinations": 5160,
|
||||
"k0_identities": "全部12组阈值、10个持有期通过;无门槛历史池一致,both K0=current",
|
||||
"direct_mask_checks": [
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "total:0.5",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "total:0.6",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "total:0.7",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "total:0.8",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "total:0.9",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "total:0.95",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 1.0408340855860843e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 1,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "total:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "total:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "total:0.7",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "total:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "total:0.9",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "total:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 2,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "total:0.5",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "total:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "total:0.7",
|
||||
"max_error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "total:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "total:0.9",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "total:0.95",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 3,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 1.3877787807814457e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "total:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "total:0.6",
|
||||
"max_error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "total:0.7",
|
||||
"max_error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "total:0.8",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "total:0.9",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "total:0.95",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 3.469446951953614e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 4,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "total:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "total:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "total:0.7",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "total:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "total:0.9",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "total:0.95",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 5,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.0816681711721685e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "total:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "total:0.6",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "total:0.7",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "total:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "total:0.9",
|
||||
"max_error": 8.326672684688674e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "total:0.95",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 6,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "total:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "total:0.6",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "total:0.7",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "total:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "total:0.9",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "total:0.95",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 7,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "total:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "total:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "total:0.7",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "total:0.8",
|
||||
"max_error": 8.326672684688674e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "total:0.9",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "total:0.95",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 8,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "total:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "total:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "total:0.7",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "total:0.8",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "total:0.9",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "total:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 9,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "total:0.5",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "total:0.6",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "total:0.7",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "total:0.8",
|
||||
"max_error": 8.326672684688674e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "total:0.9",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "total:0.95",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "smart:0.5",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "smart:0.6",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "smart:0.7",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "smart:0.8",
|
||||
"max_error": 4.163336342344337e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "smart:0.9",
|
||||
"max_error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"hold": 10,
|
||||
"group": "smart:0.95",
|
||||
"max_error": 2.7755575615628914e-17
|
||||
}
|
||||
],
|
||||
"account_checks": [
|
||||
{
|
||||
"name": "total_current",
|
||||
"hold": 1,
|
||||
"fee_bps": 30,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "total_current",
|
||||
"hold": 1,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "total_current",
|
||||
"hold": 5,
|
||||
"fee_bps": 30,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "total_current",
|
||||
"hold": 5,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_current",
|
||||
"hold": 10,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_current",
|
||||
"hold": 10,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_frequency",
|
||||
"hold": 1,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_frequency",
|
||||
"hold": 1,
|
||||
"fee_bps": 60,
|
||||
"error": 3.2255014631443757e-17
|
||||
},
|
||||
{
|
||||
"name": "total_frequency",
|
||||
"hold": 5,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_frequency",
|
||||
"hold": 5,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "total_frequency",
|
||||
"hold": 10,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_frequency",
|
||||
"hold": 10,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_both",
|
||||
"hold": 1,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_both",
|
||||
"hold": 1,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "total_both",
|
||||
"hold": 5,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_both",
|
||||
"hold": 5,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "total_both",
|
||||
"hold": 10,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "total_both",
|
||||
"hold": 10,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_current",
|
||||
"hold": 1,
|
||||
"fee_bps": 30,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_current",
|
||||
"hold": 1,
|
||||
"fee_bps": 60,
|
||||
"error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"name": "smart_current",
|
||||
"hold": 5,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_current",
|
||||
"hold": 5,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_current",
|
||||
"hold": 10,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_current",
|
||||
"hold": 10,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_frequency",
|
||||
"hold": 1,
|
||||
"fee_bps": 30,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_frequency",
|
||||
"hold": 1,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_frequency",
|
||||
"hold": 5,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_frequency",
|
||||
"hold": 5,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_frequency",
|
||||
"hold": 10,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_frequency",
|
||||
"hold": 10,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_both",
|
||||
"hold": 1,
|
||||
"fee_bps": 30,
|
||||
"error": 0.0
|
||||
},
|
||||
{
|
||||
"name": "smart_both",
|
||||
"hold": 1,
|
||||
"fee_bps": 60,
|
||||
"error": 5.551115123125783e-17
|
||||
},
|
||||
{
|
||||
"name": "smart_both",
|
||||
"hold": 5,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_both",
|
||||
"hold": 5,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_both",
|
||||
"hold": 10,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "smart_both",
|
||||
"hold": 10,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "universe",
|
||||
"hold": 1,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "universe",
|
||||
"hold": 1,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "universe",
|
||||
"hold": 5,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "universe",
|
||||
"hold": 5,
|
||||
"fee_bps": 60,
|
||||
"error": 1.1102230246251565e-16
|
||||
},
|
||||
{
|
||||
"name": "universe",
|
||||
"hold": 10,
|
||||
"fee_bps": 30,
|
||||
"error": 2.220446049250313e-16
|
||||
},
|
||||
{
|
||||
"name": "universe",
|
||||
"hold": 10,
|
||||
"fee_bps": 60,
|
||||
"error": 2.220446049250313e-16
|
||||
}
|
||||
],
|
||||
"account_prefix_check": "全部21条30bp主账户前半段与截断计算逐日一致"
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
"""全部频次、门槛、持有期与市场分组;不按事后冠军选账户。"""
|
||||
import sys
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from common import *
|
||||
from engine import future_exits,account
|
||||
|
||||
def slices(dates,features):
|
||||
out=[]
|
||||
for period in ['2025','2026','full']:
|
||||
period_mask=features['window'] if period=='full' else features['window']&np.char.startswith(dates,period)
|
||||
out.append((period,'all',99,period_mask))
|
||||
for ix,index in enumerate(features['index_names']):
|
||||
for stage in [-1,0,1]:out.append((period,str(index),stage,period_mask&(features['stages'][ix]==stage)))
|
||||
return out
|
||||
|
||||
def main():
|
||||
sys.addaudithook(offline);p,panel,f,cov=load();dates=panel['dates'];t,n=panel['open'].shape;base=f['base'];configs=configuration();nc=len(configs);n_groups=len(f['group_keys'])
|
||||
ids=[];selected=[];filled=[];can_buy=np.vstack([panel['can_buy'][1:],np.zeros((1,n),bool)])
|
||||
for group,key in enumerate(f['group_keys']):
|
||||
field,q=key.split(':');q=float(q);hit=panel[field]>=q
|
||||
bucket=np.arange(t,dtype=np.int32)[:,None]*42+hit.astype(np.int32)*21+np.maximum(f['counts'][group],0)
|
||||
ids.append(bucket);selected.append(aggregate(bucket,base,None,t));filled.append(aggregate(bucket,base&can_buy,None,t))
|
||||
selected=np.concatenate(selected,axis=1);filled=np.concatenate(filled,axis=1)
|
||||
cfg=pd.DataFrame(configs);sl=slices(dates,f);all_rows=[];checks=[];daily_dir=ROOT/'cache'
|
||||
control=np.array([c['config']//43*43+(1 if c['mode']=='frequency' else 0) for c in configs])
|
||||
current=np.array([c['config']//43*43 for c in configs]);universe=np.array([c['config']//43*43+1 for c in configs])
|
||||
for h in p['holds']:
|
||||
exits,gross=future_exits(panel,h);ok=base&np.isfinite(gross);gr=gross-1
|
||||
fields={'completed':[],'gross':[],'wins30':[],'delayed':[]}
|
||||
for index in f['index_names']:fields['excess_'+str(index)]=[]
|
||||
ix_excess=[]
|
||||
# 比较各股票实际持有区间的指数开盘收益,卖出延期不偷偷截回计划日。
|
||||
for op in f['index_opens']:
|
||||
benchmark=op[np.maximum(exits,0)]/np.r_[op[1:],np.nan][:,None]-1
|
||||
ix_excess.append(gr-benchmark)
|
||||
for group,bucket in enumerate(ids):
|
||||
cc=aggregate(bucket,ok,None,t);fields['completed'].append(cc)
|
||||
fields['gross'].append(divide(aggregate(bucket,ok,gr,t),cc))
|
||||
fields['wins30'].append(aggregate(bucket,ok,gross*.997/1.003>1,t))
|
||||
fields['delayed'].append(aggregate(bucket,ok&(exits>np.arange(t)[:,None]+h+1),None,t))
|
||||
for index,values in zip(f['index_names'],ix_excess):fields['excess_'+str(index)].append(divide(aggregate(bucket,ok,values,t),cc))
|
||||
d={k:np.concatenate(values,axis=1) for k,values in fields.items()};d['selected']=selected;d['filled']=filled
|
||||
np.savez_compressed(daily_dir/f'daily_{h:02}.npz',**d)
|
||||
for period,index,stage,dd in sl:
|
||||
v=d['gross'][dd];cc=d['completed'][dd];ntr=cc.sum(0)
|
||||
z=cfg.copy();z['hold']=h;z['period']=period;z['phase_index']=index;z['stage']=stage;z['phase_days']=int(dd.sum())
|
||||
z['active_days']=np.sum(cc>0,axis=0);z['selected']=selected[dd].sum(0).astype(int);z['mean_selected']=selected[dd].mean(0)
|
||||
z['filled']=filled[dd].sum(0).astype(int);z['completed']=ntr.astype(int);z['unresolved']=(filled[dd].sum(0)-ntr).astype(int);z['delayed']=d['delayed'][dd].sum(0).astype(int)
|
||||
z['mean_gross']=mean(v);z['mean_net30']=(z['mean_gross']+1)*.997/1.003-1;z['mean_net60']=(z['mean_gross']+1)*.994/1.006-1
|
||||
z['win30']=divide(d['wins30'][dd].sum(0),ntr)
|
||||
z['delta_k0_net30']=mean(v-v[:,control])*.997/1.003;z['delta_current_net30']=mean(v-v[:,current])*.997/1.003;z['delta_universe_net30']=mean(v-v[:,universe])*.997/1.003
|
||||
z['paired_days']=np.sum(np.isfinite(v-v[:,control]),axis=0)
|
||||
for key in ['csi300','csi500','csi1000','csi2000']:z['excess_'+key]=mean(d['excess_'+key][dd])
|
||||
z['supported']=(z.active_days>=20)&(z.completed>=100)
|
||||
all_rows.append(z)
|
||||
# K=0条件是本实验的恒等式,覆盖每一分数阈值与持有期。
|
||||
for group in range(n_groups):
|
||||
off=group*43;assert np.array_equal(d['completed'][:,off],d['completed'][:,off+22]);assert np.allclose(d['gross'][:,off],d['gross'][:,off+22],equal_nan=True,atol=1e-14)
|
||||
assert np.array_equal(d['completed'][:,1],d['completed'][:,off+1])
|
||||
# 对K=5直接逐股筛选,再独立等权计算,核对分桶累计没有错位。
|
||||
config=configs[off+6];mask=mask_for(panel,f,config)&np.isfinite(gross)
|
||||
direct=divide(np.where(mask,gr,0).sum(1),mask.sum(1))
|
||||
error=float(np.nanmax(np.abs(direct-d['gross'][:,off+6])))
|
||||
assert error<1e-12;checks.append({'hold':h,'group':str(f['group_keys'][group]),'max_error':error})
|
||||
print('持有',h,'日:516组条件、39种年份阶段分组完成',flush=True)
|
||||
grid=pd.concat(all_rows,ignore_index=True);grid.to_csv(ROOT/'grid.csv.gz',index=False,compression={'method':'gzip','mtime':0},lineterminator='\n')
|
||||
focus=grid[(grid.threshold==.8)&grid.k.isin([0,1,3,5,8,10,15,20])];focus.to_csv(ROOT/'focus_grid.csv',index=False,lineterminator='\n')
|
||||
accounts=[];curves=[];cashchecks=[]
|
||||
account_configs=[c for c in configs if c['threshold']==.8 and (c['mode']=='current' or c['k']==5)]
|
||||
# 无分数/频次门槛对照,其完整历史观察池与所有条件一致。
|
||||
account_configs.append(configs[1]);test=dates>='2026-01-01'
|
||||
for c in account_configs:
|
||||
mask=mask_for(panel,f,c)&test[:,None]
|
||||
for h in [1,5,10]:
|
||||
for fee in [30,60]:
|
||||
aa=account(panel,mask,h,fee/10000);cash=1.;err=0.
|
||||
for row in aa['daily']:
|
||||
err=max(err,abs(row['cash']-(cash+row['sell_cash']-row['buy_cash'])),abs(row['nav']-row['cash']-row['stock_value']));cash=row['cash'];assert cash>=-1e-12
|
||||
assert err<1e-10
|
||||
name='universe' if c['config']==1 else c['score']+'_'+c['mode']
|
||||
accounts.append({'name':name,**c,'hold':h,'fee_bps':fee,**aa['summary']})
|
||||
curves.extend({'name':name,'hold':h,'fee_bps':fee,**row} for row in aa['daily'])
|
||||
cashchecks.append({'name':name,'hold':h,'fee_bps':fee,'error':err})
|
||||
if fee==30:assert account(panel,mask,h,.003,stop=t//2)['daily']==aa['daily'][:t//2]
|
||||
print('预设账户',c['score'],c['mode'],c['k'],'完成',flush=True)
|
||||
pd.DataFrame(accounts).to_csv(ROOT/'accounts.csv',index=False,lineterminator='\n');pd.DataFrame(curves).to_csv(ROOT/'account_daily.csv.gz',index=False,compression={'method':'gzip','mtime':0},lineterminator='\n')
|
||||
dump(ROOT/'calculation_checks.json',{'grid_rows':len(grid),'combinations':5160,'k0_identities':'全部12组阈值、10个持有期通过;无门槛历史池一致,both K0=current','direct_mask_checks':checks,'account_checks':cashchecks,'account_prefix_check':'全部21条30bp主账户前半段与截断计算逐日一致'})
|
||||
print('计算完成',len(grid),'行分组结果,',len(accounts),'账户')
|
||||
if __name__=='__main__':main()
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
"""研究公共函数,仅处理离线缓存。"""
|
||||
import gzip,hashlib,json,sys
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
ROOT=Path(__file__).resolve().parent
|
||||
PREVIOUS=ROOT.parent/'signal_scores_20261028'
|
||||
OLD=ROOT.parent/'macro_timing_20261026'
|
||||
def read(path):
|
||||
with gzip.open(path,'rt') if str(path).endswith('.gz') else open(path) as f:return json.load(f)
|
||||
def dump(path,value):path.write_text(json.dumps(value,ensure_ascii=False,indent=2,allow_nan=False)+'\n')
|
||||
def digest(path):return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
def offline(event,args):
|
||||
if event in ('socket.connect','socket.getaddrinfo','socket.sendto','socket.sendmsg'):raise RuntimeError('离线研究禁止联网')
|
||||
def divide(a,b):return np.divide(a,b,out=np.full(np.broadcast_shapes(a.shape,b.shape),np.nan),where=b>0)
|
||||
def mean(a,axis=0):
|
||||
a=np.asarray(a);return divide(np.nansum(a,axis=axis),np.sum(np.isfinite(a),axis=axis))
|
||||
def previous_counts(hit,window=20):
|
||||
"""明确排除当天,前window个日历交易日不足则返回-1。"""
|
||||
c=np.vstack([np.zeros((1,hit.shape[1]),dtype=np.int32),np.cumsum(hit,axis=0,dtype=np.int32)])
|
||||
out=np.full(hit.shape,-1,dtype=np.int16)
|
||||
out[window:]=c[window:-1]-c[:-window-1]
|
||||
return out
|
||||
|
||||
def regime(rows,dates):
|
||||
series=pd.Series({r['timestamp'][:10]:float(r['close']) for r in rows}).sort_index()
|
||||
ma=series.rolling(60,min_periods=60).mean();r20=series/series.shift(20)-1
|
||||
stage=np.where((series>=ma)&(r20>0),1,np.where((series<ma)&(r20<0),-1,0))
|
||||
z=pd.DataFrame({'close':series,'ma60':ma,'return20':r20,'stage':stage})
|
||||
assert z.loc[dates,['close','ma60','return20']].notna().all().all()
|
||||
return z.loc[dates]
|
||||
|
||||
def aggregate(ids,valid,weights,t):
|
||||
"""按当天是否达标及历史达标次数分桶,再累加为>=K。"""
|
||||
x=np.bincount(ids[valid],weights=None if weights is None else weights[valid],minlength=t*42).reshape(t,2,21)
|
||||
x=x[:,:,::-1].cumsum(2)[:,:,::-1]
|
||||
return np.concatenate([x[:,1,:1],x.sum(1),x[:,1]],axis=1)
|
||||
def configuration():
|
||||
p=read(ROOT/'protocol.json');rows=[]
|
||||
for score in p['scores']:
|
||||
for threshold in p['thresholds']:
|
||||
for mode,ks in [('current',[0]),('frequency',range(21)),('both',range(21))]:
|
||||
for k in ks:rows.append({'config':len(rows),'score':score,'threshold':threshold,'mode':mode,'k':k})
|
||||
return rows
|
||||
|
||||
def load():
|
||||
p=read(ROOT/'protocol.json');cov=read(ROOT/'coverage.json')
|
||||
assert digest(ROOT/'protocol.json')==(ROOT/'protocol.sha256').read_text().split()[0]
|
||||
assert digest(PREVIOUS/'cache/panel.npz')==cov['source_sha256']['signal_scores_20261028/cache/panel.npz']
|
||||
panel=dict(np.load(PREVIOUS/'cache/panel.npz'));features=dict(np.load(ROOT/'cache/features.npz'))
|
||||
return p,panel,features,cov
|
||||
|
||||
def mask_for(panel,features,config):
|
||||
base=features['base'];field=config['score'];q=config['threshold'];mode=config['mode'];k=config['k']
|
||||
if mode=='current':return base&(panel[field]>=q)
|
||||
group=next(i for i,c in enumerate(features['group_keys']) if c==field+':'+str(q))
|
||||
mask=base&(features['counts'][group]>=k)
|
||||
return mask if mode=='frequency' else mask&(panel[field]>=q)
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
config,score,threshold,mode,k,period,hold,active_days,completed,unique_stocks,stock_signal_streaks,median_stocks_on_active_day,top5_event_share,largest_stock_event_share
|
||||
135,total,0.8,frequency,5,2025,5,229,430996,4740,23257,1883.0,0.0026566371845678383,0.0005313274369135677
|
||||
135,total,0.8,frequency,5,2026,5,160,289973,4624,16712,1824.5,0.0027588775506685106,0.0005517755101337021
|
||||
140,total,0.8,frequency,10,2025,5,229,81451,2907,8972,346.0,0.011896723183263557,0.0026887331033382035
|
||||
140,total,0.8,frequency,10,2026,5,160,73645,2798,7187,474.0,0.009084119763731415,0.0019281689184601806
|
||||
145,total,0.8,frequency,15,2025,5,229,6047,545,1010,26.0,0.07706300644947908,0.019348437241607407
|
||||
145,total,0.8,frequency,15,2026,5,160,8285,773,1294,48.0,0.035365117682558844,0.009776704888352444
|
||||
150,total,0.8,frequency,20,2025,5,57,104,10,12,2.0,0.8461538461538461,0.3173076923076923
|
||||
150,total,0.8,frequency,20,2026,5,38,71,20,20,1.0,0.5492957746478874,0.15492957746478872
|
||||
156,total,0.8,both,5,2025,5,229,130627,4569,77593,573.0,0.005519532715288569,0.001247827784454975
|
||||
156,total,0.8,both,5,2026,5,160,94613,4396,51723,587.5,0.005252977920581738,0.001099214695654931
|
||||
161,total,0.8,both,10,2025,5,229,34234,2469,17399,143.0,0.01846117894490857,0.004498451831512531
|
||||
161,total,0.8,both,10,2026,5,160,33065,2472,15357,203.0,0.012792983517314381,0.0027219113866626342
|
||||
166,total,0.8,both,15,2025,5,229,3521,427,1332,14.0,0.10252769099687589,0.026696961090599262
|
||||
166,total,0.8,both,15,2026,5,160,4894,631,1739,26.5,0.04372701266857376,0.011851246424192888
|
||||
171,total,0.8,both,20,2025,5,53,92,10,12,2.0,0.8913043478260869,0.34782608695652173
|
||||
171,total,0.8,both,20,2026,5,28,51,13,13,1.0,0.6666666666666666,0.19607843137254902
|
||||
393,smart,0.8,frequency,5,2025,5,229,194627,4038,12250,850.0,0.005230517862372641,0.0011406433845252714
|
||||
393,smart,0.8,frequency,5,2026,5,160,144141,4084,9496,913.5,0.004925732442538903,0.0010267723964728981
|
||||
398,smart,0.8,frequency,10,2025,5,229,28251,1612,3005,124.0,0.023326607907684684,0.005274149587625216
|
||||
398,smart,0.8,frequency,10,2026,5,160,28617,1882,2846,138.0,0.017262466366145996,0.0042282559317887965
|
||||
403,smart,0.8,frequency,15,2025,5,229,3223,253,378,11.0,0.09866583928017375,0.023890784982935155
|
||||
403,smart,0.8,frequency,15,2026,5,159,3585,406,481,8.0,0.06834030683403068,0.02287308228730823
|
||||
408,smart,0.8,frequency,20,2025,5,65,953,30,30,22.0,0.21091290661070305,0.04302203567681007
|
||||
408,smart,0.8,frequency,20,2026,5,52,115,34,36,2.0,0.3652173913043478,0.08695652173913043
|
||||
414,smart,0.8,both,5,2025,5,229,48328,3575,27463,207.0,0.010925343486177784,0.002545108425757325
|
||||
414,smart,0.8,both,5,2026,5,160,37667,3594,17035,224.0,0.01006185785966496,0.0026017468871956887
|
||||
419,smart,0.8,both,10,2025,5,229,11424,1276,5135,49.0,0.03720238095238095,0.008841036414565826
|
||||
419,smart,0.8,both,10,2026,5,160,10947,1547,4123,51.5,0.02850095916689504,0.008312779757011054
|
||||
424,smart,0.8,both,15,2025,5,228,2232,198,466,6.0,0.11155913978494623,0.026881720430107527
|
||||
424,smart,0.8,both,15,2026,5,156,1984,324,549,5.0,0.0967741935483871,0.03225806451612903
|
||||
429,smart,0.8,both,20,2025,5,63,926,30,30,22.0,0.21166306695464362,0.04319654427645788
|
||||
429,smart,0.8,both,20,2026,5,46,83,23,24,2.0,0.4578313253012048,0.10843373493975904
|
||||
|
|
|
@ -0,0 +1,517 @@
|
|||
config,score,threshold,mode,k
|
||||
0,total,0.5,current,0
|
||||
1,total,0.5,frequency,0
|
||||
2,total,0.5,frequency,1
|
||||
3,total,0.5,frequency,2
|
||||
4,total,0.5,frequency,3
|
||||
5,total,0.5,frequency,4
|
||||
6,total,0.5,frequency,5
|
||||
7,total,0.5,frequency,6
|
||||
8,total,0.5,frequency,7
|
||||
9,total,0.5,frequency,8
|
||||
10,total,0.5,frequency,9
|
||||
11,total,0.5,frequency,10
|
||||
12,total,0.5,frequency,11
|
||||
13,total,0.5,frequency,12
|
||||
14,total,0.5,frequency,13
|
||||
15,total,0.5,frequency,14
|
||||
16,total,0.5,frequency,15
|
||||
17,total,0.5,frequency,16
|
||||
18,total,0.5,frequency,17
|
||||
19,total,0.5,frequency,18
|
||||
20,total,0.5,frequency,19
|
||||
21,total,0.5,frequency,20
|
||||
22,total,0.5,both,0
|
||||
23,total,0.5,both,1
|
||||
24,total,0.5,both,2
|
||||
25,total,0.5,both,3
|
||||
26,total,0.5,both,4
|
||||
27,total,0.5,both,5
|
||||
28,total,0.5,both,6
|
||||
29,total,0.5,both,7
|
||||
30,total,0.5,both,8
|
||||
31,total,0.5,both,9
|
||||
32,total,0.5,both,10
|
||||
33,total,0.5,both,11
|
||||
34,total,0.5,both,12
|
||||
35,total,0.5,both,13
|
||||
36,total,0.5,both,14
|
||||
37,total,0.5,both,15
|
||||
38,total,0.5,both,16
|
||||
39,total,0.5,both,17
|
||||
40,total,0.5,both,18
|
||||
41,total,0.5,both,19
|
||||
42,total,0.5,both,20
|
||||
43,total,0.6,current,0
|
||||
44,total,0.6,frequency,0
|
||||
45,total,0.6,frequency,1
|
||||
46,total,0.6,frequency,2
|
||||
47,total,0.6,frequency,3
|
||||
48,total,0.6,frequency,4
|
||||
49,total,0.6,frequency,5
|
||||
50,total,0.6,frequency,6
|
||||
51,total,0.6,frequency,7
|
||||
52,total,0.6,frequency,8
|
||||
53,total,0.6,frequency,9
|
||||
54,total,0.6,frequency,10
|
||||
55,total,0.6,frequency,11
|
||||
56,total,0.6,frequency,12
|
||||
57,total,0.6,frequency,13
|
||||
58,total,0.6,frequency,14
|
||||
59,total,0.6,frequency,15
|
||||
60,total,0.6,frequency,16
|
||||
61,total,0.6,frequency,17
|
||||
62,total,0.6,frequency,18
|
||||
63,total,0.6,frequency,19
|
||||
64,total,0.6,frequency,20
|
||||
65,total,0.6,both,0
|
||||
66,total,0.6,both,1
|
||||
67,total,0.6,both,2
|
||||
68,total,0.6,both,3
|
||||
69,total,0.6,both,4
|
||||
70,total,0.6,both,5
|
||||
71,total,0.6,both,6
|
||||
72,total,0.6,both,7
|
||||
73,total,0.6,both,8
|
||||
74,total,0.6,both,9
|
||||
75,total,0.6,both,10
|
||||
76,total,0.6,both,11
|
||||
77,total,0.6,both,12
|
||||
78,total,0.6,both,13
|
||||
79,total,0.6,both,14
|
||||
80,total,0.6,both,15
|
||||
81,total,0.6,both,16
|
||||
82,total,0.6,both,17
|
||||
83,total,0.6,both,18
|
||||
84,total,0.6,both,19
|
||||
85,total,0.6,both,20
|
||||
86,total,0.7,current,0
|
||||
87,total,0.7,frequency,0
|
||||
88,total,0.7,frequency,1
|
||||
89,total,0.7,frequency,2
|
||||
90,total,0.7,frequency,3
|
||||
91,total,0.7,frequency,4
|
||||
92,total,0.7,frequency,5
|
||||
93,total,0.7,frequency,6
|
||||
94,total,0.7,frequency,7
|
||||
95,total,0.7,frequency,8
|
||||
96,total,0.7,frequency,9
|
||||
97,total,0.7,frequency,10
|
||||
98,total,0.7,frequency,11
|
||||
99,total,0.7,frequency,12
|
||||
100,total,0.7,frequency,13
|
||||
101,total,0.7,frequency,14
|
||||
102,total,0.7,frequency,15
|
||||
103,total,0.7,frequency,16
|
||||
104,total,0.7,frequency,17
|
||||
105,total,0.7,frequency,18
|
||||
106,total,0.7,frequency,19
|
||||
107,total,0.7,frequency,20
|
||||
108,total,0.7,both,0
|
||||
109,total,0.7,both,1
|
||||
110,total,0.7,both,2
|
||||
111,total,0.7,both,3
|
||||
112,total,0.7,both,4
|
||||
113,total,0.7,both,5
|
||||
114,total,0.7,both,6
|
||||
115,total,0.7,both,7
|
||||
116,total,0.7,both,8
|
||||
117,total,0.7,both,9
|
||||
118,total,0.7,both,10
|
||||
119,total,0.7,both,11
|
||||
120,total,0.7,both,12
|
||||
121,total,0.7,both,13
|
||||
122,total,0.7,both,14
|
||||
123,total,0.7,both,15
|
||||
124,total,0.7,both,16
|
||||
125,total,0.7,both,17
|
||||
126,total,0.7,both,18
|
||||
127,total,0.7,both,19
|
||||
128,total,0.7,both,20
|
||||
129,total,0.8,current,0
|
||||
130,total,0.8,frequency,0
|
||||
131,total,0.8,frequency,1
|
||||
132,total,0.8,frequency,2
|
||||
133,total,0.8,frequency,3
|
||||
134,total,0.8,frequency,4
|
||||
135,total,0.8,frequency,5
|
||||
136,total,0.8,frequency,6
|
||||
137,total,0.8,frequency,7
|
||||
138,total,0.8,frequency,8
|
||||
139,total,0.8,frequency,9
|
||||
140,total,0.8,frequency,10
|
||||
141,total,0.8,frequency,11
|
||||
142,total,0.8,frequency,12
|
||||
143,total,0.8,frequency,13
|
||||
144,total,0.8,frequency,14
|
||||
145,total,0.8,frequency,15
|
||||
146,total,0.8,frequency,16
|
||||
147,total,0.8,frequency,17
|
||||
148,total,0.8,frequency,18
|
||||
149,total,0.8,frequency,19
|
||||
150,total,0.8,frequency,20
|
||||
151,total,0.8,both,0
|
||||
152,total,0.8,both,1
|
||||
153,total,0.8,both,2
|
||||
154,total,0.8,both,3
|
||||
155,total,0.8,both,4
|
||||
156,total,0.8,both,5
|
||||
157,total,0.8,both,6
|
||||
158,total,0.8,both,7
|
||||
159,total,0.8,both,8
|
||||
160,total,0.8,both,9
|
||||
161,total,0.8,both,10
|
||||
162,total,0.8,both,11
|
||||
163,total,0.8,both,12
|
||||
164,total,0.8,both,13
|
||||
165,total,0.8,both,14
|
||||
166,total,0.8,both,15
|
||||
167,total,0.8,both,16
|
||||
168,total,0.8,both,17
|
||||
169,total,0.8,both,18
|
||||
170,total,0.8,both,19
|
||||
171,total,0.8,both,20
|
||||
172,total,0.9,current,0
|
||||
173,total,0.9,frequency,0
|
||||
174,total,0.9,frequency,1
|
||||
175,total,0.9,frequency,2
|
||||
176,total,0.9,frequency,3
|
||||
177,total,0.9,frequency,4
|
||||
178,total,0.9,frequency,5
|
||||
179,total,0.9,frequency,6
|
||||
180,total,0.9,frequency,7
|
||||
181,total,0.9,frequency,8
|
||||
182,total,0.9,frequency,9
|
||||
183,total,0.9,frequency,10
|
||||
184,total,0.9,frequency,11
|
||||
185,total,0.9,frequency,12
|
||||
186,total,0.9,frequency,13
|
||||
187,total,0.9,frequency,14
|
||||
188,total,0.9,frequency,15
|
||||
189,total,0.9,frequency,16
|
||||
190,total,0.9,frequency,17
|
||||
191,total,0.9,frequency,18
|
||||
192,total,0.9,frequency,19
|
||||
193,total,0.9,frequency,20
|
||||
194,total,0.9,both,0
|
||||
195,total,0.9,both,1
|
||||
196,total,0.9,both,2
|
||||
197,total,0.9,both,3
|
||||
198,total,0.9,both,4
|
||||
199,total,0.9,both,5
|
||||
200,total,0.9,both,6
|
||||
201,total,0.9,both,7
|
||||
202,total,0.9,both,8
|
||||
203,total,0.9,both,9
|
||||
204,total,0.9,both,10
|
||||
205,total,0.9,both,11
|
||||
206,total,0.9,both,12
|
||||
207,total,0.9,both,13
|
||||
208,total,0.9,both,14
|
||||
209,total,0.9,both,15
|
||||
210,total,0.9,both,16
|
||||
211,total,0.9,both,17
|
||||
212,total,0.9,both,18
|
||||
213,total,0.9,both,19
|
||||
214,total,0.9,both,20
|
||||
215,total,0.95,current,0
|
||||
216,total,0.95,frequency,0
|
||||
217,total,0.95,frequency,1
|
||||
218,total,0.95,frequency,2
|
||||
219,total,0.95,frequency,3
|
||||
220,total,0.95,frequency,4
|
||||
221,total,0.95,frequency,5
|
||||
222,total,0.95,frequency,6
|
||||
223,total,0.95,frequency,7
|
||||
224,total,0.95,frequency,8
|
||||
225,total,0.95,frequency,9
|
||||
226,total,0.95,frequency,10
|
||||
227,total,0.95,frequency,11
|
||||
228,total,0.95,frequency,12
|
||||
229,total,0.95,frequency,13
|
||||
230,total,0.95,frequency,14
|
||||
231,total,0.95,frequency,15
|
||||
232,total,0.95,frequency,16
|
||||
233,total,0.95,frequency,17
|
||||
234,total,0.95,frequency,18
|
||||
235,total,0.95,frequency,19
|
||||
236,total,0.95,frequency,20
|
||||
237,total,0.95,both,0
|
||||
238,total,0.95,both,1
|
||||
239,total,0.95,both,2
|
||||
240,total,0.95,both,3
|
||||
241,total,0.95,both,4
|
||||
242,total,0.95,both,5
|
||||
243,total,0.95,both,6
|
||||
244,total,0.95,both,7
|
||||
245,total,0.95,both,8
|
||||
246,total,0.95,both,9
|
||||
247,total,0.95,both,10
|
||||
248,total,0.95,both,11
|
||||
249,total,0.95,both,12
|
||||
250,total,0.95,both,13
|
||||
251,total,0.95,both,14
|
||||
252,total,0.95,both,15
|
||||
253,total,0.95,both,16
|
||||
254,total,0.95,both,17
|
||||
255,total,0.95,both,18
|
||||
256,total,0.95,both,19
|
||||
257,total,0.95,both,20
|
||||
258,smart,0.5,current,0
|
||||
259,smart,0.5,frequency,0
|
||||
260,smart,0.5,frequency,1
|
||||
261,smart,0.5,frequency,2
|
||||
262,smart,0.5,frequency,3
|
||||
263,smart,0.5,frequency,4
|
||||
264,smart,0.5,frequency,5
|
||||
265,smart,0.5,frequency,6
|
||||
266,smart,0.5,frequency,7
|
||||
267,smart,0.5,frequency,8
|
||||
268,smart,0.5,frequency,9
|
||||
269,smart,0.5,frequency,10
|
||||
270,smart,0.5,frequency,11
|
||||
271,smart,0.5,frequency,12
|
||||
272,smart,0.5,frequency,13
|
||||
273,smart,0.5,frequency,14
|
||||
274,smart,0.5,frequency,15
|
||||
275,smart,0.5,frequency,16
|
||||
276,smart,0.5,frequency,17
|
||||
277,smart,0.5,frequency,18
|
||||
278,smart,0.5,frequency,19
|
||||
279,smart,0.5,frequency,20
|
||||
280,smart,0.5,both,0
|
||||
281,smart,0.5,both,1
|
||||
282,smart,0.5,both,2
|
||||
283,smart,0.5,both,3
|
||||
284,smart,0.5,both,4
|
||||
285,smart,0.5,both,5
|
||||
286,smart,0.5,both,6
|
||||
287,smart,0.5,both,7
|
||||
288,smart,0.5,both,8
|
||||
289,smart,0.5,both,9
|
||||
290,smart,0.5,both,10
|
||||
291,smart,0.5,both,11
|
||||
292,smart,0.5,both,12
|
||||
293,smart,0.5,both,13
|
||||
294,smart,0.5,both,14
|
||||
295,smart,0.5,both,15
|
||||
296,smart,0.5,both,16
|
||||
297,smart,0.5,both,17
|
||||
298,smart,0.5,both,18
|
||||
299,smart,0.5,both,19
|
||||
300,smart,0.5,both,20
|
||||
301,smart,0.6,current,0
|
||||
302,smart,0.6,frequency,0
|
||||
303,smart,0.6,frequency,1
|
||||
304,smart,0.6,frequency,2
|
||||
305,smart,0.6,frequency,3
|
||||
306,smart,0.6,frequency,4
|
||||
307,smart,0.6,frequency,5
|
||||
308,smart,0.6,frequency,6
|
||||
309,smart,0.6,frequency,7
|
||||
310,smart,0.6,frequency,8
|
||||
311,smart,0.6,frequency,9
|
||||
312,smart,0.6,frequency,10
|
||||
313,smart,0.6,frequency,11
|
||||
314,smart,0.6,frequency,12
|
||||
315,smart,0.6,frequency,13
|
||||
316,smart,0.6,frequency,14
|
||||
317,smart,0.6,frequency,15
|
||||
318,smart,0.6,frequency,16
|
||||
319,smart,0.6,frequency,17
|
||||
320,smart,0.6,frequency,18
|
||||
321,smart,0.6,frequency,19
|
||||
322,smart,0.6,frequency,20
|
||||
323,smart,0.6,both,0
|
||||
324,smart,0.6,both,1
|
||||
325,smart,0.6,both,2
|
||||
326,smart,0.6,both,3
|
||||
327,smart,0.6,both,4
|
||||
328,smart,0.6,both,5
|
||||
329,smart,0.6,both,6
|
||||
330,smart,0.6,both,7
|
||||
331,smart,0.6,both,8
|
||||
332,smart,0.6,both,9
|
||||
333,smart,0.6,both,10
|
||||
334,smart,0.6,both,11
|
||||
335,smart,0.6,both,12
|
||||
336,smart,0.6,both,13
|
||||
337,smart,0.6,both,14
|
||||
338,smart,0.6,both,15
|
||||
339,smart,0.6,both,16
|
||||
340,smart,0.6,both,17
|
||||
341,smart,0.6,both,18
|
||||
342,smart,0.6,both,19
|
||||
343,smart,0.6,both,20
|
||||
344,smart,0.7,current,0
|
||||
345,smart,0.7,frequency,0
|
||||
346,smart,0.7,frequency,1
|
||||
347,smart,0.7,frequency,2
|
||||
348,smart,0.7,frequency,3
|
||||
349,smart,0.7,frequency,4
|
||||
350,smart,0.7,frequency,5
|
||||
351,smart,0.7,frequency,6
|
||||
352,smart,0.7,frequency,7
|
||||
353,smart,0.7,frequency,8
|
||||
354,smart,0.7,frequency,9
|
||||
355,smart,0.7,frequency,10
|
||||
356,smart,0.7,frequency,11
|
||||
357,smart,0.7,frequency,12
|
||||
358,smart,0.7,frequency,13
|
||||
359,smart,0.7,frequency,14
|
||||
360,smart,0.7,frequency,15
|
||||
361,smart,0.7,frequency,16
|
||||
362,smart,0.7,frequency,17
|
||||
363,smart,0.7,frequency,18
|
||||
364,smart,0.7,frequency,19
|
||||
365,smart,0.7,frequency,20
|
||||
366,smart,0.7,both,0
|
||||
367,smart,0.7,both,1
|
||||
368,smart,0.7,both,2
|
||||
369,smart,0.7,both,3
|
||||
370,smart,0.7,both,4
|
||||
371,smart,0.7,both,5
|
||||
372,smart,0.7,both,6
|
||||
373,smart,0.7,both,7
|
||||
374,smart,0.7,both,8
|
||||
375,smart,0.7,both,9
|
||||
376,smart,0.7,both,10
|
||||
377,smart,0.7,both,11
|
||||
378,smart,0.7,both,12
|
||||
379,smart,0.7,both,13
|
||||
380,smart,0.7,both,14
|
||||
381,smart,0.7,both,15
|
||||
382,smart,0.7,both,16
|
||||
383,smart,0.7,both,17
|
||||
384,smart,0.7,both,18
|
||||
385,smart,0.7,both,19
|
||||
386,smart,0.7,both,20
|
||||
387,smart,0.8,current,0
|
||||
388,smart,0.8,frequency,0
|
||||
389,smart,0.8,frequency,1
|
||||
390,smart,0.8,frequency,2
|
||||
391,smart,0.8,frequency,3
|
||||
392,smart,0.8,frequency,4
|
||||
393,smart,0.8,frequency,5
|
||||
394,smart,0.8,frequency,6
|
||||
395,smart,0.8,frequency,7
|
||||
396,smart,0.8,frequency,8
|
||||
397,smart,0.8,frequency,9
|
||||
398,smart,0.8,frequency,10
|
||||
399,smart,0.8,frequency,11
|
||||
400,smart,0.8,frequency,12
|
||||
401,smart,0.8,frequency,13
|
||||
402,smart,0.8,frequency,14
|
||||
403,smart,0.8,frequency,15
|
||||
404,smart,0.8,frequency,16
|
||||
405,smart,0.8,frequency,17
|
||||
406,smart,0.8,frequency,18
|
||||
407,smart,0.8,frequency,19
|
||||
408,smart,0.8,frequency,20
|
||||
409,smart,0.8,both,0
|
||||
410,smart,0.8,both,1
|
||||
411,smart,0.8,both,2
|
||||
412,smart,0.8,both,3
|
||||
413,smart,0.8,both,4
|
||||
414,smart,0.8,both,5
|
||||
415,smart,0.8,both,6
|
||||
416,smart,0.8,both,7
|
||||
417,smart,0.8,both,8
|
||||
418,smart,0.8,both,9
|
||||
419,smart,0.8,both,10
|
||||
420,smart,0.8,both,11
|
||||
421,smart,0.8,both,12
|
||||
422,smart,0.8,both,13
|
||||
423,smart,0.8,both,14
|
||||
424,smart,0.8,both,15
|
||||
425,smart,0.8,both,16
|
||||
426,smart,0.8,both,17
|
||||
427,smart,0.8,both,18
|
||||
428,smart,0.8,both,19
|
||||
429,smart,0.8,both,20
|
||||
430,smart,0.9,current,0
|
||||
431,smart,0.9,frequency,0
|
||||
432,smart,0.9,frequency,1
|
||||
433,smart,0.9,frequency,2
|
||||
434,smart,0.9,frequency,3
|
||||
435,smart,0.9,frequency,4
|
||||
436,smart,0.9,frequency,5
|
||||
437,smart,0.9,frequency,6
|
||||
438,smart,0.9,frequency,7
|
||||
439,smart,0.9,frequency,8
|
||||
440,smart,0.9,frequency,9
|
||||
441,smart,0.9,frequency,10
|
||||
442,smart,0.9,frequency,11
|
||||
443,smart,0.9,frequency,12
|
||||
444,smart,0.9,frequency,13
|
||||
445,smart,0.9,frequency,14
|
||||
446,smart,0.9,frequency,15
|
||||
447,smart,0.9,frequency,16
|
||||
448,smart,0.9,frequency,17
|
||||
449,smart,0.9,frequency,18
|
||||
450,smart,0.9,frequency,19
|
||||
451,smart,0.9,frequency,20
|
||||
452,smart,0.9,both,0
|
||||
453,smart,0.9,both,1
|
||||
454,smart,0.9,both,2
|
||||
455,smart,0.9,both,3
|
||||
456,smart,0.9,both,4
|
||||
457,smart,0.9,both,5
|
||||
458,smart,0.9,both,6
|
||||
459,smart,0.9,both,7
|
||||
460,smart,0.9,both,8
|
||||
461,smart,0.9,both,9
|
||||
462,smart,0.9,both,10
|
||||
463,smart,0.9,both,11
|
||||
464,smart,0.9,both,12
|
||||
465,smart,0.9,both,13
|
||||
466,smart,0.9,both,14
|
||||
467,smart,0.9,both,15
|
||||
468,smart,0.9,both,16
|
||||
469,smart,0.9,both,17
|
||||
470,smart,0.9,both,18
|
||||
471,smart,0.9,both,19
|
||||
472,smart,0.9,both,20
|
||||
473,smart,0.95,current,0
|
||||
474,smart,0.95,frequency,0
|
||||
475,smart,0.95,frequency,1
|
||||
476,smart,0.95,frequency,2
|
||||
477,smart,0.95,frequency,3
|
||||
478,smart,0.95,frequency,4
|
||||
479,smart,0.95,frequency,5
|
||||
480,smart,0.95,frequency,6
|
||||
481,smart,0.95,frequency,7
|
||||
482,smart,0.95,frequency,8
|
||||
483,smart,0.95,frequency,9
|
||||
484,smart,0.95,frequency,10
|
||||
485,smart,0.95,frequency,11
|
||||
486,smart,0.95,frequency,12
|
||||
487,smart,0.95,frequency,13
|
||||
488,smart,0.95,frequency,14
|
||||
489,smart,0.95,frequency,15
|
||||
490,smart,0.95,frequency,16
|
||||
491,smart,0.95,frequency,17
|
||||
492,smart,0.95,frequency,18
|
||||
493,smart,0.95,frequency,19
|
||||
494,smart,0.95,frequency,20
|
||||
495,smart,0.95,both,0
|
||||
496,smart,0.95,both,1
|
||||
497,smart,0.95,both,2
|
||||
498,smart,0.95,both,3
|
||||
499,smart,0.95,both,4
|
||||
500,smart,0.95,both,5
|
||||
501,smart,0.95,both,6
|
||||
502,smart,0.95,both,7
|
||||
503,smart,0.95,both,8
|
||||
504,smart,0.95,both,9
|
||||
505,smart,0.95,both,10
|
||||
506,smart,0.95,both,11
|
||||
507,smart,0.95,both,12
|
||||
508,smart,0.95,both,13
|
||||
509,smart,0.95,both,14
|
||||
510,smart,0.95,both,15
|
||||
511,smart,0.95,both,16
|
||||
512,smart,0.95,both,17
|
||||
513,smart,0.95,both,18
|
||||
514,smart,0.95,both,19
|
||||
515,smart,0.95,both,20
|
||||
|
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,55 @@
|
|||
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>反复活跃股票的持有期矩阵</title><style>
|
||||
:root{font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;color:#233244;background:#f4f6f8;font-size:14px}*{box-sizing:border-box}body{margin:0}main{max-width:1540px;margin:auto;padding:24px}header{margin-bottom:18px}h1{font-size:28px;margin:0 0 8px;font-weight:650}h2{font-size:18px;margin:0}p{line-height:1.65;margin:6px 0}.muted{color:#607084}.tag{font-size:12px;color:#235a80;background:#e4eff8;border-radius:4px;padding:4px 8px;display:inline-block;margin:8px 6px 0 0}.panel{background:white;border:1px solid #e0e6ed;border-radius:12px;padding:18px;margin-bottom:16px}.filters{display:grid;grid-template-columns:repeat(6,minmax(145px,1fr));gap:12px}label{display:block;color:#607084;font-size:12px}select{margin-top:5px;width:100%;height:36px;border:1px solid #cbd4df;border-radius:6px;background:white;color:#233244;padding:0 7px;font-size:13px}select:disabled{background:#f1f3f5;color:#8d99a6}.actions{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0 4px}button{border:1px solid #bdcddd;border-radius:6px;background:#fff;color:#2c5271;padding:8px 12px;cursor:pointer;font-size:13px}button:hover{background:#eaf2f9}button.primary{background:#265f87;color:white;border-color:#265f87}.charts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.charts.wide{grid-template-columns:1fr}.chart-panel{background:white;border:1px solid #e0e6ed;border-radius:12px;padding:16px;min-width:0}.chart-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}.chart-sub{font-size:12px;min-height:34px;color:#607084;line-height:1.5}.canvas-box{position:relative;height:800px}.legend{display:flex;align-items:center;gap:10px;font-size:12px;margin:8px auto;justify-content:center}.gradient{height:12px;width:180px;background:linear-gradient(90deg,#2166ac,#f7f7f7,#b2182b);border:1px solid #e0e6ed}.grey{display:inline-block;background:#e1e5ea;width:12px;height:12px;margin-right:4px}.notice{padding:11px 14px;border-left:3px solid #7199b9;background:#eef4f8;font-size:13px;line-height:1.6;margin:14px 0}.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.kpi{padding:14px;background:#fff;border:1px solid #e0e6ed;border-radius:10px}.kpi strong{display:block;font-size:22px;margin-top:5px}.kpi span{font-size:12px;color:#607084}table{border-collapse:collapse;width:100%;font-size:12px;white-space:nowrap}th,td{padding:8px 10px;border-bottom:1px solid #e6ebf0;text-align:right}th{background:#f3f6f9;font-weight:600;position:sticky;top:0}th:first-child,td:first-child{text-align:left}.scroll{overflow:auto;max-height:530px}#loading{padding:40px;text-align:center;color:#5a7187}footer{font-size:12px;color:#607084;margin:20px 0}a{color:#265f87}.hidden{display:none!important}@media(max-width:1050px){.filters{grid-template-columns:repeat(3,minmax(135px,1fr))}.charts{grid-template-columns:1fr}.kpis{grid-template-columns:repeat(2,1fr)}}@media(max-width:580px){main{padding:12px}h1{font-size:23px}.filters{grid-template-columns:repeat(2,minmax(120px,1fr))}.chart-panel{padding:10px}.canvas-box{min-width:480px}.chart-panel{overflow:auto}}@media print{.filters,.actions,button{display:none}.charts{display:block}.chart-panel{break-inside:avoid;margin:12px 0}body{background:#fff}}
|
||||
</style></head><body><main>
|
||||
<header><h1>反复活跃股票的持有期矩阵</h1><p class="muted">固定一个条件,比较持有1至10个交易日。2025年与2026年并排查看,分清绝对收益、频次增量和指数差额。</p><span class="tag">前20个交易日,不含信号当天</span><span class="tag">全市场同一合格池</span><span class="tag">5160组参数 · 389个可用信号日</span></header>
|
||||
<section class="panel"><div class="filters">
|
||||
<label>矩阵坐标<select id="view"><option value="count_hold">次数 × 持有日</option><option value="threshold_hold">分数门槛 × 持有日</option><option value="threshold_count">分数门槛 × 次数</option></select></label>
|
||||
<label>单独考察的分数<select id="score"><option value="smart">smart_score 聪明资金分</option><option value="total">total_score 综合分</option></select></label>
|
||||
<label>筛选规则<select id="mode"><option value="frequency">仅看前20日次数</option><option value="both">次数足够且当天达标</option><option value="current">只看当天分数</option></select></label>
|
||||
<label>固定分数门槛<select id="threshold"></select></label><label>固定次数下限 K<select id="k"></select></label><label>固定持有日 H<select id="hold"></select></label>
|
||||
<label>年份<select id="period"><option value="compare">2025与2026并排</option><option value="2026">仅2026</option><option value="2025">仅2025</option><option value="full">全部历史</option></select></label>
|
||||
<label>市场阶段<select id="stage"><option value="99">全部阶段</option><option value="1">上涨</option><option value="0">震荡</option><option value="-1">下跌</option></select></label>
|
||||
<label>阶段划分依据<select id="phase_index"></select></label>
|
||||
<label>着色指标<select id="metric"><option value="return">平均每批收益</option><option value="delta_k0">增加频次要求的改善</option><option value="delta_current">相对只看当天分数</option><option value="delta_universe">相对共同全市场池</option><option value="index_excess">相对同期指数</option><option value="win30">个股胜率(30基点)</option><option value="active_days">有效信号日数</option><option value="mean_selected">日均入选股票数</option></select></label>
|
||||
<label>每边费用<select id="fee"><option value="30">30基点净收益</option><option value="60">60基点压力</option><option value="0">0基点毛收益</option></select></label>
|
||||
<label>同期收益对照指数<select id="benchmark"></select></label>
|
||||
<label>收益色标范围<select id="scale"><option value="auto">当前两图统一范围</option><option value="1">固定 ±1%</option><option value="2">固定 ±2%</option><option value="5">固定 ±5%</option><option value="10">固定 ±10%</option></select></label>
|
||||
</div><div class="actions"><button class="primary" id="preset-current">先看单日分数</button><button id="preset-frequency">再看20日频次</button><button id="preset-both">叠加当天达标</button><button id="download-csv">下载当前矩阵CSV</button></div>
|
||||
<p id="rule" class="muted"></p></section>
|
||||
<div class="notice">评分日后下一交易日开盘买入,买后H个交易日开盘卖出;卖出受阻顺延。每格是已结束交易的平均批次收益,不是账户累计收益。缺失历史评分不会记为0次;未达20个有效信号日或100笔完成交易的格子标灰。</div>
|
||||
<div id="loading">正在读取本地矩阵数据…</div><section class="charts" id="charts"></section>
|
||||
<section class="panel" style="margin-top:16px"><h2 id="detail-title">点击一个格子,查看该行持有1至10日的明细</h2><p class="muted" id="detail-note"></p><div class="scroll"><table><thead><tr><th>年份</th><th>门槛</th><th>次数</th><th>持有日</th><th id="value-heading">当前指标</th><th>毛收益</th><th>30bp净收益</th><th>60bp净收益</th><th>有效日</th><th>完成笔数</th><th>日均入选</th><th>未退出笔数</th></tr></thead><tbody id="details"></tbody></table></div></section>
|
||||
<footer><p>共同信号窗口:2025-01-22至2026-09-30;行情与退出估值截至2026-10-23。2026-03-19缺评分及其后20个交易日无法形成完整观察窗。历史评分可被覆盖,未能核实首次可用时点,结果属于现存历史分数回放。</p><p>阶段只使用信号日及以前的指数趋势,不改变股票池。收益对照指数可独立选择;同期指数按每笔股票的实际买卖日开盘计算,属于价格收益对照,不是风险中性收益或ETF成交回报。所有年份均为已见历史,少数高收益格不代表稳定最优参数。</p><p><a href="反复活跃与持有期矩阵研究.md">研究报告</a> · <a href="grid.csv.gz">完整压缩CSV</a> · <a href="protocol.json">冻结协议</a> · <a href="window_examples.csv">20日计数实例</a> · <a href="accounts.csv">预设现金账户结果</a></p></footer>
|
||||
</main><script>/*__CHARTJS__*/</script><script>
|
||||
const PAYLOAD=/*__PAYLOAD__*/;
|
||||
const Q=[.5,.6,.7,.8,.9,.95],INDEX={csi300:'沪深300',csi500:'中证500',csi1000:'中证1000',csi2000:'中证2000'},STAGE={'99':'全部阶段','1':'上涨','0':'震荡','-1':'下跌'};
|
||||
const COL={gross:0,net30:1,net60:2,win30:3,active_days:4,completed:5,mean_selected:6,filled:7,unresolved:8,delayed:9,delta_k0:10,delta_current:11,delta_universe:12,csi300:13,csi500:14,csi1000:15,csi2000:16};
|
||||
const $=id=>document.getElementById(id),cache=new Map();let charts=[],visible=[],generation=0,selection={q:.8,k:5,h:5},ready=false;
|
||||
const percent=v=>v==null?'—':(v>=0?'+':'')+(v*100).toFixed(2)+'%';const number=v=>v==null?'—':v.toLocaleString('zh-CN',{maximumFractionDigits:1});
|
||||
for(const id of ['threshold']){Q.forEach(q=>$(id).add(new Option(q,q)));$(id).value='.8';$(id).value='0.8'}
|
||||
for(let k=0;k<=20;k++)$('k').add(new Option(k,k));$('k').value='5';for(let h=1;h<=10;h++)$('hold').add(new Option(h,h));$('hold').value='5';
|
||||
for(const id of ['phase_index','benchmark'])Object.entries(INDEX).forEach(([k,v])=>$(id).add(new Option(v,k)));$('benchmark').value='csi2000';
|
||||
function state(){return Object.fromEntries([...document.querySelectorAll('select')].map(e=>[e.id,e.value]))}
|
||||
async function chunk(s,period){const ix=s.stage==='99'?'all':s.phase_index,key=[s.score,period,ix,s.stage].join('|');if(cache.has(key))return cache.get(key);const bytes=Uint8Array.from(atob(PAYLOAD[key]),c=>c.charCodeAt(0));const stream=new Blob([bytes]).stream().pipeThrough(new DecompressionStream('gzip'));const data=JSON.parse(await new Response(stream).text());cache.set(key,data);if(cache.size>8)cache.delete(cache.keys().next().value);return data}
|
||||
function lookup(data,s,q,k,h){const off=Q.indexOf(Number(q))*43;const config=off+(s.mode==='current'?0:s.mode==='frequency'?1+Number(k):22+Number(k));return data[config*10+Number(h)-1]}
|
||||
function value(v,s){if(!v)return null;const fee=Number(s.fee)/10000,f=(1-fee)/(1+fee);if(s.metric==='return')return v[s.fee==='0'?0:s.fee==='30'?1:2];if(s.metric.startsWith('delta_'))return v[COL[s.metric]]==null?null:v[COL[s.metric]]*f/(.997/1.003);if(s.metric==='index_excess'){if(v[0]==null||v[COL[s.benchmark]]==null)return null;return v[COL[s.benchmark]]+(v[0]+1)*f-1-v[0]}return v[COL[s.metric]]}
|
||||
function isCount(s){return ['active_days','mean_selected'].includes(s.metric)}function unit(s){return isCount(s)?(s.metric==='active_days'?'日':'只'):s.metric==='return'||s.metric==='win30'?'%':'百分点'}
|
||||
function formatted(v,s){if(v==null)return '—';if(isCount(s))return number(v);if(s.metric==='win30')return (v*100).toFixed(1)+'%';return (v>=0?'+':'')+(v*100).toFixed(2)+(unit(s)==='%'?'%':'')}
|
||||
function supported(v){return v&&v[4]>=20&&v[5]>=100}
|
||||
function color(v,limit,s){if(v==null)return '#e1e5ea';let z=Math.max(-1,Math.min(1,v/limit));if(isCount(s)||s.metric==='win30')z=Math.max(0,z);const white=[247,247,247],end=z<0?[33,102,172]:[178,24,43];return 'rgb('+white.map((a,i)=>Math.round(a+(end[i]-a)*Math.abs(z))).join(',')+')'}
|
||||
function rowsFor(s){return s.view==='count_hold'?Array.from({length:21},(_,i)=>i):Q}
|
||||
function columnsFor(s){return s.view==='threshold_count'?Array.from({length:21},(_,i)=>i):Array.from({length:10},(_,i)=>i+1)}
|
||||
function pointsFor(data,s){const rows=rowsFor(s),cols=columnsFor(s),out=[];rows.forEach((r,y)=>cols.forEach((c,x)=>{const q=s.view==='count_hold'?Number(s.threshold):r,k=s.view==='count_hold'?r:s.view==='threshold_count'?c:Number(s.k),h=s.view==='threshold_count'?Number(s.hold):c,v=lookup(data,s,q,k,h);out.push({x,y,q,k:s.mode==='current'?0:k,h,v,z:value(v,s),ok:supported(v)})}));return out}
|
||||
const cells={id:'matrixCells',beforeDraw(chart){const c=chart.ctx;c.save();c.fillStyle='#fff';c.fillRect(0,0,chart.width,chart.height);c.restore()},beforeDatasetsDraw(chart){const {ctx,scales:{x,y}}=chart,opts=chart.options.plugins.matrixCells,s=opts.state;const width=Math.abs(x.getPixelForValue(1)-x.getPixelForValue(0)),height=Math.abs(y.getPixelForValue(1)-y.getPixelForValue(0));ctx.save();for(const p of chart.data.datasets[0].data){const px=x.getPixelForValue(p.x),py=y.getPixelForValue(p.y);ctx.fillStyle=p.ok?color(p.z,opts.limit,s):'#e1e5ea';ctx.fillRect(px-width/2+.7,py-height/2+.7,width-1.4,height-1.4);ctx.textAlign='center';ctx.textBaseline='middle';ctx.font=(width<40?'10':'12')+'px -apple-system, "PingFang SC", sans-serif';ctx.fillStyle=p.ok&&p.z!=null&&Math.abs(p.z)>opts.limit*.58?'#fff':'#273849';let text=p.z==null?'—':isCount(s)?Math.round(p.z).toString():(p.z*100).toFixed(2);if(!p.ok&&p.z!=null)text+='*';ctx.fillText(text,px,py,width-4)}ctx.restore()},afterDraw(chart){const c=chart.ctx;c.save();c.fillStyle='#607084';c.font='10px -apple-system, "PingFang SC", sans-serif';c.textAlign='center';c.fillText('信号截至2026-09-30;行情与退出估值截至2026-10-23;现存历史评分回放',chart.width/2,chart.height-5);c.restore()}};
|
||||
Chart.register(cells);
|
||||
function matrix(canvas,data,s,period,limit){const rows=rowsFor(s),cols=columnsFor(s),pts=pointsFor(data,s);return new Chart(canvas,{type:'scatter',data:{datasets:[{data:pts,pointRadius:0,pointHitRadius:23}]},options:{layout:{padding:{bottom:20}},animation:false,responsive:true,maintainAspectRatio:false,devicePixelRatio:2,interaction:{mode:'nearest',intersect:false},plugins:{title:{display:true,text:[`${period==='full'?'全历史':period+'年'} · ${s.score}_score · ${s.mode==='current'?'仅当天':s.mode==='frequency'?'历史频次':'历史频次且当天达标'}`,`${s.view==='count_hold'?'门槛≥'+s.threshold:s.view==='threshold_count'?'持有'+s.hold+'日':s.mode==='current'?'单日筛选':'次数≥'+s.k} · ${s.stage==='99'?'全部阶段':INDEX[s.phase_index]+' '+STAGE[s.stage]} · ${$('metric').selectedOptions[0].text}(${unit(s)})`,`${s.metric==='index_excess'?INDEX[s.benchmark]+'对照 · ':''}${isCount(s)||s.metric==='win30'?'':$('fee').selectedOptions[0].text+' · '}色标上限${formatted(limit,s)};灰格样本不足`],font:{size:11},color:'#233244',padding:{bottom:12}},legend:{display:false},matrixCells:{state:s,limit},tooltip:{enabled:true,callbacks:{title:items=>{const p=items[0].raw;return `门槛 ≥ ${p.q} · ${s.mode==='current'?'仅当天':`前20日 ≥ ${p.k}次`} · 持有${p.h}日`},label:context=>{const p=context.raw;return [`${$('metric').selectedOptions[0].text}:${formatted(p.z,s)} ${unit(s)==='百分点'?'个百分点':''}`,`有效信号日:${p.v[4]};完成交易:${p.v[5]}`,`日均入选:${number(p.v[6])}只;未退出:${p.v[8]}笔`,p.ok?'达到最低展示样本要求':'样本不足,实际数值仅供观察']}}}},scales:{x:{type:'linear',min:-.5,max:cols.length-.5,afterBuildTicks:axis=>axis.ticks=cols.map((_,i)=>({value:i})),ticks:{callback:v=>cols[v],font:{size:12},maxRotation:0},grid:{display:false},title:{display:true,text:s.view==='threshold_count'?'此前20个交易日达标次数下限 K':'持有交易日 H',font:{size:13}}},y:{type:'linear',min:-.5,max:rows.length-.5,reverse:true,afterBuildTicks:axis=>axis.ticks=rows.map((_,i)=>({value:i})),ticks:{callback:v=>rows[v],font:{size:12}},grid:{display:false},title:{display:true,text:s.view==='count_hold'?'此前20日达标次数下限 K':'分数下限(含边界)',font:{size:13}}}},onClick:(event,items)=>{if(items.length){const p=pts[items[0].index];selection={q:p.q,k:p.k,h:p.h};renderDetails(s)}}}})}
|
||||
function renderDetails(s){$('value-heading').textContent=$('metric').selectedOptions[0].text+'('+unit(s)+')';$('detail-title').textContent=`该条件持有1至10日:${s.score}_score ≥ ${selection.q},${s.mode==='current'?'只看当天':`前20日 ≥ ${selection.k}次`}`;$('detail-note').textContent='点击任一矩阵格可切换此表;灰格的实际值仍保留。日均入选包含对应阶段内无法形成信号的日期。';const lines=[];for(const v of visible){for(let h=1;h<=10;h++){const a=lookup(v.data,s,selection.q,selection.k,h),z=value(a,s);lines.push(`<tr><td>${v.period==='full'?'全历史':v.period}</td><td>${selection.q}</td><td>${s.mode==='current'?'—':selection.k}</td><td>${h}</td><td>${formatted(z,s)}${supported(a)?'':' *'}</td><td>${percent(a[0])}</td><td>${percent(a[1])}</td><td>${percent(a[2])}</td><td>${a[4]}</td><td>${number(a[5])}</td><td>${number(a[6])}</td><td>${a[8]}</td></tr>`)}}$('details').innerHTML=lines.join('')}
|
||||
async function render(){const turn=++generation;ready=false;let s=state();if(s.mode==='current'&&s.view!=='threshold_hold'){$('view').value='threshold_hold';s=state()}$('threshold').disabled=s.view!=='count_hold';$('k').disabled=s.view!=='threshold_hold'||s.mode==='current';$('hold').disabled=s.view!=='threshold_count';$('phase_index').disabled=s.stage==='99';$('benchmark').disabled=s.metric!=='index_excess';$('fee').disabled=isCount(s)||s.metric==='win30';$('scale').disabled=isCount(s)||s.metric==='win30';const periods=s.period==='compare'?['2025','2026']:[s.period];$('loading').classList.remove('hidden');try{const chunks=await Promise.all(periods.map(p=>chunk(s,p)));if(turn!==generation)return;visible=periods.map((period,i)=>({period,data:chunks[i]}));const all=visible.flatMap(v=>pointsFor(v.data,s)).filter(p=>p.ok&&p.z!=null).map(p=>Math.abs(p.z));let limit=s.scale==='auto'?Math.max(isCount(s)?1:.001,...all):Number(s.scale)/100;if(isCount(s)||s.metric==='win30')limit=Math.max(s.metric==='win30'?1:1,...all);else if(s.scale==='auto')limit=Math.ceil(limit*1000)/1000;charts.forEach(c=>c.destroy());charts=[];$('charts').innerHTML='';$('charts').classList.toggle('wide',s.view==='threshold_count'||periods.length===1);
|
||||
for(const [i,v] of visible.entries()){const panel=document.createElement('article');panel.className='chart-panel';const phase=s.stage==='99'?'全部阶段':INDEX[s.phase_index]+'划分 · '+STAGE[s.stage],metric=$('metric').selectedOptions[0].text+(s.metric==='index_excess'?' '+INDEX[s.benchmark]:'');panel.innerHTML=`<div class="chart-head"><h2>${v.period==='full'?'全历史':v.period+'年'}</h2><button data-download="${i}">下载PNG</button></div><div class="chart-sub">${phase} · ${metric} · ${isCount(s)||s.metric==='win30'?'':$('fee').selectedOptions[0].text}</div><div class="canvas-box" style="height:${s.view==='count_hold'?820:370}px"><canvas aria-label="${v.period}年参数热力图,明细在下方表格" role="img"></canvas></div><div class="legend"><span>${formatted(isCount(s)||s.metric==='win30'?0:-limit,s)}</span><div class="gradient" style="background:${isCount(s)||s.metric==='win30'?'linear-gradient(90deg,#f7f7f7,#b2182b)':'linear-gradient(90deg,#2166ac,#f7f7f7,#b2182b)'}"></div><span>${formatted(limit,s)} ${unit(s)==='百分点'?'个百分点':''}</span></div><p class="muted" style="font-size:12px"><span class="grey"></span>灰色为样本不足或无样本;*保留实际值。两图使用相同色标${s.scale==='auto'?',切换条件后重算':',超出范围按端点色显示'}。</p>`;$('charts').appendChild(panel);charts.push(matrix(panel.querySelector('canvas'),v.data,s,v.period,limit));panel.querySelector('button').onclick=()=>download(charts[i].toBase64Image(),'矩阵_'+s.score+'_'+v.period+'.png')}
|
||||
$('rule').textContent=(s.mode==='current'?'只检验当天一个分数门槛。':s.mode==='frequency'?'只检验此前20日达标频次,当天不额外要求达标。':'此前20日达标次数满足要求,同时要求当天分数达标。')+' K=0为同一可观察样本的对照;不含当天,不要求连续。';if(!Q.includes(selection.q))selection.q=.8;if(s.view==='count_hold')selection.q=Number(s.threshold);if(s.view==='threshold_hold'&&s.mode!=='current')selection.k=Number(s.k);renderDetails(s);$('loading').classList.add('hidden');ready=true;window.__dashboardReady=true;window.__dashboardState=s}catch(error){$('loading').textContent='数据读取失败:'+error.message;console.error(error)}}
|
||||
function download(url,name){const a=document.createElement('a');a.href=url;a.download=name;a.click()}
|
||||
for(const e of document.querySelectorAll('select'))e.addEventListener('change',render);
|
||||
$('preset-current').onclick=()=>{$('mode').value='current';$('view').value='threshold_hold';render()};$('preset-frequency').onclick=()=>{$('mode').value='frequency';$('view').value='count_hold';render()};$('preset-both').onclick=()=>{$('mode').value='both';$('view').value='count_hold';render()};
|
||||
$('download-csv').onclick=()=>{const s=state(),rows=[['年份','分数','门槛','规则','前20日次数下限','持有日','阶段指数','阶段','收益对照指数','费用每边基点','指标','指标值原比例','有效日','完成笔数','日均入选','样本足够']];for(const v of visible)for(const p of pointsFor(v.data,s))rows.push([v.period,s.score,p.q,s.mode,p.k,p.h,s.stage==='99'?'all':s.phase_index,s.stage,s.benchmark,s.fee,s.metric,p.z??'',p.v[4],p.v[5],p.v[6],p.ok]);const blob=new Blob(['\ufeff'+rows.map(r=>r.join(',')).join('\n')],{type:'text/csv;charset=utf-8'}),u=URL.createObjectURL(blob);download(u,'当前矩阵.csv');setTimeout(()=>URL.revokeObjectURL(u),1000)};
|
||||
window.getDisplayedCell=(period,q,k,h)=>{const s=state(),v=visible.find(v=>v.period===period);return v?lookup(v.data,s,q,k,h):null};render();
|
||||
</script></body></html>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"chunks": 78,
|
||||
"rows_per_chunk": 2580,
|
||||
"columns": [
|
||||
"mean_gross",
|
||||
"mean_net30",
|
||||
"mean_net60",
|
||||
"win30",
|
||||
"active_days",
|
||||
"completed",
|
||||
"mean_selected",
|
||||
"filled",
|
||||
"unresolved",
|
||||
"delayed",
|
||||
"delta_k0_net30",
|
||||
"delta_current_net30",
|
||||
"delta_universe_net30",
|
||||
"excess_csi300",
|
||||
"excess_csi500",
|
||||
"excess_csi1000",
|
||||
"excess_csi2000"
|
||||
],
|
||||
"html_bytes": 15722969,
|
||||
"html_sha256": "7f9353fc6f3978826a0cd9dd1b6cdaf5ed09cdd1308b4e9725bd6d466775fed5",
|
||||
"chartjs_version": "4.5.1",
|
||||
"chartjs_sha384": "jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ",
|
||||
"external_runtime_requests": 0,
|
||||
"data_source": "grid.csv.gz",
|
||||
"data_source_sha256": "3a666cb7ef9f5ddbe504334560daa6047272ba8005eb9be71b511cc321ce7d6e",
|
||||
"default": "smart>=0.8,历史频次,2025/2026并排,30基点,全部阶段"
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
"""预设0.8门槛的样本集中度和对照;不据此重新选参。"""
|
||||
import sys
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from common import *
|
||||
from engine import future_exits
|
||||
|
||||
def block_interval(a,reps=1000):
|
||||
rng=np.random.default_rng(20261029);n=len(a);out=[]
|
||||
for _ in range(reps):
|
||||
starts=rng.integers(0,n,size=(n+9)//10);ix=np.concatenate([(s+np.arange(10))%n for s in starts])[:n];v=a[ix];v=v[np.isfinite(v)]
|
||||
if len(v):out.append(np.mean(v))
|
||||
return [float(v) for v in np.quantile(out,[.025,.975])] if out else None
|
||||
|
||||
def main():
|
||||
sys.addaudithook(offline);p,panel,f,cov=load();dates=panel['dates'];ex,gr=future_exits(panel,5);rows=[];unc=[];cfg=configuration();d=np.load(ROOT/'cache/daily_05.npz')
|
||||
for c in cfg:
|
||||
if c['threshold']!=.8 or c['mode']=='current' or c['k'] not in [5,10,15,20]:continue
|
||||
for period in ['2025','2026']:
|
||||
dd=f['window']&np.char.startswith(dates,period);mask=mask_for(panel,f,c)&dd[:,None]&np.isfinite(gr);by_stock=mask.sum(0);byday=mask.sum(1);active=byday>0;stocks=by_stock>0
|
||||
total=int(by_stock.sum());episodes=int(np.sum(mask&~np.vstack([np.zeros((1,mask.shape[1]),bool),mask[:-1]])))
|
||||
rows.append({**c,'period':period,'hold':5,'active_days':int(active.sum()),'completed':total,'unique_stocks':int(stocks.sum()),'stock_signal_streaks':episodes,'median_stocks_on_active_day':float(np.median(byday[active])) if active.any() else None,'top5_event_share':float(np.sort(by_stock)[-5:].sum()/total) if total else None,'largest_stock_event_share':float(by_stock.max()/total) if total else None})
|
||||
if c['score']=='smart' and c['mode']=='frequency' and c['k'] in [5,10,20] and period=='2026':
|
||||
raw=(d['gross'][:,c['config']]+1)*.997/1.003-1;control=(d['gross'][:,c['config']//43*43+1]+1)*.997/1.003-1
|
||||
unc.append({**c,'period':period,'hold':5,'mean_net30':float(mean(raw[dd])),'net30_block10_interval':block_interval(raw[dd]),'excess_k0':float(mean((raw-control)[dd])),'excess_block10_interval':block_interval((raw-control)[dd])})
|
||||
pd.DataFrame(rows).to_csv(ROOT/'concentration.csv',index=False,lineterminator='\n');dump(ROOT/'uncertainty.json',unc)
|
||||
print(pd.DataFrame(rows).query("score == 'smart' and mode == 'frequency' and k == 20").to_string(index=False))
|
||||
if __name__=='__main__':main()
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
"""上一轮已复核的纯账户引擎副本,冻结复用,不导入线上代码。"""
|
||||
import numpy as np
|
||||
|
||||
def future_exits(panel,hold):
|
||||
t,n=panel['open'].shape
|
||||
nxt=np.full((t+1,n),-1,dtype=np.int16)
|
||||
for i in range(t-1,-1,-1):nxt[i]=np.where(panel['can_sell'][i],i,nxt[i+1])
|
||||
exits=np.full((t,n),-1,dtype=np.int16)
|
||||
gross=np.full((t,n),np.nan)
|
||||
for s in range(t-hold-1):
|
||||
e=nxt[s+hold+1];j=np.arange(n)
|
||||
exits[s]=e
|
||||
ok=(e>=0)&panel['can_buy'][s+1]
|
||||
gross[s,ok]=panel['open'][e[ok],j[ok]]/panel['open'][s+1,ok]
|
||||
return exits,gross
|
||||
|
||||
def daily_means(mask,values):
|
||||
valid=mask&np.isfinite(values)
|
||||
n=valid.sum(axis=1)
|
||||
total=np.where(valid,values,0).sum(axis=1)
|
||||
return np.divide(total,n,out=np.full(len(n),np.nan),where=n>0)
|
||||
|
||||
def mean(v):
|
||||
v=np.asarray(v);v=v[np.isfinite(v)]
|
||||
return float(v.mean()) if len(v) else None
|
||||
|
||||
def account(panel,mask,hold,cost,stop=None,detail=False):
|
||||
"""每批次独立到期;卖出失败保留原任务。预算采用前收资产,禁止重复使用现金。"""
|
||||
t,n=mask.shape;stop=t if stop is None else stop
|
||||
holds=np.broadcast_to(np.asarray(hold,dtype=int),(t,))
|
||||
assert np.all((holds>=1)&(holds<=10))
|
||||
cash=1.;prev=1.;lots=[];records=[];journal=[];fees=0.;skipped=0;delays=0
|
||||
max_weight=0.;max_positions=0;max_stale_value=0.;buy_count=sell_count=0
|
||||
for i in range(stop):
|
||||
fee_today=0.;turnover=0.;sell_cash=0.;buy_cash=0.
|
||||
survivors=[]
|
||||
for lot in lots:
|
||||
ix,q,due,sig=lot
|
||||
if i>=due:
|
||||
sell=panel['can_sell'][i,ix]
|
||||
if i==due:delays+=int((~sell).sum())
|
||||
if sell.any():
|
||||
v=q[sell]*panel['open'][i,ix[sell]];fee=float(v.sum()*cost)
|
||||
cash+=float(v.sum())-fee;fee_today+=fee;turnover+=float(v.sum());sell_cash+=float(v.sum())-fee
|
||||
sell_count+=int(sell.sum())
|
||||
if detail:
|
||||
journal.extend({'day':i,'side':'sell','stock':int(j),'qty':float(qty),'price':float(price),'signal':sig}
|
||||
for j,qty,price in zip(ix[sell],q[sell],panel['open'][i,ix[sell]]))
|
||||
ix,q=ix[~sell],q[~sell]
|
||||
if len(ix):survivors.append((ix,q,due,sig))
|
||||
lots=survivors
|
||||
if i>0:
|
||||
chosen=np.flatnonzero(mask[i-1]);count=len(chosen)
|
||||
if count:
|
||||
available=panel['can_buy'][i,chosen];skipped+=int((~available).sum());ix=chosen[available]
|
||||
h=int(holds[i-1]);budget=min(max(cash,0),prev/h)
|
||||
if len(ix) and budget>0:
|
||||
each=budget/count/(1+cost);q=each/panel['open'][i,ix]
|
||||
value=each*len(ix);fee=value*cost
|
||||
cash-=value+fee;fee_today+=fee;turnover+=value;buy_cash=value+fee
|
||||
lots.append((ix,q,i+h,i-1));buy_count+=len(ix)
|
||||
if detail:
|
||||
journal.extend({'day':i,'side':'buy','stock':int(j),'qty':float(qty),'price':float(price),'signal':i-1}
|
||||
for j,qty,price in zip(ix,q,panel['open'][i,ix]))
|
||||
values=np.zeros(n)
|
||||
for ix,q,_,_ in lots:np.add.at(values,ix,q*panel['mark'][i,ix])
|
||||
value=float(values.sum());nav=cash+value;assert cash>=-1e-12 and nav>=0
|
||||
max_weight=max(max_weight,float(values.max()/nav) if nav else 0)
|
||||
max_positions=max(max_positions,int(np.count_nonzero(values)))
|
||||
max_stale_value=max(max_stale_value,float(values[~np.isfinite(panel['close'][i])].sum()))
|
||||
fees+=fee_today
|
||||
records.append({'date':str(panel['dates'][i]),'cash':cash,'stock_value':value,'nav':nav,'fee':fee_today,
|
||||
'turnover':turnover,'sell_cash':sell_cash,'buy_cash':buy_cash,'positions':int(np.count_nonzero(values))})
|
||||
prev=nav
|
||||
nav=np.array([1.]+[r['nav'] for r in records]);draw=nav/np.maximum.accumulate(nav)-1
|
||||
summary={'return':float(nav[-1]-1),'max_drawdown':float(draw.min()),'fees_initial_capital':fees,
|
||||
'buy_count':buy_count,'sell_count':sell_count,'skipped_buy':skipped,'delayed_lots':delays,
|
||||
'ending_cash':cash,'ending_stock_value':records[-1]['stock_value'],'open_lots':sum(len(x[0]) for x in lots),
|
||||
'max_stock_weight':max_weight,'max_positions':max_positions,'max_stale_valuation':max_stale_value,
|
||||
'mean_exposure':float(np.mean([r['stock_value']/r['nav'] for r in records if r['buy_cash'] or r['stock_value']])) if buy_count else 0}
|
||||
return {'summary':summary,'daily':records,'journal':journal}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 565 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 565 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 463 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 588 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 312 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 781 KiB |
|
|
@ -0,0 +1,34 @@
|
|||
"""核验分组加总、报告引用与交付摘要,不改研究计算口径。"""
|
||||
import datetime as dt,sys,re,ast
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import matplotlib
|
||||
from common import *
|
||||
def main():
|
||||
sys.addaudithook(offline);p,panel,f,cov=load();g=pd.read_csv(ROOT/'grid.csv.gz');keys=['config','hold','period']
|
||||
whole=g[g.phase_index=='all'].set_index(keys).sort_index();partition=[]
|
||||
for index in ['csi300','csi500','csi1000','csi2000']:
|
||||
z=g[g.phase_index==index].copy();z['weighted_gross']=z.mean_gross.fillna(0)*z.active_days
|
||||
aggregate=z.groupby(keys)[['phase_days','active_days','selected','filled','completed','unresolved','delayed','weighted_gross']].sum().sort_index()
|
||||
for field in ['phase_days','active_days','selected','filled','completed','unresolved','delayed']:assert np.array_equal(aggregate[field],whole[field])
|
||||
weighted=divide(aggregate.weighted_gross.to_numpy(),aggregate.active_days.to_numpy());assert np.allclose(weighted,whole.mean_gross.to_numpy(),atol=1e-12,equal_nan=True)
|
||||
partition.append(index)
|
||||
assert len(g)==201240
|
||||
assert np.all(g.mean_net60.dropna()<=g.mean_net30.dropna()+1e-14)
|
||||
assert np.all(g.mean_net30.dropna()<=g.mean_gross.dropna()+1e-14)
|
||||
assert not g[g.completed==0].mean_gross.notna().any()
|
||||
for name,sha in cov['source_sha256'].items():assert digest(ROOT.parent/name)==sha
|
||||
assert digest(ROOT/'cache/features.npz')==cov['features_sha256']
|
||||
dashboard=read(ROOT/'dashboard_manifest.json');assert digest(ROOT/'反复活跃矩阵浏览器.html')==dashboard['html_sha256'];assert digest(ROOT/'grid.csv.gz')==dashboard['data_source_sha256']
|
||||
links=0
|
||||
docs=[ROOT/'反复活跃与持有期矩阵研究.md',ROOT.parents[1]/'docs/反复活跃矩阵研究接续_2026-10-29.md',ROOT.parents[1]/'docs/开发入口.md',ROOT/'vendor/README.md']
|
||||
for path in docs:
|
||||
for dest in re.findall(r'!?\[[^\]]*\]\(([^)]+)\)',path.read_text()):
|
||||
if '://' not in dest and not dest.startswith('#'):assert (path.parent/dest.split('#')[0]).exists(),(path,dest);links+=1
|
||||
for path in ROOT.glob('*.py'):ast.parse(path.read_text())
|
||||
browser=read(ROOT/'browser_checks.json');assert not browser['external_requests'] and not browser['page_errors']
|
||||
files=[path for path in ROOT.rglob('*') if path.is_file() and not any(x in path.parts for x in ['cache','__pycache__']) and path.name!='manifest.json']
|
||||
result={'created_at_beijing':dt.datetime.now(dt.timezone(dt.timedelta(hours=8))).isoformat(),'protocol_sha256':digest(ROOT/'protocol.json'),'files_sha256':{str(path.relative_to(ROOT)):digest(path) for path in sorted(files)},'runtime':{'python':sys.version.split()[0],'numpy':np.__version__,'pandas':pd.__version__,'matplotlib':matplotlib.__version__},'grid_rows':len(g),'parameter_combinations':5160,'accounts':42,'phase_partitions_checked':partition,'cash_and_event_audit':'audit.json和calculation_checks.json','local_links_checked':links,'figures_checked':6,'browser_checks':len(browser['checks']),'new_database_access':False,'live_strategy_changes':False}
|
||||
dump(ROOT/'manifest.json',result);print({'files':len(files),'local_links':links,'phase_partitions':partition,'grid_rows':len(g),'figures':6,'browser_checks':len(browser['checks'])})
|
||||
if __name__=='__main__':main()
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"created_at_beijing": "2026-10-29T09:40:16.413536+08:00",
|
||||
"protocol_sha256": "b9b66b98d045638c76333ead2a141bcb4979d9905beca22c7211568a4f3e6389",
|
||||
"files_sha256": {
|
||||
".gitignore": "fba3161fc0773b7851ddc424b0e52a8a9bdd249cf70e6c274c84ea365c19f396",
|
||||
"account_daily.csv.gz": "73b4a410acb1abf7e988fe3b86c460ed168de1c21919d19dc4478047d472b277",
|
||||
"accounts.csv": "fc2bfc8dc5c2cf55ee8996f8c837331986ab7dc8b2482ddee47b2e05be43d1c7",
|
||||
"audit.json": "12878da951e92694b9e74755aeacc7477780fc72b13d5ba8b90e6846a6a62d96",
|
||||
"audit.py": "f686697b8b26d438cad5c8f4197b717bf815172a9195730cf220f2ad0b23205e",
|
||||
"browser_check.py": "31761d3b87565bed94ba1d183f0256ae9c194ce36e598976f7fe0e06facebac3",
|
||||
"browser_checks.json": "a3ce306763dcb96371e68b66178da7832f248f4ba2f4d033b52513bf89d0b22f",
|
||||
"build_dashboard.py": "83de0b99bffad8c5d19d636d96d4035cdcd1e4157818760dc238ae7ad8439ca4",
|
||||
"calculation_checks.json": "b80b634fec154b44b782f4c8cbed0eeae4eecdeadaccfe54eaae1a43cfaaef55",
|
||||
"calibrate.py": "8811fdeb4a8f2b6650c761143768a3f9b55dabf16575f713d5a35be6bbf432fe",
|
||||
"common.py": "4ded040da786cd1fe2610c44dbb339b0dd64aafd20b6ea7770d8393c6bfed254",
|
||||
"concentration.csv": "3c1808355a946dc8c473c93b8ed8b436a783c537f748cdaa8c6f840a354aefa9",
|
||||
"configurations.csv": "223e3fa0479ee39701adaa3ae66ba5e3b3dccb0b82f50eab480047c64ce16e6e",
|
||||
"coverage.json": "2dc09a6b7a4ad1e9f9c377bc00986fa42310cf485d814883dfbe065adcff914c",
|
||||
"dashboard.html.tpl": "2d01789fcd8179e3fd01a847e0272dda2423edfd40af8ffefabacef95e45fb4e",
|
||||
"dashboard_manifest.json": "388d337f635b2a0ef17497a70dea303472afc768cf11780aa68b4e0f41589505",
|
||||
"diagnostics.py": "07c79e4f43ea28778840b1f575b50d30a7795edc71756a172cafcc7502df38dd",
|
||||
"engine.py": "6e8f7b5fc97ba1353eaeda346111ff214ce53b33a846bddf2486167362be479d",
|
||||
"figures/smart_频次与持有期.png": "43abe8d2df6820cfa1dcea91315c91f89f8cef7bff1074c2f6cf2a33f044e0f1",
|
||||
"figures/total_频次与持有期.png": "0b86064a9a5e3b472ab1be86cadebe647a189a44f95950c08c9cea54e5a6ac0e",
|
||||
"figures/单日分数与持有期.png": "d9504b19c983d33820e82f377b3788965c096647db272f10addc9ee520e49f16",
|
||||
"figures/指数对照.png": "d7d056434cf7349ec324e3b8f94b81914e939ccbaafd2c825659d2ea4558089f",
|
||||
"figures/阈值与频次.png": "a0857bf00d63aaa6712d1f26c759a7019eb824a59c618edd75d6e8c7631d543d",
|
||||
"figures/阶段隔离.png": "71ebf481972941b45e3b2c5e06f9209660048df8db159a98e6dda637d6b835a2",
|
||||
"finalize.py": "8b2878a12657841fd2dff18c7965cb27e42d3caf1ef7c2fc6c9a7a9ff5b5d711",
|
||||
"focus_grid.csv": "eb78b4ed9cddd0533b378b3bc76f8e8a7a45a8ed832de2f8796b46203e228fc8",
|
||||
"grid.csv.gz": "3a666cb7ef9f5ddbe504334560daa6047272ba8005eb9be71b511cc321ce7d6e",
|
||||
"index_stages.csv": "ccb09586405ab210b42848d8944b543688fae63550344440e0a84888315ba4bb",
|
||||
"prepare.py": "8695b847a3e9c073c4468d9932e023ddecacf0148a4a56256417856fe6320c07",
|
||||
"protocol.json": "b9b66b98d045638c76333ead2a141bcb4979d9905beca22c7211568a4f3e6389",
|
||||
"protocol.sha256": "516b051a38122d22ca3f78c51874dc8dd63153661d7c2c93a00cb2808a84447e",
|
||||
"report.py": "d4773a4fd2eed2543a111e0da0f61add8f462ff00ca9ffa3a7cc55dd0840508d",
|
||||
"requirements-research.txt": "5b2f983fc693c6b94ad19800535c91df6802d9fde1fae882e11f42f591078c31",
|
||||
"test_recurrence.py": "dc64738ea240d21e053b1bdd9c8e076a6a1de1e9948c9dcf3723b4158bb98e2d",
|
||||
"uncertainty.json": "f303105b4373efee88727f54468098126a7bca53c24dc05e947338be631e7527",
|
||||
"vendor/LICENSE-Chart.js.md": "41a84aa2caba645f966a18d9c2056b73e6d3a81d80bc0046bc0011a2634d4cce",
|
||||
"vendor/README.md": "c9867f9b937f9eba14677088f7d1341f0d660fc3455ae0a8b3aff7dd635198d3",
|
||||
"vendor/chart.umd.js": "48444a82d4edcb5bec0f1965faacdde18d9c17db3063d042abada2f705c9f54a",
|
||||
"window_examples.csv": "c4782626431c7029d2bd7a17f4643e19b56d4403233d4c6a6f90209a8842c799",
|
||||
"反复活跃与持有期矩阵研究.md": "49c2cfa47a040584ddd72e884bdc924fd24de231ac5f5db59137268e53104b0e",
|
||||
"反复活跃矩阵浏览器.html": "7f9353fc6f3978826a0cd9dd1b6cdaf5ed09cdd1308b4e9725bd6d466775fed5"
|
||||
},
|
||||
"runtime": {
|
||||
"python": "3.12.14",
|
||||
"numpy": "2.3.5",
|
||||
"pandas": "2.2.3",
|
||||
"matplotlib": "3.11.2"
|
||||
},
|
||||
"grid_rows": 201240,
|
||||
"parameter_combinations": 5160,
|
||||
"accounts": 42,
|
||||
"phase_partitions_checked": [
|
||||
"csi300",
|
||||
"csi500",
|
||||
"csi1000",
|
||||
"csi2000"
|
||||
],
|
||||
"cash_and_event_audit": "audit.json和calculation_checks.json",
|
||||
"local_links_checked": 43,
|
||||
"figures_checked": 6,
|
||||
"browser_checks": 7,
|
||||
"new_database_access": false,
|
||||
"live_strategy_changes": false
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
"""保留上一轮行情和评分版本,新增滞后频次及四指数对照。"""
|
||||
import datetime as dt,sys
|
||||
from collections import Counter
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from common import *
|
||||
def main():
|
||||
sys.addaudithook(offline);p=read(ROOT/'protocol.json');assert digest(ROOT/'protocol.json')==(ROOT/'protocol.sha256').read_text().split()[0]
|
||||
oldcov=read(PREVIOUS/'coverage.json');sources={}
|
||||
def track(path):sources[str(path.relative_to(ROOT.parent))]=digest(path);return path
|
||||
panel=dict(np.load(track(PREVIOUS/'cache/panel.npz')));assert digest(PREVIOUS/'cache/panel.npz')==oldcov['panel_sha256']
|
||||
track(PREVIOUS/'coverage.json');track(PREVIOUS/'protocol.json');track(PREVIOUS/'engine.py')
|
||||
assert digest(ROOT/'engine.py')==digest(PREVIOUS/'engine.py')
|
||||
dates=panel['dates'];t,n=panel['open'].shape
|
||||
observed=np.isfinite(panel['total'])&np.isfinite(panel['smart'])
|
||||
# 上轮已核查本快照无全日降级;明确核验后再允许计数。
|
||||
assert oldcov['fallback_dates']==[]
|
||||
full=previous_counts(observed,p['lookback'])==20
|
||||
window=(dates>='2025-01-22')&(dates<='2026-09-30');base=panel['eligible']&full&window[:,None]
|
||||
groups=[];counts=[]
|
||||
for field in p['scores']:
|
||||
for q in p['thresholds']:groups.append(field+':'+str(q));counts.append(previous_counts(np.isfinite(panel[field])&(panel[field]>=q),20).astype(np.int8))
|
||||
export=read(track(OLD/'raw/export.json'))['data']['index_daily'];small=read(track(OLD/'raw/csi2000.json'))['data']['daily']['rows']
|
||||
stages=[];opens=[];rows=[]
|
||||
for key,symbol in p['phase_indices'].items():
|
||||
rr=small if key=='csi2000' else export[symbol]['rows'];r=regime(rr,dates.tolist());op={v['timestamp'][:10]:v['open'] for v in rr};aa=np.array([op[str(d)] for d in dates],float);assert np.isfinite(aa).all() and (aa>0).all()
|
||||
stages.append(r.stage.to_numpy());opens.append(aa)
|
||||
rows.extend({'date':str(d),'index':key,'open':float(aa[i]),'close':float(r.close.iloc[i]),'ma60':float(r.ma60.iloc[i]),'return20':float(r.return20.iloc[i]),'stage':int(r.stage.iloc[i])} for i,d in enumerate(dates))
|
||||
cache=ROOT/'cache';cache.mkdir(exist_ok=True)
|
||||
np.savez_compressed(cache/'features.npz',base=base,history_observed=full,counts=counts,group_keys=groups,window=window,index_names=list(p['phase_indices']),index_opens=opens,stages=stages)
|
||||
pd.DataFrame(rows).to_csv(ROOT/'index_stages.csv',index=False,lineterminator='\n')
|
||||
cfg=configuration();pd.DataFrame(cfg).to_csv(ROOT/'configurations.csv',index=False,lineterminator='\n')
|
||||
daily=[]
|
||||
for i,d in enumerate(dates):
|
||||
if window[i]:daily.append({'date':str(d),'previous_eligible':int(panel['eligible'][i].sum()),'common_eligible':int(base[i].sum()),'excluded_for_history':int((panel['eligible'][i]&~full[i]).sum())})
|
||||
cov={'created_at_beijing':dt.datetime.now(dt.timezone(dt.timedelta(hours=8))).isoformat(),'source_sha256':sources,'features_sha256':digest(cache/'features.npz'),'panel_shape':[t,n],'first_signal':'2025-01-22','last_signal':'2026-09-30','calendar_signal_days':int(window.sum()),'usable_signal_days':int(np.any(base,axis=1).sum()),'no_signal_dates':[r['date'] for r in daily if r['common_eligible']==0],'removed_stock_days_history':sum(r['excluded_for_history'] for r in daily),'daily':daily,'configurations':len(cfg),'combinations':len(cfg)*10,'previous_coverage':{'missing_listing_codes':oldcov['quality']['missing_listing_codes'],'missing_historical_name_stock_days':oldcov['quality']['missing_historical_name_stock_days'],'repairs':len(oldcov['repairs']),'missing_score_date':'2026-03-19'},'availability':'沿用不可验证首次可用时点的现存历史评分;本次未访问数据库'}
|
||||
dump(ROOT/'coverage.json',cov);print({k:v for k,v in cov.items() if k not in ['source_sha256','daily','no_signal_dates']})
|
||||
if __name__=='__main__':main()
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
"version": "1.0",
|
||||
"frozen_at_beijing": "2026-10-29T09:10:48.468127+08:00",
|
||||
"question": "隔离单个分数、前20交易日反复达标频次、持有1至10日、市场阶段与同期指数表现,以矩阵热力图比较",
|
||||
"data_snapshot": "沿用2026-10-28已导出评分和行情快照,不追加数据、不覆盖旧实验",
|
||||
"scores": [
|
||||
"total",
|
||||
"smart"
|
||||
],
|
||||
"thresholds": [
|
||||
0.5,
|
||||
0.6,
|
||||
0.7,
|
||||
0.8,
|
||||
0.9,
|
||||
0.95
|
||||
],
|
||||
"lookback": 20,
|
||||
"min_occurrences": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20
|
||||
],
|
||||
"holds": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10
|
||||
],
|
||||
"count_definition": "信号日t之前的20个交易日[t-20,t-1]中,原始分数>=阈值的日数;不含t,不要求连续;一次交易日最多计1次",
|
||||
"modes": {
|
||||
"current": "只要求当天该分数>=阈值",
|
||||
"frequency": "只要求此前20日达标次数>=K,当天不额外要求该分数达阈值",
|
||||
"both": "此前20日达标次数>=K,且当天该分数>=阈值"
|
||||
},
|
||||
"eligibility": "沿用上轮当日沪深A股资格;新增两项分数此前20交易日均可观察,以保证同一股票日对照。历史计数只看当日分数,不把缺分记0,不用未来是否继续达标筛选",
|
||||
"signal_window": "2025-01-22至2026-09-30;所有H共用;当日无评分或历史20日不全不开新批次",
|
||||
"outcome_cutoff": "2026-10-23",
|
||||
"periods": [
|
||||
"2025",
|
||||
"2026",
|
||||
"full"
|
||||
],
|
||||
"fees_bps_per_side": [
|
||||
0,
|
||||
30,
|
||||
60
|
||||
],
|
||||
"execution": "信号后下一交易日开盘买;买后H交易日开盘卖,H=1遵循T+1;受阻卖出顺延,未退出不纳入完成事件,但账户保留;重复信号独立批次不展期",
|
||||
"phase_indices": {
|
||||
"csi300": "000300.SH",
|
||||
"csi500": "000905.SH",
|
||||
"csi1000": "000852.SH",
|
||||
"csi2000": "932000.CSI"
|
||||
},
|
||||
"phase_rule": "截至信号日:收盘>=MA60且20日涨幅>0为上涨;收盘<MA60且20日涨幅<0为下跌;其他震荡。仅分组,不依阶段停止交易;均线含当日",
|
||||
"index_isolation": "阶段分类指数与收益对照指数是独立选择。股票池始终全市场,不假装已按历史成分股筛选。同期指数使用每只股票实际买入和卖出日的开盘比,先按同批股票再按信号日等权;指数差额是价格收益对照,不是beta中性alpha或可交易ETF收益",
|
||||
"metrics": "每批先等权,再对信号日等权;展示毛收益、30/60bp净收益、股票胜率、日均入选、有效信号日、完成/受阻/未退出笔数、相对同日K=0对照、四指数同期毛超额。无样本为缺值,不画成0",
|
||||
"isolation_controls": "frequency的K=0是完整历史合格池;both的K=0和current完全一致;增量按两组都有完成事件的同日相减;分阶段与指数对照不混用为同一变量",
|
||||
"figure_support": "有效成交信号日>=20且完成交易>=100的格子正常着色,其余灰色并可查看实际数值;图上区分净收益和超额;同组图使用一致色标",
|
||||
"fixed_focus": {
|
||||
"threshold": 0.8,
|
||||
"occurrence": 5,
|
||||
"phase_primary": "csi300",
|
||||
"phase_sensitivity": "csi2000"
|
||||
},
|
||||
"accounts": "仅预设总分或smart>=0.8,current/frequency K5/both K5,H1/5/10;加无门槛K0对照,2026现金账户,费用30/60bp,共42条;采用既有冻结引擎,不通过全样本最高格选账户",
|
||||
"selection": "不再择优训练参数;2025和2026分开作为已见历史的描述性复核。全网格的高收益单格必须连同样本量、费用、邻格和另一年份显示,不认定独立样本外",
|
||||
"limitations": [
|
||||
"历史分数可覆盖且无首次可用时间",
|
||||
"20日完整观察规则减少样本,须披露缺日影响",
|
||||
"历史资格与退市覆盖不全",
|
||||
"未完整建模整手、最低佣金和开盘容量",
|
||||
"事件样本重叠,股票数和参数组合不是独立样本"
|
||||
],
|
||||
"outputs": [
|
||||
"可独立打开的矩阵浏览器",
|
||||
"可导出PNG热力图",
|
||||
"协议、数据摘要、完整压缩CSV与逐日复现缓存",
|
||||
"中文报告与测试审计"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
b9b66b98d045638c76333ead2a141bcb4979d9905beca22c7211568a4f3e6389 protocol.json
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
"""生成可导出热力图及中文研究结论,不改变冻结的参数范围或账户。"""
|
||||
import sys,datetime as dt
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import font_manager
|
||||
from common import *
|
||||
SCORE={'total':'综合分 total_score','smart':'聪明资金分 smart_score'}
|
||||
MODE={'current':'仅当天达标','frequency':'仅历史频次','both':'历史频次且当天达标'}
|
||||
INDEX={'csi300':'沪深300','csi500':'中证500','csi1000':'中证1000','csi2000':'中证2000'}
|
||||
STAGE={99:'全部',-1:'下跌',0:'震荡',1:'上涨'}
|
||||
K=[0,1,3,5,8,10,15,20]
|
||||
def pct(v):return '—' if not np.isfinite(v) else f'{v*100:+.2f}%'
|
||||
def pp(v):return '—' if not np.isfinite(v) else f'{v*100:+.3f}'
|
||||
def table(headers,rows):return '\n'.join(['| '+' | '.join(headers)+' |','| '+' | '.join(['---']*len(headers))+' |']+['| '+' | '.join(map(str,r))+' |' for r in rows])
|
||||
def main():
|
||||
sys.addaudithook(offline);p=read(ROOT/'protocol.json');cov=read(ROOT/'coverage.json');audit=read(ROOT/'audit.json');unc=read(ROOT/'uncertainty.json');g=pd.read_csv(ROOT/'grid.csv.gz');accounts=pd.read_csv(ROOT/'accounts.csv');conc=pd.read_csv(ROOT/'concentration.csv',dtype={'period':str});figdir=ROOT/'figures';figdir.mkdir(exist_ok=True)
|
||||
for path in ['/System/Library/Fonts/STHeiti Light.ttc','/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc']:
|
||||
if Path(path).exists():font_manager.fontManager.addfont(path);plt.rcParams['font.family']=font_manager.FontProperties(fname=path).get_name();break
|
||||
plt.rcParams.update({'axes.unicode_minus':False,'font.size':11,'savefig.dpi':160,'axes.spines.top':False,'axes.spines.right':False})
|
||||
def select(score='smart',threshold=.8,mode='frequency',period='2026',phase_index='all',stage=99,**extra):
|
||||
z=g.copy(deep=False)
|
||||
for k,v in dict(score=score,threshold=threshold,mode=mode,period=period,phase_index=phase_index,stage=stage,**extra).items():
|
||||
if v is not None:z=z[z[k]==v]
|
||||
return z
|
||||
def row(**kwargs):return select(**kwargs).iloc[0]
|
||||
def heat(ax,z,y='k',x='hold',value='mean_net30',limit=3,title='',ylabel='此前20日达标次数下限 K',xlabel='持有交易日 H'):
|
||||
matrix=z.pivot(index=y,columns=x,values=value)*100;support=z.pivot(index=y,columns=x,values='supported');display=matrix.where(support)
|
||||
cmap=plt.get_cmap('RdBu_r').copy();cmap.set_bad('#e2e6eb');im=ax.imshow(display,cmap=cmap,vmin=-limit,vmax=limit,aspect='auto')
|
||||
ax.set_xticks(range(len(matrix.columns)),[f'{v:g}' for v in matrix.columns]);ax.set_yticks(range(len(matrix.index)),[f'{v:g}' for v in matrix.index]);ax.set_xlabel(xlabel);ax.set_ylabel(ylabel);ax.set_title(title)
|
||||
for i in range(len(matrix.index)):
|
||||
for j in range(len(matrix.columns)):
|
||||
v=matrix.iloc[i,j];ok=bool(support.iloc[i,j]);label='—' if not np.isfinite(v) else f'{v:+.2f}'+('' if ok else '*')
|
||||
ax.text(j,i,label,ha='center',va='center',fontsize=10,color='white' if ok and abs(v)>limit*.58 else '#293847')
|
||||
return im
|
||||
footer='每格为平均批次收益;灰格不足20个有效信号日或100笔完成交易。前20日不含当天;数据快照截至2026-10-23。'
|
||||
fig,axes=plt.subplots(2,2,figsize=(16,10),layout='constrained')
|
||||
for i,score in enumerate(['total','smart']):
|
||||
for j,period in enumerate(['2025','2026']):im=heat(axes[i,j],select(score=score,threshold=None,mode='current',period=period),y='threshold',limit=2,title=f'{period}年 · {SCORE[score]}',ylabel='当天分数下限')
|
||||
fig.colorbar(im,ax=axes,label='平均每批净收益(%,每边30基点)',shrink=.8);fig.suptitle('先只改变单日分数门槛与持有期\n使用与频次试验相同的完整20日历史观察池',fontsize=16);fig.supxlabel(footer,fontsize=10);fig.savefig(figdir/'单日分数与持有期.png');plt.close(fig)
|
||||
for score in ['total','smart']:
|
||||
fig,axes=plt.subplots(2,2,figsize=(16,12),layout='constrained')
|
||||
for i,mode in enumerate(['frequency','both']):
|
||||
for j,period in enumerate(['2025','2026']):im=heat(axes[i,j],select(score=score,mode=mode,period=period).query('k in @K'),limit=4,title=f'{period}年 · {MODE[mode]}')
|
||||
fig.colorbar(im,ax=axes,label='平均每批净收益(%,每边30基点;色标±4%)',shrink=.8);fig.suptitle(f'固定{SCORE[score]}≥0.8:历史次数 × 持有期\n2025与2026并排;静态图列出8档次数,浏览器提供全部0至20次',fontsize=16);fig.supxlabel(footer,fontsize=10);fig.savefig(figdir/f'{score}_频次与持有期.png');plt.close(fig)
|
||||
fig,axes=plt.subplots(2,3,figsize=(22,12),layout='constrained')
|
||||
for i,idx in enumerate(['csi300','csi2000']):
|
||||
for j,stage in enumerate([1,0,-1]):im=heat(axes[i,j],select(phase_index=idx,stage=stage).query('k in @K'),limit=4,title=f'{INDEX[idx]}划分 · {STAGE[stage]}阶段')
|
||||
fig.colorbar(im,ax=axes,label='平均每批净收益(%,每边30基点;色标±4%)',shrink=.8);fig.suptitle('隔离市场阶段:同样的smart≥0.8历史频次条件,2026年\n沪深300与中证2000只改变阶段归组,股票池与交易规则不变',fontsize=16);fig.supxlabel(footer,fontsize=10);fig.savefig(figdir/'阶段隔离.png');plt.close(fig)
|
||||
fig,axes=plt.subplots(2,2,figsize=(16,12),layout='constrained')
|
||||
for ax,idx in zip(axes.flat,INDEX):im=heat(ax,select().query('k in @K'),value='excess_'+idx,limit=3,title=f'相对{INDEX[idx]}的同期毛收益差')
|
||||
fig.colorbar(im,ax=axes,label='股票毛收益 − 同期指数价格收益(百分点)',shrink=.8);fig.suptitle('隔离指数对照:固定smart≥0.8、仅历史频次、2026年全部阶段\n每笔按实际买卖日对齐指数;差额不等于风险中性收益',fontsize=16);fig.supxlabel(footer,fontsize=10);fig.savefig(figdir/'指数对照.png');plt.close(fig)
|
||||
fig,axes=plt.subplots(1,3,figsize=(21,6),layout='constrained')
|
||||
for ax,h in zip(axes,[1,5,10]):im=heat(ax,select(threshold=None,hold=h).query('k in @K'),y='threshold',x='k',limit=4,title=f'持有{h}个交易日',ylabel='smart_score下限',xlabel='此前20日达标次数下限 K')
|
||||
fig.colorbar(im,ax=axes,label='平均每批净收益(%,每边30基点;色标±4%)',shrink=.8);fig.suptitle('固定持有期:分数阈值 × 历史达标次数\n2026年,仅历史频次,不要求当天分数仍达标',fontsize=16);fig.supxlabel(footer,fontsize=10);fig.savefig(figdir/'阈值与频次.png');plt.close(fig)
|
||||
# 用户可直接读取的固定条件H1..10表,不从全网格重新选最优点。
|
||||
hold_rows=[]
|
||||
for h in range(1,11):
|
||||
a=row(k=5,hold=h,period='2025');b=row(k=5,hold=h);c=row(k=5,hold=h,mode='both');hold_rows.append([h,pct(a.mean_net30),pct(b.mean_net30),pct(b.mean_net60),pp(b.delta_k0_net30),pct(c.mean_net30)])
|
||||
holdtable=table(['持有日','2025净收益','2026净收益','2026每边60bp','2026相对K=0,百分点','2026加当天达标'],hold_rows)
|
||||
comparison=table(['单独评分','规则(门槛0.8,持有5日)','2025每批净收益','2026每批净收益','2026日均入选'],[[SCORE[score],MODE[mode]+(',K≥5' if mode!='current' else ''),pct(row(score=score,mode=mode,k=0 if mode=='current' else 5,hold=5,period='2025').mean_net30),pct(row(score=score,mode=mode,k=0 if mode=='current' else 5,hold=5).mean_net30),f"{row(score=score,mode=mode,k=0 if mode=='current' else 5,hold=5).mean_selected:.1f}"] for score in ['total','smart'] for mode in ['current','frequency','both']])
|
||||
stage_table=table(['阶段指数','阶段','有效日','每批净收益','增加K≥5的改善,百分点'],[[INDEX[ix],STAGE[st],int(row(k=5,hold=5,phase_index=ix,stage=st).active_days),pct(row(k=5,hold=5,phase_index=ix,stage=st).mean_net30),pp(row(k=5,hold=5,phase_index=ix,stage=st).delta_k0_net30)] for ix in INDEX for st in [1,0,-1]])
|
||||
indexrow=row(k=5,hold=5);indextable=table(['同期对照指数','毛收益差,百分点','30bp净收益减指数毛收益,百分点'],[[name,pp(indexrow['excess_'+ix]),pp(indexrow['excess_'+ix]+indexrow.mean_net30-indexrow.mean_gross)] for ix,name in INDEX.items()])
|
||||
all26=g[(g.period=='2026')&(g.phase_index=='all')];supported=all26[all26.supported];pos=supported[supported.mean_net30>0];positive60=int((supported.mean_net60>0).sum())
|
||||
a=g[(g.period=='2025')&(g.phase_index=='all')&(g['mode']=='frequency')&(g.hold==5)&g.supported&(g.mean_net30>0)]
|
||||
b=g[(g.period=='2026')&(g.phase_index=='all')&(g['mode']=='frequency')&(g.hold==5)&g.supported&(g.mean_net30>0)]
|
||||
regions=a.merge(b,on=['config','score','threshold','mode','k','hold'],suffixes=('_25','_26')).sort_values(['score','threshold','k'])
|
||||
regiontable=table(['分数','阈值','20日最少次数','2025每批净收益','2026每批净收益','2026每边60bp','2026有效日 / 完成笔数','2026日均入选'],[[r.score,r.threshold,r.k,pct(r.mean_net30_25),pct(r.mean_net30_26),pct(r.mean_net60_26),f'{int(r.active_days_26)} / {int(r.completed_26)}',f'{r.mean_selected_26:.2f}'] for r in regions.itertuples()])
|
||||
rare=row(k=20,hold=5);rare25=row(k=20,hold=5,period='2025');con=conc[(conc.score=='smart')&(conc['mode']=='frequency')&(conc.k==20)&(conc.period=='2026')].iloc[0];u=next(r for r in unc if r['k']==20)
|
||||
accountrows=[]
|
||||
for name,label in [('universe','共同全市场池'),('total_current','总分,仅当天'),('total_frequency','总分,仅历史K≥5'),('total_both','总分,历史K≥5且当天'),('smart_current','聪明资金,仅当天'),('smart_frequency','聪明资金,仅历史K≥5'),('smart_both','聪明资金,历史K≥5且当天')]:
|
||||
def acct(fee):return accounts[(accounts.name==name)&(accounts.hold==5)&(accounts.fee_bps==fee)].iloc[0]
|
||||
x=acct(30);accountrows.append([label,pct(x['return']),pct(x.max_drawdown),pct(acct(60)['return']),int(x.open_lots)])
|
||||
accounttable=table(['规则,门槛0.8、持有5日','2026累计收益','最大回撤','每边60bp累计收益','期末残余批次股数'],accountrows)
|
||||
text=f'''# 反复活跃股票与持有期矩阵研究
|
||||
|
||||
日期:2026年10月29日。共同信号窗口为2025年1月22日至2026年9月30日,行情和退出估值截至2026年10月23日。沿用上一轮评分及行情快照,以便隔离变量;本轮未重新连接数据库,也未部署或修改运行策略。
|
||||
|
||||
## 先看矩阵浏览器
|
||||
|
||||
**[打开反复活跃矩阵浏览器](反复活跃矩阵浏览器.html)**。文件可在现代浏览器中直接打开,数据与绘图依赖全部内嵌,无需服务器或联网。完整结果包含5160组参数、39种年份与阶段分组,共201,240行。下载当前CSV或PNG可保留正在看的切片。
|
||||
|
||||
浏览器提供三种坐标:**分数门槛 × 持有日、前20日次数 × 持有日、分数门槛 × 前20日次数**。选择total_score或smart_score后,可独立切换“只看当天”“只看历史次数”“次数足够且当天达标”。年份默认并排展示2025和2026;阶段分类指数与收益对照指数是两个独立选择。点击任意格子,下方直接列出该门槛、该次数持有1至10日的明细。
|
||||
|
||||
**主要发现:反复活跃带来一些局部改善,但不是次数越多越好。** 2026年有{len(pos)}个组合在最低展示样本要求下的平均批次净收益为正,集中在较高频次且入选股票很少的区域;每边费用提高至60基点后剩{positive60}个。两项分数分开测试后,smart_score出现的正收益格更多。它们是相关、重复的参数切片,不能当作{len(pos)}次独立成功,也不能直接认定为可上线参数。
|
||||
|
||||
## 变量怎样隔离
|
||||
|
||||
本轮协议于{p['frozen_at_beijing'][:16].replace('T',' ')}北京时间冻结,见[protocol.json](protocol.json)。不叠加上一轮的双分数门槛、热度值或涨跌幅条件,不在计算后改变参数范围。
|
||||
|
||||
| 维度 | 本轮口径 |
|
||||
| --- | --- |
|
||||
| 分数 | total_score、smart_score分别单独测试 |
|
||||
| 分数下限q | 0.5、0.6、0.7、0.8、0.9、0.95,含边界 |
|
||||
| 历史窗口 | 信号日前20个交易日,不含信号当天 |
|
||||
| 最少达标次数K | 0至20全部整数,含边界,不要求连续 |
|
||||
| 交易条件 | 仅当天达标;仅历史次数;历史次数足够且当天达标 |
|
||||
| 持有期H | 1至10个交易日,所有H共用信号末日 |
|
||||
| 市场阶段 | 当日及以前的沪深300、中证500、中证1000、中证2000趋势分别划分 |
|
||||
| 收益对照 | 四个指数分别与实际股票持有区间对齐 |
|
||||
| 费用 | 每边0、30、60基点;0只展示毛收益 |
|
||||
|
||||
对某只股票、某个信号日t,次数等于t−20至t−1这20个交易日内“分数≥q”的天数。例如K≥5表示此前20日最少5日达标,可能连续也可能分散;它并非“超过5次”,若需要严格超过5次,应在浏览器选K=6。K=20才意味着前20个交易日全部达标。示例原始窗口见[window_examples.csv](window_examples.csv),按预设日期和股票代码顺序取例,没有根据后续收益挑股票。
|
||||
|
||||
“仅历史次数”的K=0是同一可观察股票池;“历史次数且当天达标”的K=0与“仅当天达标”完全相同。增加频次门槛的改善,按两种条件都有完成交易的同一信号日相减,防止因为不交易的日期不同而混入择日效果。完整年份均值仍各自在有交易日内等权,不能将两个年度均值直接相减冒充配对改善。
|
||||
|
||||
本轮“隔离指数”是固定股票池,分别改变阶段分类和同期收益对照,**没有声称已按历史指数成分股筛选,也没有做市场风险回归或beta中性化**。同期收益差不能等同于纯选股alpha。
|
||||
|
||||
## 完整20日观察的样本代价
|
||||
|
||||
评分历史从2024年12月24日开始,因此最早拥有完整前20个交易日的信号日是2025年1月22日。共同区间410个交易日中有389日能够形成信号:2025年229日,2026年160日。2026年3月19日整日评分缺失,当日及其后20个交易日不满足共同观察要求。
|
||||
|
||||
缺失评分不能记成“当天没有达标”。本轮要求此前20个交易日的两项分数都可观察,并将当天单因子对照限制在同一股票日池;相较已有当日合格池,历史观察要求排除{cov['removed_stock_days_history']:,}个股票日。历史次数只统计原始分数,上市时长、历史名称、ST及价格资格在信号日另行检查。
|
||||
|
||||
因此本轮2026结果不能与上一轮直接比较数值高低来判断变量有效;上轮的部分交易日期被共同观察要求剔除。复原旧日期范围后,单因子基线在1、5、10日均精确复现。数据与源摘要见[coverage.json](coverage.json)。历史上市日期缺失78只、名称缺失3536个股票日及此前12条行情补缺均沿用,未用未来成分股名单选择股票。
|
||||
|
||||
## 先固定一个分数,比较持有1至10日
|
||||
|
||||
下面只使用信号当天的一个分数,历史20日仅用于统一可观察样本,不作为次数筛选。
|
||||
|
||||

|
||||
|
||||
如果希望直接读一组具体条件,以下固定 **smart_score≥0.8、前20日达标至少5次**。主列不要求当天仍达标,末列专门检验再加当天条件。数字为每个信号日先对完成交易等权,再对信号日等权的平均单批收益,不是现金账户累计收益;每边30基点为主口径。
|
||||
|
||||
{holdtable}
|
||||
|
||||
2025年延长持有期改善了这个条件的平均结果,2026年则未延续。仅凭2025年较长持有期的红色区域,不能把10日设为已验证最优持有期。
|
||||
|
||||
## 历史次数是否提供额外信息
|
||||
|
||||
以下统一分数门槛0.8、持有5日。三种规则都使用同一个完整历史观察池,差别只在是否需要历史频次、当天是否达标。
|
||||
|
||||
{comparison}
|
||||
|
||||
smart≥0.8、历史至少5次在2026年的平均每批净收益为{pct(indexrow.mean_net30)},相对K=0对照改善{pp(indexrow.delta_k0_net30)}个百分点;其10日整块抽样的超额95%描述区间跨越0。再要求当天达标后,相对“只看当天”的改善约为{pp(row(mode='both',k=5,hold=5).delta_k0_net30)}个百分点,没有延续同样改善。total_score对应的K≥5条件也没有在2026年稳定改善对照。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
静态图选取0、1、3、5、8、10、15、20次便于阅读;浏览器提供全部21档次数。每组图内色标一致,色标超出范围时只截断颜色,不改写单格数值。灰格表示不足20个有效信号日或100笔已结束交易,星号仍保留实际观察值;达到这个展示门槛并不代表统计可靠。
|
||||
|
||||
## 固定持有期,再看门槛与次数组合
|
||||
|
||||

|
||||
|
||||
正收益区域值得继续检查,不能因为上一轮结果为负而忽略。本轮固定持有5日、只按历史频次筛选,在2025与2026两年都为正、且满足最低展示样本要求的组合如下。这张表是看过全部结果后的描述性筛选,**不是新训练出的独立验证参数**,也没有据此追加“冠军账户”。
|
||||
|
||||
{regiontable}
|
||||
|
||||
这些条件在2026年日均只入选约1.7至4.2只股票,频繁重复同一股票的日信号。更高次数既改变选股特征,也大幅改变分散度和交易日期。不能把“平均每批为正”直接等同于持续满仓可赚钱。
|
||||
|
||||
以预设门槛0.8下的K=20、持有5日为例:2026平均单批净收益{pct(rare.mean_net30)},但2025为{pct(rare25.mean_net30)}。2026只包含{int(con.active_days)}个有完成交易的信号日、{int(con.completed)}笔交易、{int(con.unique_stocks)}只不同股票;有完成交易的信号日,每日完成交易股票数中位数只有{con.median_stocks_on_active_day:.0f}只,前5只股票贡献了{con.top5_event_share*100:.1f}%的事件数量。10日整块抽样的净收益区间为[{pct(u['net30_block10_interval'][0])}, {pct(u['net30_block10_interval'][1])}],相对K=0的区间也跨0。抽样没有解决版本回填、多参数扫描或重叠持仓的全部偏差,不能作为显著性证明。详见[集中度](concentration.csv)和[描述性区间](uncertainty.json)。
|
||||
|
||||
## 市场阶段与收益指数分开看
|
||||
|
||||
上涨阶段定义为收盘不低于60日均线且近20日收益为正;下跌为收盘低于60日均线且近20日收益为负;其他为震荡。均线含信号日,预热使用更早指数历史,不使用未来价格。每笔按信号日阶段归组,持有过程中不因阶段变化强平。
|
||||
|
||||
以下固定smart≥0.8、前20日至少5次、持有5日、2026年,分别改变阶段分类指数。其“改善”均相对同日同持有期的K=0全市场对照。
|
||||
|
||||
{stage_table}
|
||||
|
||||
同一条件按沪深300划分,下跌阶段的平均结果为{pct(row(k=5,hold=5,phase_index='csi300',stage=-1).mean_net30)};按中证500划分,变为{pct(row(k=5,hold=5,phase_index='csi500',stage=-1).mean_net30)}。差别主要在于哪些日期被分入该阶段,不能据此认定某个指数能使同一组股票自动变得更有收益。
|
||||
|
||||

|
||||
|
||||
保持全部阶段不变,再单独切换同期收益对照指数,得到下表。对每只已完成交易,指数买入日和卖出日与该股票一致,卖出受阻的延期也同步延长;先对股票等权,再对信号日等权。指数毛收益与股票毛收益的差用于观察相对价格表现,净收益减指数毛收益则另行包含策略摩擦,两者不能混用。
|
||||
|
||||
{indextable}
|
||||
|
||||

|
||||
|
||||
## 现金账户和交易可实现性
|
||||
|
||||
预先约定的账户只选择分数0.8、历史5次这个固定展示条件,分别运行H=1、5、10及每边30/60基点;两个分数的三种规则,加一个共同股票池对照,共42条账户。没有用全网格的事后最高收益点挑账户。以下为2026年、持有5日的结果。
|
||||
|
||||
{accounttable}
|
||||
|
||||
账户每天先卖后买,新批次预算以前收资产/H计算且不超过现金;每个信号独立批次,旧批次不展期。入选等额分配,可买部分不重新分配失败股票的预算。开盘涨跌停、停牌、风险标记和缺报价保留原限制;计划持有上限10日,受阻退出可能超过10日。原始事件研究没有将未卖出股票算作已完成盈利,现金账户会保留并估值。长期缺价超过20日按原规则暂记0,不等于实际清仓。
|
||||
|
||||
仍采用可分割复权单位,未完整建模整手、最低佣金、开盘冲击和实际资金规模。尤其正收益小区域常只有少数股票,个股集中与可成交规模是后续必须单独核验的变量。账户的平均资金暴露、残仓、费用和回撤详见[accounts.csv](accounts.csv)。
|
||||
|
||||
## 这轮能够支持的判断
|
||||
|
||||
反复活跃值得作为单独研究变量保留,已有局部改善和少数跨年正收益区域;但目前还不能给出不受阶段、费用与稀疏样本影响的稳定门槛。下一步可围绕图中相邻区域做事先冻结的验证,并加入真实资金规模下的集中度、整手与成交容量约束,不能一边查看本次结果一边把参数重新称作未见样本验证。
|
||||
|
||||
源表缺首次可用时刻、允许覆盖旧日期的问题仍未解决。本轮的20日历史计数只是对现存分数快照逐日回放,不证明历史20日内当时就已获得这些分数。需要保存不可覆盖的评分版本与首次可用时间,才能补强时序证据。市场阶段分组和同期指数差额也不能消除所有风格、行业、个股质量等混杂因素。
|
||||
|
||||
## 验证和复现
|
||||
|
||||
开发机通过9项隔离配置、禁止联网的内存测试;真实缓存另做1200次直接20日窗口计数、所有门槛历史前缀检查、6项旧单因子基线复现、36项实际退出日期指数对齐核验。3个预设账户独立逐笔重建现金、持仓和估值,最大误差{max(r['error'] for r in audit['ledger_rebuilds']):.3g}。42条账户现金守恒通过,21条30基点账户前缀与截断运行一致。详情见[audit.json](audit.json)及[calculation_checks.json](calculation_checks.json)。
|
||||
|
||||
矩阵浏览器使用本机Chrome检查默认双年视图、切换三种坐标、独立阶段与基准选择、CSV及PNG导出和手机布局,外部请求为0。详情见[browser_checks.json](browser_checks.json)。静态图已检查标注、单位和色标。研究只在开发机运行,不构成155服务、QMT成交或真实交易验收,没有修改生产代码或容器。
|
||||
|
||||
完整压缩明细见[grid.csv.gz](grid.csv.gz),预设0.8切片见[focus_grid.csv](focus_grid.csv),四指数逐日阶段见[index_stages.csv](index_stages.csv),界面结果映射见[dashboard_manifest.json](dashboard_manifest.json)。原始行情、评分和派生逐日缓存不入Git;所依赖的旧快照和代码均记录摘要。依赖与版本见[requirements-research.txt](requirements-research.txt),复现顺序如下:
|
||||
|
||||
```bash
|
||||
python research/score_recurrence_20261029/prepare.py
|
||||
python research/score_recurrence_20261029/calibrate.py
|
||||
python scripts/unit_test_guard.py research/score_recurrence_20261029/test_recurrence.py
|
||||
python scripts/unit_test_guard.py research/score_recurrence_20261029/audit.py
|
||||
python research/score_recurrence_20261029/diagnostics.py
|
||||
python research/score_recurrence_20261029/build_dashboard.py
|
||||
python research/score_recurrence_20261029/report.py
|
||||
python research/score_recurrence_20261029/browser_check.py
|
||||
python research/score_recurrence_20261029/finalize.py
|
||||
```
|
||||
|
||||
浏览器核验依赖本机Chrome路径;其他平台应改为本机浏览器可执行文件。CSV收益为原比例,图中收益为百分比、差额为百分点;stage=-1/0/1代表下跌/震荡/上涨,99为全部。所有统计均为已见历史的探索性比较,未输出年化“最优收益”。
|
||||
'''
|
||||
(ROOT/'反复活跃与持有期矩阵研究.md').write_text(text)
|
||||
print('报告和6幅PNG已生成')
|
||||
if __name__=='__main__':main()
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
numpy==2.3.5
|
||||
pandas==2.2.3
|
||||
matplotlib==3.11.2
|
||||
# 仅本地浏览器核验使用;计算和HTML浏览不需要此依赖。
|
||||
playwright==1.64.1
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
"""仅内存数据,必须经unit_test_guard隔离运行。"""
|
||||
import unittest
|
||||
import numpy as np
|
||||
from common import previous_counts,aggregate,mask_for,regime
|
||||
from engine import account,future_exits
|
||||
class RecurrenceTests(unittest.TestCase):
|
||||
def test_excludes_signal_day(self):
|
||||
hits=np.zeros((24,1),bool);hits[0]=True;hits[20]=True
|
||||
c=previous_counts(hits);self.assertEqual(c[19,0],-1);self.assertEqual(c[20,0],1);self.assertEqual(c[21,0],1)
|
||||
hits[20]=False;self.assertEqual(previous_counts(hits)[20,0],1)
|
||||
def test_window_rolls_exactly_twenty(self):
|
||||
hits=np.zeros((43,1),bool);hits[1:21]=True;c=previous_counts(hits)
|
||||
self.assertEqual(c[21,0],20);self.assertEqual(c[22,0],19);self.assertEqual(c[41,0],0)
|
||||
def test_missing_observation_is_not_a_failed_signal(self):
|
||||
v=np.full((42,1),.9);v[20]=np.nan;observed=previous_counts(np.isfinite(v))==20
|
||||
self.assertTrue(observed[20,0]);self.assertFalse(observed[21,0]);self.assertFalse(observed[40,0]);self.assertTrue(observed[41,0])
|
||||
def test_today_gate_is_independent(self):
|
||||
panel={'smart':np.array([[.2,.9]])};f={'base':np.ones((1,2),bool),'counts':np.array([[[5,4]]]),'group_keys':np.array(['smart:0.8'])}
|
||||
c={'score':'smart','threshold':.8,'k':5,'mode':'frequency'};self.assertEqual(mask_for(panel,f,c).tolist(),[[True,False]])
|
||||
c['mode']='both';self.assertEqual(mask_for(panel,f,c).tolist(),[[False,False]])
|
||||
c['mode']='current';self.assertEqual(mask_for(panel,f,c).tolist(),[[False,True]])
|
||||
def test_bin_accumulation_and_boundary(self):
|
||||
counts=np.array([[0,1,5,20]]);today=np.array([[False,True,False,True]]);ids=today.astype(int)*21+counts
|
||||
result=aggregate(ids,np.ones(ids.shape,bool),None,1)
|
||||
for k in range(21):self.assertEqual(result[0,k+1],(counts>=k).sum());self.assertEqual(result[0,k+22],((counts>=k)&today).sum())
|
||||
self.assertEqual(result[0,0],result[0,22]);self.assertEqual(result[0,1],4)
|
||||
def test_future_scores_do_not_change_past_counts(self):
|
||||
rng=np.random.default_rng(8);hits=rng.random((90,4))>.5;a=previous_counts(hits);hits[60:]=False
|
||||
self.assertTrue(np.array_equal(a[:61],previous_counts(hits)[:61]));self.assertTrue(np.array_equal(a[:60],previous_counts(hits[:60])))
|
||||
def test_phase_prefix_uses_no_future(self):
|
||||
import pandas as pd
|
||||
ds=pd.bdate_range('2024-01-01',periods=100).strftime('%Y-%m-%d').tolist();rows=[{'timestamp':d,'close':100+i} for i,d in enumerate(ds)]
|
||||
self.assertTrue(regime(rows,ds[60:80]).equals(regime(rows[:80],ds[60:80])))
|
||||
def test_t_plus_one_fee_and_delayed_sell(self):
|
||||
t=8;p={k:np.full((t,1),10.) for k in ['open','close','mark']};p.update(can_buy=np.ones((t,1),bool),can_sell=np.ones((t,1),bool),dates=np.arange(t).astype(str))
|
||||
p['can_sell'][2:4]=False;p['open'][4]=12;m=np.zeros((t,1),bool);m[0]=True
|
||||
a=account(p,m,1,.003,detail=True);ex,gr=future_exits(p,1)
|
||||
self.assertEqual([(x['day'],x['side']) for x in a['journal']],[(1,'buy'),(4,'sell')]);self.assertEqual(ex[0,0],4)
|
||||
self.assertAlmostEqual(a['summary']['return'],1.2*.997/1.003-1);self.assertAlmostEqual(gr[0,0],1.2)
|
||||
def test_blocked_buy_retains_allocation(self):
|
||||
t=8;p={k:np.full((t,2),10.) for k in ['open','close','mark']};p.update(can_buy=np.ones((t,2),bool),can_sell=np.ones((t,2),bool),dates=np.arange(t).astype(str))
|
||||
p['can_buy'][1,0]=False;m=np.zeros((t,2),bool);m[0]=True;a=account(p,m,1,0)
|
||||
self.assertAlmostEqual(a['daily'][1]['cash'],.5)
|
||||
if __name__=='__main__':unittest.main()
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
[
|
||||
{
|
||||
"config": 393,
|
||||
"score": "smart",
|
||||
"threshold": 0.8,
|
||||
"mode": "frequency",
|
||||
"k": 5,
|
||||
"period": "2026",
|
||||
"hold": 5,
|
||||
"mean_net30": -0.008373789434859908,
|
||||
"net30_block10_interval": [
|
||||
-0.020650184458110586,
|
||||
0.004438762731283945
|
||||
],
|
||||
"excess_k0": 0.0006176216981504133,
|
||||
"excess_block10_interval": [
|
||||
-0.0033356150069096513,
|
||||
0.004244572004834594
|
||||
]
|
||||
},
|
||||
{
|
||||
"config": 398,
|
||||
"score": "smart",
|
||||
"threshold": 0.8,
|
||||
"mode": "frequency",
|
||||
"k": 10,
|
||||
"period": "2026",
|
||||
"hold": 5,
|
||||
"mean_net30": -0.0069641552784366414,
|
||||
"net30_block10_interval": [
|
||||
-0.020637707029501972,
|
||||
0.0062632176111741
|
||||
],
|
||||
"excess_k0": 0.00202725585457368,
|
||||
"excess_block10_interval": [
|
||||
-0.003435122962526486,
|
||||
0.007134091396110073
|
||||
]
|
||||
},
|
||||
{
|
||||
"config": 408,
|
||||
"score": "smart",
|
||||
"threshold": 0.8,
|
||||
"mode": "frequency",
|
||||
"k": 20,
|
||||
"period": "2026",
|
||||
"hold": 5,
|
||||
"mean_net30": 0.008894139316834889,
|
||||
"net30_block10_interval": [
|
||||
-0.01892966947918145,
|
||||
0.04806049061717558
|
||||
],
|
||||
"excess_k0": 0.012032946367850404,
|
||||
"excess_block10_interval": [
|
||||
-0.004066783793032734,
|
||||
0.03558626775562023
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2024 Chart.js Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# 本地绘图依赖
|
||||
|
||||
Chart.js固定为4.5.1,用于可离线打开的研究热力图。源文件在构建浏览器时内嵌,不从用户浏览器请求远程资源。
|
||||
|
||||
- 来源:https://cdn.jsdelivr.net/npm/chart.js@4.5.1/dist/chart.umd.min.js
|
||||
- SHA-384:`jb8JQMbMoBUzgWatfe6COACi2ljcDdZQ2OxczGA3bGNeWe+6DChMTBJemed7ZnvJ`
|
||||
- 构建程序验证上述摘要。保留原版权头,完整许可证见[LICENSE-Chart.js.md](LICENSE-Chart.js.md)。
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,61 @@
|
|||
signal_date,stock,historical_date,smart_score,hit_ge_0_8,prior20_hits,signal_day_score
|
||||
2026-08-31,000001.SZ,2026-08-03,0.987584,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-04,0.988448,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-05,0.990477,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-06,0.991776,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-07,0.992931,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-10,0.991926,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-11,0.610433,False,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-12,0.605934,False,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-13,0.845096,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-14,0.833846,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-17,0.812813,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-18,0.780396,False,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-19,0.838946,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-20,0.80562,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-21,0.78579,False,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-24,0.658059,False,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-25,0.739325,False,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-26,0.859543,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-27,0.879224,True,14,0.943612
|
||||
2026-08-31,000001.SZ,2026-08-28,0.885299,True,14,0.943612
|
||||
2026-08-31,000002.SZ,2026-08-03,0.600626,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-04,0.58197,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-05,0.54242,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-06,0.491439,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-07,0.424072,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-10,0.345636,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-11,0.25976,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-12,0.67162,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-13,0.81274,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-14,0.89399,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-17,0.936466,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-18,0.959311,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-19,0.675919,False,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-20,0.957323,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-21,0.961612,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-24,0.966099,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-25,0.9686,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-26,0.891753,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-27,0.891225,True,11,0.950048
|
||||
2026-08-31,000002.SZ,2026-08-28,0.95218,True,11,0.950048
|
||||
2026-08-31,000006.SZ,2026-08-03,0.520019,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-04,0.500963,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-05,0.52097,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-06,0.455896,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-07,0.462877,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-10,0.569108,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-11,0.653173,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-12,0.515917,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-13,0.772404,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-14,0.788654,False,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-17,0.800356,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-18,0.822432,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-19,0.856311,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-20,0.815098,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-21,0.84188,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-24,0.835257,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-25,0.856367,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-26,0.865111,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-27,0.896937,True,9,0.641258
|
||||
2026-08-31,000006.SZ,2026-08-28,0.644229,False,9,0.641258
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
# 反复活跃股票与持有期矩阵研究
|
||||
|
||||
日期:2026年10月29日。共同信号窗口为2025年1月22日至2026年9月30日,行情和退出估值截至2026年10月23日。沿用上一轮评分及行情快照,以便隔离变量;本轮未重新连接数据库,也未部署或修改运行策略。
|
||||
|
||||
## 先看矩阵浏览器
|
||||
|
||||
**[打开反复活跃矩阵浏览器](反复活跃矩阵浏览器.html)**。文件可在现代浏览器中直接打开,数据与绘图依赖全部内嵌,无需服务器或联网。完整结果包含5160组参数、39种年份与阶段分组,共201,240行。下载当前CSV或PNG可保留正在看的切片。
|
||||
|
||||
浏览器提供三种坐标:**分数门槛 × 持有日、前20日次数 × 持有日、分数门槛 × 前20日次数**。选择total_score或smart_score后,可独立切换“只看当天”“只看历史次数”“次数足够且当天达标”。年份默认并排展示2025和2026;阶段分类指数与收益对照指数是两个独立选择。点击任意格子,下方直接列出该门槛、该次数持有1至10日的明细。
|
||||
|
||||
**主要发现:反复活跃带来一些局部改善,但不是次数越多越好。** 2026年有94个组合在最低展示样本要求下的平均批次净收益为正,集中在较高频次且入选股票很少的区域;每边费用提高至60基点后剩44个。两项分数分开测试后,smart_score出现的正收益格更多。它们是相关、重复的参数切片,不能当作94次独立成功,也不能直接认定为可上线参数。
|
||||
|
||||
## 变量怎样隔离
|
||||
|
||||
本轮协议于2026-10-29 09:10北京时间冻结,见[protocol.json](protocol.json)。不叠加上一轮的双分数门槛、热度值或涨跌幅条件,不在计算后改变参数范围。
|
||||
|
||||
| 维度 | 本轮口径 |
|
||||
| --- | --- |
|
||||
| 分数 | total_score、smart_score分别单独测试 |
|
||||
| 分数下限q | 0.5、0.6、0.7、0.8、0.9、0.95,含边界 |
|
||||
| 历史窗口 | 信号日前20个交易日,不含信号当天 |
|
||||
| 最少达标次数K | 0至20全部整数,含边界,不要求连续 |
|
||||
| 交易条件 | 仅当天达标;仅历史次数;历史次数足够且当天达标 |
|
||||
| 持有期H | 1至10个交易日,所有H共用信号末日 |
|
||||
| 市场阶段 | 当日及以前的沪深300、中证500、中证1000、中证2000趋势分别划分 |
|
||||
| 收益对照 | 四个指数分别与实际股票持有区间对齐 |
|
||||
| 费用 | 每边0、30、60基点;0只展示毛收益 |
|
||||
|
||||
对某只股票、某个信号日t,次数等于t−20至t−1这20个交易日内“分数≥q”的天数。例如K≥5表示此前20日最少5日达标,可能连续也可能分散;它并非“超过5次”,若需要严格超过5次,应在浏览器选K=6。K=20才意味着前20个交易日全部达标。示例原始窗口见[window_examples.csv](window_examples.csv),按预设日期和股票代码顺序取例,没有根据后续收益挑股票。
|
||||
|
||||
“仅历史次数”的K=0是同一可观察股票池;“历史次数且当天达标”的K=0与“仅当天达标”完全相同。增加频次门槛的改善,按两种条件都有完成交易的同一信号日相减,防止因为不交易的日期不同而混入择日效果。完整年份均值仍各自在有交易日内等权,不能将两个年度均值直接相减冒充配对改善。
|
||||
|
||||
本轮“隔离指数”是固定股票池,分别改变阶段分类和同期收益对照,**没有声称已按历史指数成分股筛选,也没有做市场风险回归或beta中性化**。同期收益差不能等同于纯选股alpha。
|
||||
|
||||
## 完整20日观察的样本代价
|
||||
|
||||
评分历史从2024年12月24日开始,因此最早拥有完整前20个交易日的信号日是2025年1月22日。共同区间410个交易日中有389日能够形成信号:2025年229日,2026年160日。2026年3月19日整日评分缺失,当日及其后20个交易日不满足共同观察要求。
|
||||
|
||||
缺失评分不能记成“当天没有达标”。本轮要求此前20个交易日的两项分数都可观察,并将当天单因子对照限制在同一股票日池;相较已有当日合格池,历史观察要求排除115,570个股票日。历史次数只统计原始分数,上市时长、历史名称、ST及价格资格在信号日另行检查。
|
||||
|
||||
因此本轮2026结果不能与上一轮直接比较数值高低来判断变量有效;上轮的部分交易日期被共同观察要求剔除。复原旧日期范围后,单因子基线在1、5、10日均精确复现。数据与源摘要见[coverage.json](coverage.json)。历史上市日期缺失78只、名称缺失3536个股票日及此前12条行情补缺均沿用,未用未来成分股名单选择股票。
|
||||
|
||||
## 先固定一个分数,比较持有1至10日
|
||||
|
||||
下面只使用信号当天的一个分数,历史20日仅用于统一可观察样本,不作为次数筛选。
|
||||
|
||||

|
||||
|
||||
如果希望直接读一组具体条件,以下固定 **smart_score≥0.8、前20日达标至少5次**。主列不要求当天仍达标,末列专门检验再加当天条件。数字为每个信号日先对完成交易等权,再对信号日等权的平均单批收益,不是现金账户累计收益;每边30基点为主口径。
|
||||
|
||||
| 持有日 | 2025净收益 | 2026净收益 | 2026每边60bp | 2026相对K=0,百分点 | 2026加当天达标 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 1 | -0.40% | -0.61% | -1.20% | +0.018 | -0.61% |
|
||||
| 2 | -0.20% | -0.64% | -1.24% | +0.034 | -0.67% |
|
||||
| 3 | -0.00% | -0.72% | -1.31% | +0.041 | -0.74% |
|
||||
| 4 | +0.20% | -0.77% | -1.36% | +0.051 | -0.77% |
|
||||
| 5 | +0.41% | -0.84% | -1.43% | +0.062 | -0.88% |
|
||||
| 6 | +0.62% | -0.94% | -1.53% | +0.075 | -1.00% |
|
||||
| 7 | +0.82% | -1.03% | -1.62% | +0.081 | -1.06% |
|
||||
| 8 | +1.00% | -1.11% | -1.71% | +0.086 | -1.16% |
|
||||
| 9 | +1.19% | -1.21% | -1.80% | +0.082 | -1.23% |
|
||||
| 10 | +1.38% | -1.31% | -1.90% | +0.077 | -1.31% |
|
||||
|
||||
2025年延长持有期改善了这个条件的平均结果,2026年则未延续。仅凭2025年较长持有期的红色区域,不能把10日设为已验证最优持有期。
|
||||
|
||||
## 历史次数是否提供额外信息
|
||||
|
||||
以下统一分数门槛0.8、持有5日。三种规则都使用同一个完整历史观察池,差别只在是否需要历史频次、当天是否达标。
|
||||
|
||||
| 单独评分 | 规则(门槛0.8,持有5日) | 2025每批净收益 | 2026每批净收益 | 2026日均入选 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 综合分 total_score | 仅当天达标 | +0.30% | -0.97% | 868.7 |
|
||||
| 综合分 total_score | 仅历史频次,K≥5 | +0.30% | -0.91% | 1607.4 |
|
||||
| 综合分 total_score | 历史频次且当天达标,K≥5 | +0.35% | -0.98% | 524.6 |
|
||||
| 聪明资金分 smart_score | 仅当天达标 | +0.35% | -0.88% | 483.1 |
|
||||
| 聪明资金分 smart_score | 仅历史频次,K≥5 | +0.41% | -0.84% | 798.5 |
|
||||
| 聪明资金分 smart_score | 历史频次且当天达标,K≥5 | +0.46% | -0.88% | 208.5 |
|
||||
|
||||
smart≥0.8、历史至少5次在2026年的平均每批净收益为-0.84%,相对K=0对照改善+0.062个百分点;其10日整块抽样的超额95%描述区间跨越0。再要求当天达标后,相对“只看当天”的改善约为-0.004个百分点,没有延续同样改善。total_score对应的K≥5条件也没有在2026年稳定改善对照。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
静态图选取0、1、3、5、8、10、15、20次便于阅读;浏览器提供全部21档次数。每组图内色标一致,色标超出范围时只截断颜色,不改写单格数值。灰格表示不足20个有效信号日或100笔已结束交易,星号仍保留实际观察值;达到这个展示门槛并不代表统计可靠。
|
||||
|
||||
## 固定持有期,再看门槛与次数组合
|
||||
|
||||

|
||||
|
||||
正收益区域值得继续检查,不能因为上一轮结果为负而忽略。本轮固定持有5日、只按历史频次筛选,在2025与2026两年都为正、且满足最低展示样本要求的组合如下。这张表是看过全部结果后的描述性筛选,**不是新训练出的独立验证参数**,也没有据此追加“冠军账户”。
|
||||
|
||||
| 分数 | 阈值 | 20日最少次数 | 2025每批净收益 | 2026每批净收益 | 2026每边60bp | 2026有效日 / 完成笔数 | 2026日均入选 |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| smart | 0.8 | 18 | +0.37% | +0.54% | -0.06% | 111 / 755 | 4.20 |
|
||||
| smart | 0.8 | 19 | +1.07% | +0.01% | -0.59% | 89 / 331 | 1.83 |
|
||||
| smart | 0.9 | 15 | +1.30% | +0.23% | -0.37% | 97 / 449 | 2.50 |
|
||||
| smart | 0.95 | 13 | +2.91% | +0.84% | +0.24% | 80 / 310 | 1.72 |
|
||||
| total | 0.95 | 11 | +0.04% | +0.35% | -0.25% | 139 / 594 | 3.29 |
|
||||
|
||||
这些条件在2026年日均只入选约1.7至4.2只股票,频繁重复同一股票的日信号。更高次数既改变选股特征,也大幅改变分散度和交易日期。不能把“平均每批为正”直接等同于持续满仓可赚钱。
|
||||
|
||||
以预设门槛0.8下的K=20、持有5日为例:2026平均单批净收益+0.89%,但2025为-0.20%。2026只包含52个有完成交易的信号日、115笔交易、34只不同股票;有完成交易的信号日,每日完成交易股票数中位数只有2只,前5只股票贡献了36.5%的事件数量。10日整块抽样的净收益区间为[-1.89%, +4.81%],相对K=0的区间也跨0。抽样没有解决版本回填、多参数扫描或重叠持仓的全部偏差,不能作为显著性证明。详见[集中度](concentration.csv)和[描述性区间](uncertainty.json)。
|
||||
|
||||
## 市场阶段与收益指数分开看
|
||||
|
||||
上涨阶段定义为收盘不低于60日均线且近20日收益为正;下跌为收盘低于60日均线且近20日收益为负;其他为震荡。均线含信号日,预热使用更早指数历史,不使用未来价格。每笔按信号日阶段归组,持有过程中不因阶段变化强平。
|
||||
|
||||
以下固定smart≥0.8、前20日至少5次、持有5日、2026年,分别改变阶段分类指数。其“改善”均相对同日同持有期的K=0全市场对照。
|
||||
|
||||
| 阶段指数 | 阶段 | 有效日 | 每批净收益 | 增加K≥5的改善,百分点 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 沪深300 | 上涨 | 67 | -0.87% | +0.432 |
|
||||
| 沪深300 | 震荡 | 30 | -1.02% | +0.049 |
|
||||
| 沪深300 | 下跌 | 63 | -0.71% | -0.326 |
|
||||
| 中证500 | 上涨 | 81 | -1.04% | +0.262 |
|
||||
| 中证500 | 震荡 | 33 | -1.50% | -0.089 |
|
||||
| 中证500 | 下跌 | 46 | +0.01% | -0.184 |
|
||||
| 中证1000 | 上涨 | 78 | -1.14% | +0.303 |
|
||||
| 中证1000 | 震荡 | 40 | -0.74% | -0.013 |
|
||||
| 中证1000 | 下跌 | 42 | -0.37% | -0.314 |
|
||||
| 中证2000 | 上涨 | 80 | -0.79% | +0.296 |
|
||||
| 中证2000 | 震荡 | 38 | -1.58% | -0.088 |
|
||||
| 中证2000 | 下跌 | 42 | -0.25% | -0.248 |
|
||||
|
||||
同一条件按沪深300划分,下跌阶段的平均结果为-0.71%;按中证500划分,变为+0.01%。差别主要在于哪些日期被分入该阶段,不能据此认定某个指数能使同一组股票自动变得更有收益。
|
||||
|
||||

|
||||
|
||||
保持全部阶段不变,再单独切换同期收益对照指数,得到下表。对每只已完成交易,指数买入日和卖出日与该股票一致,卖出受阻的延期也同步延长;先对股票等权,再对信号日等权。指数毛收益与股票毛收益的差用于观察相对价格表现,净收益减指数毛收益则另行包含策略摩擦,两者不能混用。
|
||||
|
||||
| 同期对照指数 | 毛收益差,百分点 | 30bp净收益减指数毛收益,百分点 |
|
||||
| --- | --- | --- |
|
||||
| 沪深300 | +0.261 | -0.336 |
|
||||
| 中证500 | +0.253 | -0.344 |
|
||||
| 中证1000 | +0.334 | -0.262 |
|
||||
| 中证2000 | +0.225 | -0.372 |
|
||||
|
||||

|
||||
|
||||
## 现金账户和交易可实现性
|
||||
|
||||
预先约定的账户只选择分数0.8、历史5次这个固定展示条件,分别运行H=1、5、10及每边30/60基点;两个分数的三种规则,加一个共同股票池对照,共42条账户。没有用全网格的事后最高收益点挑账户。以下为2026年、持有5日的结果。
|
||||
|
||||
| 规则,门槛0.8、持有5日 | 2026累计收益 | 最大回撤 | 每边60bp累计收益 | 期末残余批次股数 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 共同全市场池 | -26.29% | -32.11% | -39.12% | 13 |
|
||||
| 总分,仅当天 | -27.94% | -31.37% | -40.47% | 2 |
|
||||
| 总分,仅历史K≥5 | -27.15% | -31.49% | -39.82% | 1 |
|
||||
| 总分,历史K≥5且当天 | -28.51% | -31.99% | -40.96% | 0 |
|
||||
| 聪明资金,仅当天 | -25.97% | -29.35% | -38.86% | 0 |
|
||||
| 聪明资金,仅历史K≥5 | -25.25% | -30.17% | -38.26% | 0 |
|
||||
| 聪明资金,历史K≥5且当天 | -26.45% | -30.64% | -39.26% | 0 |
|
||||
|
||||
账户每天先卖后买,新批次预算以前收资产/H计算且不超过现金;每个信号独立批次,旧批次不展期。入选等额分配,可买部分不重新分配失败股票的预算。开盘涨跌停、停牌、风险标记和缺报价保留原限制;计划持有上限10日,受阻退出可能超过10日。原始事件研究没有将未卖出股票算作已完成盈利,现金账户会保留并估值。长期缺价超过20日按原规则暂记0,不等于实际清仓。
|
||||
|
||||
仍采用可分割复权单位,未完整建模整手、最低佣金、开盘冲击和实际资金规模。尤其正收益小区域常只有少数股票,个股集中与可成交规模是后续必须单独核验的变量。账户的平均资金暴露、残仓、费用和回撤详见[accounts.csv](accounts.csv)。
|
||||
|
||||
## 这轮能够支持的判断
|
||||
|
||||
反复活跃值得作为单独研究变量保留,已有局部改善和少数跨年正收益区域;但目前还不能给出不受阶段、费用与稀疏样本影响的稳定门槛。下一步可围绕图中相邻区域做事先冻结的验证,并加入真实资金规模下的集中度、整手与成交容量约束,不能一边查看本次结果一边把参数重新称作未见样本验证。
|
||||
|
||||
源表缺首次可用时刻、允许覆盖旧日期的问题仍未解决。本轮的20日历史计数只是对现存分数快照逐日回放,不证明历史20日内当时就已获得这些分数。需要保存不可覆盖的评分版本与首次可用时间,才能补强时序证据。市场阶段分组和同期指数差额也不能消除所有风格、行业、个股质量等混杂因素。
|
||||
|
||||
## 验证和复现
|
||||
|
||||
开发机通过9项隔离配置、禁止联网的内存测试;真实缓存另做1200次直接20日窗口计数、所有门槛历史前缀检查、6项旧单因子基线复现、36项实际退出日期指数对齐核验。3个预设账户独立逐笔重建现金、持仓和估值,最大误差6.42e-14。42条账户现金守恒通过,21条30基点账户前缀与截断运行一致。详情见[audit.json](audit.json)及[calculation_checks.json](calculation_checks.json)。
|
||||
|
||||
矩阵浏览器使用本机Chrome检查默认双年视图、切换三种坐标、独立阶段与基准选择、CSV及PNG导出和手机布局,外部请求为0。详情见[browser_checks.json](browser_checks.json)。静态图已检查标注、单位和色标。研究只在开发机运行,不构成155服务、QMT成交或真实交易验收,没有修改生产代码或容器。
|
||||
|
||||
完整压缩明细见[grid.csv.gz](grid.csv.gz),预设0.8切片见[focus_grid.csv](focus_grid.csv),四指数逐日阶段见[index_stages.csv](index_stages.csv),界面结果映射见[dashboard_manifest.json](dashboard_manifest.json)。原始行情、评分和派生逐日缓存不入Git;所依赖的旧快照和代码均记录摘要。依赖与版本见[requirements-research.txt](requirements-research.txt),复现顺序如下:
|
||||
|
||||
```bash
|
||||
python research/score_recurrence_20261029/prepare.py
|
||||
python research/score_recurrence_20261029/calibrate.py
|
||||
python scripts/unit_test_guard.py research/score_recurrence_20261029/test_recurrence.py
|
||||
python scripts/unit_test_guard.py research/score_recurrence_20261029/audit.py
|
||||
python research/score_recurrence_20261029/diagnostics.py
|
||||
python research/score_recurrence_20261029/build_dashboard.py
|
||||
python research/score_recurrence_20261029/report.py
|
||||
python research/score_recurrence_20261029/browser_check.py
|
||||
python research/score_recurrence_20261029/finalize.py
|
||||
```
|
||||
|
||||
浏览器核验依赖本机Chrome路径;其他平台应改为本机浏览器可执行文件。CSV收益为原比例,图中收益为百分比、差额为百分点;stage=-1/0/1代表下跌/震荡/上涨,99为全部。所有统计均为已见历史的探索性比较,未输出年化“最优收益”。
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue