在AI(特别是大模型应用开发)领域,Agent(智能体)和Skill(技能)是“大脑”与“手脚”的关系。为了帮你快速理清,我们先给个最直观的定义:
- Agent(智能体):是决策者,相当于一个“能自主思考的机器人”。它负责理解目标、制定计划、记忆上下文,并决定下一步该做什么。
- Skill(技能):是执行者,相当于这个机器人的“具体动作”或“工具说明书”。它负责把Agent的决策转化为具体的操作,比如查天气、发邮件或调用某个API。
如果你去读OpenAI或Anthropic的技术文档,你会发现他们最新的Agent架构中,Skill正在被“函数调用(Function Calling)”和“MCP(模型上下文协议)”替代。现在的趋势是:让Skill变得更“薄”,只负责纯粹的原子操作(如SQL查询),而把所有的逻辑、判断甚至异常处理全部上移给Agent。
所以,现在开发AI应用,你需要重点设计的是Agent的“系统提示词(System Prompt)”和“反思机制”,而不是把复杂的业务逻辑塞进Skill里。
他实现了我的想法,而且超前了。
https://www.youtube.com/watch?v=U60eTIFTJ8o
https://www.youtube.com/watch?v=8WoC2Pg_GV4
https://nyrobrain.com/
二、代码
https://www.youtube.com/watch?v=37_tweITXBQ
1.agents.md 22:58
Agents
Always read @AGENTS-core.md first. It is the authoritative source for project conventions, strategy-writing rules, datasource access, knowledge- base usage and compute / OOM limits. Treat it as binding for every task.
AGENTS-core.md is admin-managed and updated on every pod start. The file you are reading now(AGENTS.md ) is yours – edit it freely Use the section below to record project-specific
notes, ad-hoc instructions,working preferences, or context you want the Al to carry across sessions
My notes
Canary Alpha & Strategy Pool Definitions
Canary Alpha: Discovered & verified alpha formulas found by the human researcher (typically via TURTLE permutation search) . These represent PROVEN signal with full CV results. They are the ‘ground truth’ – any new research should NOT replicate these exact configurations.
Pod Researched Alpha: Alpha strategies developed by this AI research pod. These include different model angles. story interpretations, or construction methods applied to similar or different data.
Strategy Pool (Ped + Canary): The union of al canary alphas and pod-researched alphas that are Currently active (status: pass review or keep-in-review). When forming a Iive portfolio. we
want LOW correlation between strategies to avoid overfitting.
Untested means: An alpha ideas considered untested if it differs from BOIH canary and pod strategies in at least one of model/signal construction, alpha story angle, entry/exit logic. Or data factor combination. An idea using the same raw column but with a fundamental different transformation or horizon is considered different. HOWEVER-if the backtest PnL has high correlation (>06) with an existing pool strategy. flag it as a CORRELATION WARNING regardless of construction differences.
Existing Canary Options Alphas (do NOT replicate):
- TURTLEOOO_00585: Options OI (BTC. robustscaler, fast_long. SR=2.58)
- TURTLEOOO_00620:contract_calls_count_total(ETH,minmaxscaling_meannorm,trend_reverse_long, SR=2.24)
- TURTLEOOO_00310: ATM IV 1M (ETH robustscaler. fast_long. SR=2.26)
- TURTLEOOO_00374: 25D Skew 1M (ETH, robustscaler, fast_short, SR=2.15)
- Canary OO2: Options 25D Skew + Futures OI Trend Reverse (WF Sharpe 1.060)
- Full registry: 285 options/derivatives alphas across OI, IV. skew, calls count. funding
Existing Pod Options Strategies (do NOT replicate):
- iv_term_structure_momentum: IW vs IM ATM IV spread momentum (PASS, WF-CV Sharpe +0.625)
- btc_hourly_expiry_pin: Wednesday T-2 max-pain pin (PAss. OOS sharpe 0.82)
- options_skew_spike_mean_reversion: Following skew spikes works, fading doesn’t (REVIEW)
- btc_options_composite_regime: multi-factor composite (DEAD)
- btc_gex_short_gamma_momentum: GEX-based (DEAD)
Running Script Progress Bar Display
Compulsory: Use tqdm on EVERY script that has loops,
- Wrap fold loops: tqdn(folds. desc=”Folds*)
- Wrap param grid loops: tqdm(param_combos, desc=”Fald Ngrid”, Leaves=False)
- Use tqdm.write() instead of print() inside loops
- This applies to ALL scripts in brain/scripts/ all backtest_wff.py, all backtest.py
- Run scripts directly (don’t pipe to file) so progress bars display live
Always Show Tables and Plots in Chat
Every output table and every saved plot MUST be surfaced directly in the chat session.
- After every script run that produces metrics print a formatted markdown table in the chat response.
- After every plot is saved ( .png ). emit: [Description] (relative/path/to/file.png)
- Never make the user navigate to the strategy dashboard to see results.
Backtest Time Period
Aways backtest since 2020-05-10 til the latest available datetime period. Unless specially stated
Two-Stage Optimization (Universal Principle)
Every parameter search in this pipeline uses coarse-fine two-stage optimization.
This applies universally to:
- Entry/exit threshold parameters (Step 7 optimiser)
- Model rolling windows (regime filter windows, signal windows)
- Regime filter window selection (Step 8a match_alpha)
- Any setting with a continuous or large discrete search space
Pattern
Stage 1 (Coarse Grid):Wide range, few points – identify promising region
Stage 2 (Fine Grid):Narrow range around winner, many points -> find true optimun + plateau check
Rules
- Stage 1: Scan a broad range with st0-15 coarse grid points Rank by primary metric (Sharpe. separation score, etc).
2.Stage 2 Take top-3 winners from coarse scan For each generate a fine grid spanning the midpoint between adjacent coarse neighbors (-12 points) Recompute the metric at each fine point.
3.plateau detection: the optimal value must sit on a highland plateau ( ≥3 adjacent the points within 1S% of peak) if ony 1-2 points score well-> SPikE -> fragile/overfit -> reject or investigate.
4.Select plateau center: When a plateau exists, pick the CENTER (not the peak) as the recommended value. Center is more robust to future drift.
- Spike = reject: If the best score is a spike (width <3), it’s likely noise. Either:
- Widen the fine grid to check if a plateau exists elsewhere
- Reject the factor/parameter entirely
- Use the next-best candidate that IS on a plateau
Pipeline 3 – Rolling Walk-Forward(9:3 split) Fold Rules
This is the default validation pipeline for all strategies.
- Train window: 9 months (fixed from fold 2+)
- Test window: 3 months (calendar quarters: Jan-Mar. Apr-Jun,Jul-Sep, Oct-Dec)
- First fold: train data_start to first quarter boundary where (test_start -data_start) >= 9 months. Gives a LONGER first fold.
- Subsequent folds: train = test_start – retativedelta(months=9) – exactly 9 months
- MIN_TRAIN_ MONTHS = TRAIN_ MONTHS = 9 (not shorter) Skip quarters until >= 9 months available
- Last fold: test may be partial (e 3 months) it date ends mid-quarter.
- No overlap: train end = test_start, filter Uses start_time >= train_start AND start_tine < train_end
Verdicts:
- PASS: >50% active folds positive AND mean Sharpe > 0.3
- KILL: <30% folds positive AND mean Sharpe <0
- INVESTIGATE anything in between (try alternative configs fromEDA)
Methods Catalog (brain/methods/)- Direct-Read Reference
brain/methods/ is NOT indexed by the Knowledge Base. It is a stable reference catalog meant for deterministic lookup During alpha research, read directly (not via kb_search )
Pipeline flows in strict order
THESIS[1] Data Diagnostics – [2] Story Mapping – [3] E0A – [4] Method Selection[5] Quirk Check – [6] Method Confirmation – [7] Optimiser – [8] Regime Filter – STRATEGY
Step 1: Data Diagnostics ( brain/methods/data-shape-mapping.yaml )
Input:Raw datasource DataFrame
Output Data property profile (skew, kurtosig. stationarity, bounds, nulls, autocorrelation)
Gate: If data has <2yr history or >5% nulls, flag risk before proceeding.
Step 2: Story Mapping ( brain/methods/alpha-story-mapping.yaml )
- Input: Alpha hypothesis + data profile from Step 1
- Output Preprocessing chain, signal generator, failure modes, counterparty
- Gate (Counterparty) if no counterparty can be named. the alpha likely doesn’t exist. Do NOT proceed without a named counterparty
- Gate (Factor Family) Check against empirical pass rates:
VALIDATED (pass rate > 3O%):
derivatives_microstructure: OI collapse, IV tern structure, leverage ratio
options_mechanics: max-pain pin (T-2 Wednesday), IV backwardation
exchange_premiun: Coinbase-Binance gap (z-score threshold)
miner: balance regime (accumulation/distribution via z-score)
PROMISING (under-explored):
cross_asset_residual: ETH beta-neutralized residual
funding: event-driven extreme short
WEAKENED (post-ETF structural break):
exchange_premiun: Coinbase gap weakening
on_chain_flow: netflow signals broken post-Jan-2824
DEAD (8% pass rate, 10+ attempts – KILL immediately):
hourly_aggregate_netflow, options_composite, gex_regine, etf_flow_momentum
Step 3: EDA ( brain/methods/EDA.yaml )
EDA is a CONFIGURATION tool, not a screening tool. It classifies the edge and prescribes optimizer params
- Hard Kill (only one) Peak IC < 0.02 at ALL horizons AND quantile shape flatt AND spread < 30 bps ->KILL
- Key outputs: Edge classification, 1-3 optimizer configs with param ranges, Sharpe calibration ( sharpe_likely = IC *V(trades/yr) IR/(IR+1) * 8.6)
- Required Follow-Ups:
Signal Decay(event types only) run eda_signal_decay.py to set hold_bars
Trade Count Sanity: Event 10-80/yr, Continuous = I00-500/yr
Direction: Default long-only unless EDA cpntirms short edge
Post-ETF Breakpoint: If IC sign-flips post-Jan-2024. factot is WEAKENED
Steps 4-6: Method Selection -> Quirk Check -> Confirmation
- brain/methods/selection-guide.yaml – cross-check data shape + EDA against method suitability
- brain/methods/quirks.yaml – verify no silent landmines (QO2 QO3, Q13, Q16 are critical)
- brain/methods/preprocessing/_index.yaml / brain/methods/signals/_index.yaml – confirm method row
Step 7: Optimiser ( brain/methods/optimiser.yaml)
Highland plateau parameter selection. Select params on a performance PLATEAU (not peak)
- Gate (Plateau) If no plateau exists – factor is likely overfit. KILL or simplify.
- Gate (DSR) Run robustness dsr. py If DSR < 0.95, Sharpe is a selection artifact. KILL or extend data.
- Gate (RAS): If parameter space large., run robustness_ras.py -Lite If anti-serum <0 KILL.
- Gate (Trade Count) Event signals need >50 IS trades, >20 OOS trades for statistical meaning
- Gate (Sharpe vs Calibration) optimizer sharpe> sharpe_celing *08 ->lkely overfit. Optimizer_ sharpe <sharpe_likely * 5 -> wrong construction
Step 8: Regime Filter ( brain/methods/regime_filter.yaml)
Overlay regime filter to protect the alpha. This is the single authoritative spec.
Ba-prescreen: Atlas Correlation ( brain/regimes/match_alpha.py )
Instanty correlate IS-only PnL against pre-computed atias regime labels. Narrows 64 factor*window combinations to top 2-3 candidates in -5 seconds
uv run brain/regimes/match_alpha.py \
-report “strategies/…/report.parquet” \
-top-k 5 \
-signal-type ternarylbinary
Signal type determines scoring formula:
ternary (default): scere = (cs1 – cs-1) 1.3 entropy 8.5 – both ON and REVERSE traded
binary score = (cs1 – cs-1) – 1.0 + cs1 < 0.3 + entropy 8.5 – only ON bars generate trades
8a: Performance Simulation ( regime_coherence_analysis.py )
Position-based simulation with fees on narrowed candidates. Trains on IS period, validates on OOS
uv run brain/scripts/regime_coherence_analysis.py V
report “strategies/…/report.parquet” \
regime-factors “realised_vol,price_sma,oi_growth” \
-regime-Windows “72,120,168,248,336,504”
三、
四、他上面提到的因子
如果你要的是“现成因子库”
还可以参考这些免费开源量化库:
- TA-Lib:经典技术指标库;
- pandas-ta:pandas 原生技术指标库,安装方便;
- qlib:微软开源量化平台,包含部分 Alpha 因子和模型;
- Alpha101 / Alpha191 开源实现:GitHub 上有很多复现版本。
五、知识库
https://www.zhihu.com/question/15353055352/answer/2057928542898353930
现成的:
https://zhuanlan.zhihu.com/p/2032496271542445472
六、skill
https://zhuanlan.zhihu.com/p/2073001403262449283
创建vnpy skill
https://www.cnblogs.com/pcdoctor/p/21864347
同花顺的:
https://fuyao.aicubes.cn/
https://github.com/HiThink-Tech/Financial-API

