From fatfingererr-macro-skills
用 COT 非商業部位變化,量化對沖基金在農產品期貨的資金流向,並把出口需求、USDA 數據、美元/原油/金屬等宏觀風向整合成可交易的敘事與訊號。
npx claudepluginhub joshuarweaver/cascade-code-general-misc-1 --plugin fatfingererr-macro-skillsThis skill uses the workspace's default tool permissions.
<essential_principles>
examples/full_analysis_result.jsonexamples/weekly_flow_sample.jsonmanifest.jsonreferences/contracts-map.mdreferences/data-sources.mdreferences/input-schema.mdreferences/macro-indicators.mdreferences/methodology.mdscripts/analyze_positioning.pyscripts/fetch_cot_data.pyscripts/fetch_macro_data.pyscripts/visualize_flows.pyskill.yamltemplates/annotations.mdtemplates/output-json.mdtemplates/output-markdown.mdworkflows/analyze.mdworkflows/cross-check.mdworkflows/monitor.mdworkflows/visualize.mdCreates new Angular apps using Angular CLI with flags for routing, SSR, SCSS, prefixes, and AI config. Follows best practices for modern TypeScript/Angular development. Use when starting Angular projects.
Generates Angular code and provides architectural guidance for projects, components, services, reactivity with signals, forms, dependency injection, routing, SSR, ARIA accessibility, animations, Tailwind styling, testing, and CLI tooling.
Executes ctx7 CLI to fetch up-to-date library documentation, manage AI coding skills (install/search/generate/remove/suggest), and configure Context7 MCP. Useful for current API refs, skill handling, or agent setup.
<essential_principles>
**COT 週資料作為資金流代理**CFTC Commitments of Traders 報告是追蹤對沖基金農產品部位的核心資料:
資金流 = 本週淨部位 - 上週淨部位(以合約口數計)
**分組彙總邏輯**使用 CFTC 原生分組(commodity_subgroup_name):
| 群組 | CFTC 分組名稱 | 包含商品 |
|---|---|---|
| Grains | GRAINS | Corn, Wheat (SRW/HRW/HRS), Oats |
| Oilseeds | OILSEED and PRODUCTS | Soybeans, Soybean Oil/Meal, Canola |
| Meats | LIVESTOCK/MEAT PRODUCTS | Live Cattle, Lean Hogs, Feeder |
| Softs | FOODSTUFFS/SOFTS | Coffee, Sugar, Cocoa, OJ |
| Fiber | FIBER | Cotton |
| Dairy | DAIRY PRODUCTS | Milk, Butter, Cheese |
Total Flow = Grains + Oilseeds + Meats + Softs + Fiber + Dairy
**火力(Buying Firepower)量化**火力衡量基金是否還有加碼空間:
net_pos_percentile = rank(current_net_pos, past_N_weeks)
firepower = 1 - net_pos_percentile
整合三個風險偏好指標:
| 指標 | 訊號解讀 |
|---|---|
| 美元 (DXY) | 走弱(負報酬)= 利於商品 |
| 原油 (WTI) | 走強(正報酬)= 風險偏好上升 |
| 金屬 | 走強(正報酬)= 循環需求樂觀 |
macro_tailwind_score = (DXY弱 + WTI強 + Metals強) / 3
**週中回補驗證框架**COT 只到週二,週三~週五需用代理證據:
</essential_principles>
追蹤對沖基金在農產品期貨的部位變化與資金流向:輸出:週流量時序、最新狀態、火力分數、宏觀評分、可交易註解。
<quick_start>
快速開始:分析最新 COT 資料
cd .claude/skills/track-agri-hedge-fund-positioning/scripts
pip install pandas numpy requests yfinance pyarrow # 首次使用
python analyze_positioning.py --start 2023-01-01
輸出範例(真實資料):
{
"skill": "track-agri-hedge-fund-positioning",
"as_of": "2026-01-20",
"data_source": "CFTC Socrata API (real data)",
"summary": {
"call": "Funds continue selling",
"all_signals": ["Funds continue selling", "Extreme short - watch for reversal", "Macro mood bullish"],
"confidence": 0.90
},
"latest_metrics": {
"flow_total_contracts": -24559,
"flow_by_group_contracts": {"grains": -31279, "oilseeds": 11517, "meats": 18972, "softs": -23887, "fiber": 1607, "dairy": -1489},
"buying_firepower": {"total": 0.86, "grains": 0.58, "oilseeds": 0.62, "meats": 0.31, "softs": 0.99, "fiber": 0.58, "dairy": 0.99},
"macro_tailwind_score": 0.67
}
}
視覺化圖表:
python visualize_flows.py --weeks 52
# 輸出:output/agri_fund_positioning_YYYY-MM-DD.png
</quick_start>
需要進行什麼操作?請選擇或直接提供分析參數。
| Response | Action | |--------------------------------|-----------------------------------------------------------| | 1, "快速", "quick", "latest" | 執行 `python scripts/analyze_positioning.py` | | 2, "分析", "analyze", "full" | 執行 `python scripts/analyze_positioning.py --start DATE` | | 3, "視覺化", "chart", "plot" | 執行 `python scripts/visualize_flows.py --weeks 52` | | 4, "監控", "monitor", "weekly" | 閱讀 `workflows/monitor.md` 並執行 | | 5, "學習", "方法論", "why" | 閱讀 `references/methodology.md` | | 提供參數 (如日期範圍、商品) | 使用參數執行 `analyze_positioning.py` |所有腳本使用 CFTC Socrata API 取得真實資料,無模擬數據。
<reference_index>
參考文件 (references/)
| 文件 | 內容 |
|---|---|
| methodology.md | COT 分析方法論、火力計算、訊號邏輯 |
| data-sources.md | CFTC COT、FRED、Yahoo Finance 資料來源 |
| input-schema.md | 完整輸入參數定義 |
| contracts-map.md | 期貨合約與商品群組對照表 |
| macro-indicators.md | 宏觀指標定義與代理序列 |
| </reference_index> |
<workflows_index>
| Workflow | Purpose | 使用時機 |
|---|---|---|
| analyze.md | 完整資金流向分析 | 需要深度分析時 |
| visualize.md | 生成視覺化圖表 | 需要重建新聞圖表時 |
| monitor.md | 週度監控與警報 | 每週五 COT 更新後 |
| cross-check.md | 宏觀與基本面交叉驗證 | 驗證敘事一致性時 |
| </workflows_index> |
<templates_index>
| Template | Purpose |
|---|---|
| output-json.md | JSON 輸出結構定義 |
| output-markdown.md | Markdown 報告模板 |
| annotations.md | 圖表標註規則對照表 |
| </templates_index> |
<scripts_index>
| Script | Command | Purpose |
|---|---|---|
| fetch_cot_data.py | --start 2023-01-01 --summary | 從 CFTC Socrata API 抓取 COT |
| fetch_macro_data.py | --start 2025-01-01 --summary | 抓取宏觀指標(Yahoo/FRED) |
| analyze_positioning.py | --start 2023-01-01 | 主分析腳本(自動抓取+計算) |
| visualize_flows.py | --weeks 52 | 生成 Bloomberg 風格視覺化圖表 |
| </scripts_index> |
<input_schema_summary>
必要參數
| 參數 | 類型 | 說明 |
|---|---|---|
| date_start | string | 起始日期 (YYYY-MM-DD) |
| date_end | string | 結束日期 (YYYY-MM-DD) |
| cot_report | string | COT 類型 (legacy/disaggregated) |
| trader_group | string | 交易者分類 (noncommercial) |
| contracts_map | object | 合約→群組對照表 |
選用參數
| 參數 | 類型 | 預設值 | 說明 |
|---|---|---|---|
| position_metric | string | net | 部位衡量 (net/long/short) |
| lookback_weeks_firepower | int | 156 | 火力計算視窗(週) |
| macro_indicators | object | {...} | 宏觀指標設定 |
| fundamental_inputs | object | {...} | 基本面資料設定 |
| event_window_days | int | 3 | Wed-Fri 事件視窗 |
| output_mode | string | both | 輸出格式 (markdown/json) |
完整參數定義見 references/input-schema.md。
</input_schema_summary>
<output_schema_summary>
{
"skill": "track-agri-hedge-fund-positioning",
"as_of": "2026-01-21",
"summary": {
"call": "Funds back & buying",
"confidence": 0.72,
"why": ["COT 週部位由負轉正", "分組同步改善", "宏觀順風"],
"risks": ["COT 只到週二", "USDA 報告可能反轉"]
},
"latest_metrics": {
"cot_week_end": "2026-01-21",
"flow_total_contracts": 58,
"flow_by_group_contracts": {
"grains": 35, "oilseeds": 25, "meats": 5, "softs": 0
},
"buying_firepower": {
"total": 0.63, "grains": 0.58, "oilseeds": 0.67
},
"macro_tailwind_score": 0.67
},
"annotations": [
{"label": "macro_mood_bullish", "rule_hit": true, "evidence": ["USD down", "crude up"]}
]
}
完整輸出結構見 templates/output-json.md。
</output_schema_summary>
<success_criteria> 執行成功時應產出: