2026-07-20 接口变更(去 mock-as-real,YG 指令):硬编码 1.2000 锚与 Math.random() price_simulation 路径已删除——算子现仅输出 fx_change_percent + volatility + decomposition(完全确定性)。
做什么(One-liner)
外汇市场权重因子模型:息差 + 风险情绪 + 经济超预期 三因子加性组合 → fx_rate + volatility + 30 天模拟路径。stylized heuristic,非严格 CIP。
怎么用
Canvas 拖 fx_market_v1,填 base_currency_rate(基准币利率 %)+ quote_currency_rate(报价币利率 %)+ 可选 risk_sentiment[0,1] + economic_data_surprise[-1,1]。输出 fx_rate + volatility + price_simulation。
核心公式
rate_differential = base - quote
carry_effect = diff * 0.10 # 10% weight
risk_adj = (risk - 0.5) * 0.05
surprise = surprise * 0.02
fx_change_pct = carry_effect + risk_adj + surprise
# (2026-07-20) absolute-rate anchor removed
volatility = 0.15 + |diff| * 0.02 + (1 - risk) * 0.05Rounding 契约:fx_rate → 4;volatility → 3;rate_differential_impact → 2。
假设与适用场景
假设:货币对锚 1.2000(EUR/USD-style)+ 三因子加性独立 + 30 天固定窗口 + risk ∈ [0,1] + surprise ∈ [-1,1]。
适用:宏观 FX scenario 模拟、跨资产 what-if 输入、教学 demo。
不适用:实时交易信号、严格 CIP、长期预测、非 EUR/USD 类货币对、需可复现模拟路径。
输入 / 输出契约
{base_currency_rate, quote_currency_rate, risk_sentiment?, economic_data_surprise?} → {fx_rate, volatility, price_simulation[30], rate_differential_impact}。
price_simulation 是 Math.random(),两次调用值不同。
已知局限
- base_fx_rate = 1.2 硬编码(非 EUR/USD-style 货币对误用)
- price_simulation 非确定性(Math.random;seeded RNG 是 future work)
- 三因子权重经验值(10%/5%/2% 无 empirical tuning)
- 30 天 window 硬编码
- 模型名含义与实现错配:fx_market 不是 CIP,是 heuristic 因子和
- rate_differential_impact 字段易读为 "rate change",实际是 carry_trade_effect × 100
参考文献
Fama (1984) forward-rate bias + Engel (2014) CIP 综述 + Brunnermeier-Nagel-Pedersen (2008) carry crash。详见 frontmatter。
Golden Test
tests/golden/fixtures/tier2/fx_market/,跨语言 golden(TypeScript impl × Python reference)。10 tests:
- 6 scenario deterministic byte-equal(neutral / high_carry_hawkish / risk_off / risk_on_surprise / negative_rd / max_neg_surprise)
- determinism(5 reruns 确定性字段 byte-identical;price_simulation 不断言)
- base_fx_rate anchor(所有 inputs 中性 → fx_rate = 1.2 恰好)
- rate_differential_impact 语义锁定(= carry_trade_effect × 100)
- validation contract(缺必填字段 → throws)
Golden 只锁定确定性字段。price_simulation 仅做结构断言(length=30, 合理 band),因为 Math.random 无法 reference。
测试位置:tests/golden/node/fx_market_golden.test.ts。
Changelog
- 1.0.0 (2026-04-20) — 首次 Active(Tier 2 golden #4)