有人跑通的:
https://zhuanlan.zhihu.com/p/2037505179373806287
提到的quant alpha
https://www.zhihu.com/search?type=content&q=QuantaAlpha
七、Bybit教学 現貨 合約 交易平台101教學
https://www.youtube.com/watch?v=NSbik2yJeTw
七、其他参考
github上有人用做了多因子分析和回测的整个流程,因子他实现了alpha101和alpha191两组因子。因子分析他用的是alphalens,回测使用的是backtrader。对多因子分析与回测感兴趣的同学,值得参考。
https://github.com/quant2008/alphas/tree/main
https://zhuanlan.zhihu.com/p/613200484
八、关于数据源
我现在将它全部设成读取本地文件。
九、关于因子
它们是 WorldQuant 研发出名的 Alpha 101 因子。
它们是用作股票(或其他资产)量化/算法交易策略中信号的技术指标。
每个 alpha 是一个数学表达式,结合了价格、成交量和 VWAP 数据,使用时间序列(滚动窗口)和横截面(排名)操作来预测未来的相对收益。
只基于股票的开盘价(open)、最高价(high)、最低价(low)、收盘价(close)、成交量(volume)和成交均价(vwap)这六类基础数据,通过复杂的数学变换(排序、滚动统计、相关性、时滞等)来捕捉市场的微观结构和投资者行为偏差。
VWAP 的计算公式是:
VWAP = ∑(成交价格 × 该价格对应的成交量) / ∑ 总成交量
在这 101 个因子中,vwap 常被用作判断价格偏离程度和识别机构行为的锚点。你可以看看代码中这几类典型用法:
价格偏离因子(衡量当前价与平均成本的差距):
如 Alpha041:(high * low)^0.5 – vwap(估算日内中枢价与平均成本的差值)。
如 Alpha057:(close – vwap) / decay_linear(…)(收盘价相对于 VWAP 的偏离,除以衰减权重)。
结合成交量的相关性因子(判断放量是否推动价格回归均线):
如 Alpha050、Alpha062,计算 correlation(rank(volume), rank(vwap), 5),即过去几天内成交量大小与 VWAP 高低的排名相关性,用来捕捉量价配合的形态。
滚动统计因子(观察 VWAP 的极值变化):
如 Alpha061:vwap – ts_min(vwap, 16)(当前 VWAP 减去过去 16 天的最低 VWAP),用于判断近期平均成本的趋势强度。
特别提醒:在这份数据中,vwap 通常是当日的日频数据(即当天整体的成交量加权均价),而不是盘中实时更新的分钟级 VWAP。因子在回测时,会用它来做横截面(跨股票)的对比,或者做时间序列(跨天数)的滚动计算。
-
- 信号逻辑:这些因子通过 rank(横截面排序)、ts_rank(时间序列排序)、correlation(相关性)、delta(差分)等操作,将原始价格和成交量转化为可比较的标准化信号。例如,Alpha001 考察过去某段时间内收益率的极值位置,Alpha101 则是简单的(收盘-开盘)/(最高-最低),用于衡量日内价格效率。
中性化处理:你可能会注意到代码中许多因子(如 alpha048、alpha056 等)被注释掉了。这是因为这些因子原本需要引入市值(cap)或行业/子行业分类(IndClass)进行“中性化”处理(剥离大盘和行业影响),而这段脚本中没有提供这些额外数据,所以暂时无法运行。
(二)因子
如果说 Alpha101 是“技术面量价因子的经典基础库”,那 Alpha191 就是在这个基础上引入了更复杂的统计方法、指数权重、滚动回归,以及市场基准(指数)对比,因子数量也从 101 个扩充到了 191 个(实际有效编写了约 180+ 个)。

这 191 个因子大致可以分为以下几类(比 Alpha101 更丰富):
- 日内价格效率类(如 Alpha003、Alpha011):
计算(close-low)-(high-close)或(high-low)的比值,衡量日内价格波动的方向性,捕捉反转或突破信号。 - 量价背离与相关性类(如 Alpha001、Alpha032、Alpha062):
计算成交量与价格(或 VWAP)排名的滚动相关性,寻找“放量不涨”或“缩量新高”等异常形态。 - 趋势强度与回归类(如 Alpha021、Alpha116、Alpha147):
利用Regbeta对过去 N 日的价格序列做线性回归,提取斜率作为趋势因子。这是 Alpha101 中没有的。 - 波动率与风险类(如 Alpha127、Alpha161):
计算价格与滚动最大值的偏离标准差,或计算日内平均波动幅度(ATR 变种)。 - 大盘相对强弱类(如 Alpha075、Alpha182):
统计个股涨跌与指数涨跌同步的天数占比,用于剥离市场系统性风险。 - 条件累计类(如 Alpha112、Alpha129):
只累计上涨日的涨幅(或下跌日的跌幅),用于刻画多头/空头力量的绝对大小。
这份代码中大约有 15%~20% 的因子是“写错”或“无法运行”的,作者自己在注释里标出来了。这是你直接拿来回测前必须检查的雷区:
- 明确标注“公式有问题”(如 Alpha055、Alpha127、Alpha166、Alpha181):
这类因子的数学逻辑与 WorldQuant 原始论文有出入,或者运算中缺少必要的周期参数,直接跑会出 NaN 或错误结果。 - 明确标注“数据量较少”(如 Alpha033、Alpha045、Alpha121):
这些因子使用了 240 天(约 1 年)的超长滚动窗口,如果你的历史数据少于这个长度,前期的因子值会全是空值。 - 依赖指数数据的因子(如 Alpha075、Alpha149、Alpha182):
需要你额外提供benchmark_open和benchmark_close的日频数据,否则这些因子会报错。 - 未实现或直接返回 0 的占位符(如 Alpha030、Alpha143、Alpha149、Alpha190):
这些因子原本涉及多因子回归(如 Fama-French 三因子)或复杂滤波,代码里直接写了return 0,实际不可用。
相比 Alpha101,Alpha191 中有几个逻辑更严谨、实战中常被提及的因子:
- Alpha021(滚动回归斜率):
Regbeta(Mean(close,6), Sequence(6))
计算 6 日均价相对于时间序列(1,2,3,4,5,6)的回归斜率,用来直接量化短期趋势的方向和力度。 - Alpha028(三重平滑威廉指标变种):
对(close - min_low_9) / (max_high_9 - min_low_9)做三次滚动平滑,能有效过滤噪音,用于捕捉超买超卖区域。 - Alpha089(双均线差值的二次平滑):
2*(Sma(close,13,2)-Sma(close,27,2)-Sma(...))
这是经典 MACD 指标的变体,但用 SMA(指数权重)替代了简单均线,信号更灵敏。
以后你只需要说:
- “评估 alpha010” → 我跑默认 101 版(并提示 191 有同名)
- “评估 191 的 alpha010″ → 我跑
--factor 191:alpha010 - “评估 101 的 alpha010” → 我跑
--factor 101:alpha010
十、添加因子验证功能
(一)


(二)添加置换检验
根据这个项目添加置换检验:https://github.com/Miasyster/QuantGPT
③安慰剂检验=置换检验(真实IC须>随机打乱95分位)
(顺带说明:严格的双侧置换检验应该拿 |真实值| 和”|打乱值| 的 95 分位”比,QuantGPT 的写法是拿 |真实值| 和”打乱值原始分布的 95 分位”比——对以 0 为中心的对称分布两者近似等价,结果偏差很小。)
十、Agent.md
deepseek harness自动帮我创建了Agent.md。
I:\AITrade\AGENTS.md
十一、我的标准

A股市场日频IC的均值通常在 0.01~0.03 之间(当天买,当天卖),
如果你打算做周频或月频调仓,这个阈值需要相应调整——持有期越长,IC 均值通常会越高
如果是月频IC(滚动20日收益):月频IC均值通常在 0.03~0.08 之间,你的 0.03 门槛就非常合理。

少了分层单调性(Quantile Shape):

十二、别人开源的挖因子的系统
https://miasyster.github.io/
https://github.com/Miasyster/QuantGPT