🚀 快速安装
复制以下命令并运行,立即安装此 Skill:
npx skills add https://skills.sh/aradotso/trending-skills/trump-code-market-signals
💡 提示:需要 Node.js 和 NPM
Trump Code — 市场信号分析
技能由 ara.so 提供 — Daily 2026 Skills 系列。
Trump Code 是一个开源系统,通过暴力计算寻找特朗普在 Truth Social/X 上的发帖行为与标普 500 指数走势之间的统计显著模式。该系统已测试了 3150 万个模型组合,保留了 551 个存活规则,在 566 次预测中验证命中率达到 61.3%(z=5.39,p<0.05)。
安装
git clone https://github.com/sstklen/trump-code.git
cd trump-code
pip install -r requirements.txt
环境变量
# AI 简报和聊天机器人所需
export GEMINI_KEYS="key1,key2,key3" # 逗号分隔的 Gemini API 密钥
# 可选:用于 Claude Opus 深度分析
export ANTHROPIC_API_KEY="your-key-here"
# 可选:用于 Polymarket/Kalshi 集成
export POLYMARKET_API_KEY="your-key-here"
CLI — 关键命令
# 今日检测到的特朗普发帖信号
python3 trump_code_cli.py signals
# 模型表现排行榜(全部 11 个命名模型)
python3 trump_code_cli.py models
# 获取多头/空头共识预测
python3 trump_code_cli.py predict
# 预测市场套利机会
python3 trump_code_cli.py arbitrage
# 系统健康检查(熔断器状态)
python3 trump_code_cli.py health
# 完整每日报告(三语)
python3 trump_code_cli.py report
# 以 JSON 格式导出所有数据
python3 trump_code_cli.py json
核心脚本
# 实时特朗普发帖监控器(每 5 分钟轮询)
python3 realtime_loop.py
# 暴力模型搜索(约 25 分钟,测试数百万种组合)
python3 overnight_search.py
# 单项分析
python3 analysis_06_market.py # 发帖与标普 500 相关性分析
python3 analysis_09_combo_score.py # 多信号组合评分
# Web 仪表板 + AI 聊天机器人,端口 8888
export GEMINI_KEYS="key1,key2,key3"
python3 chatbot_server.py
# → http://localhost:8888
REST API (实时服务地址 trumpcode.washinmura.jp)
import requests
BASE = "https://trumpcode.washinmura.jp"
# 一次调用获取所有仪表板数据
data = requests.get(f"{BASE}/api/dashboard").json()
# 今日信号 + 7 天历史
signals = requests.get(f"{BASE}/api/signals").json()
# 模型表现排名
models = requests.get(f"{BASE}/api/models").json()
# 最新 20 条特朗普发帖,带信号标签
posts = requests.get(f"{BASE}/api/recent-posts").json()
# 实时 Polymarket 特朗普预测市场(316+ 个)
markets = requests.get(f"{BASE}/api/polymarket-trump").json()
# 多头/空头操作手册
playbook = requests.get(f"{BASE}/api/playbook").json()
# 系统健康 / 熔断器状态
status = requests.get(f"{BASE}/api/status").json()
AI 聊天机器人 API
import requests
response = requests.post(
"https://trumpcode.washinmura.jp/api/chat",
json={"message": "今天触发了哪些信号?共识是什么?"}
)
print(response.json()["reply"])
MCP 服务器(Claude Code / Cursor 集成)
添加到 ~/.claude/settings.json:
{
"mcpServers": {
"trump-code": {
"command": "python3",
"args": ["/path/to/trump-code/mcp_server.py"]
}
}
}
可用的 MCP 工具:signals、models、predict、arbitrage、health、events、dual_platform、crowd、full_report
开放数据文件
所有数据位于 data/ 目录,每日更新:
import json, pathlib
DATA = pathlib.Path("data")
# 44,000+ 条 Truth Social 发帖
posts = json.loads((DATA / "trump_posts_all.json").read_text())
# 预标记信号的发帖
posts_lite = json.loads((DATA / "trump_posts_lite.json").read_text())
# 566 条已验证预测及结果
predictions = json.loads((DATA / "predictions_log.json").read_text())
# 551 条活跃规则(暴力搜索 + 进化)
rules = json.loads((DATA / "surviving_rules.json").read_text())
# 384 个特征 × 414 个交易日
features = json.loads((DATA / "daily_features.json").read_text())
# 标普 500 OHLC 历史数据
market = json.loads((DATA / "market_SP500.json").read_text())
# 熔断器 / 系统健康状态
cb = json.loads((DATA / "circuit_breaker_state.json").read_text())
# 规则进化日志(交叉/变异)
evo = json.loads((DATA / "evolution_log.json").read_text())
通过 API 下载数据
import requests
BASE = "https://trumpcode.washinmura.jp"
# 列出可用数据集
catalog = requests.get(f"{BASE}/api/data").json()
# 下载特定文件
raw = requests.get(f"{BASE}/api/data/surviving_rules.json").content
rules = json.loads(raw)
代码示例
解析今日信号
import requests
signals_data = requests.get("https://trumpcode.washinmura.jp/api/signals").json()
today = signals_data.get("today", {})
print("今日触发的信号:", today.get("signals", []))
print("共识:", today.get("consensus")) # "多头" / "空头" / "中性"
print("置信度:", today.get("confidence")) # 0.0–1.0
print("活跃模型:", today.get("active_models", []))
从存活规则中查找表现最佳的规则
import json
rules = json.loads(open("data/surviving_rules.json").read())
# 按命中率降序排序
top_rules = sorted(rules, key=lambda r: r.get("hit_rate", 0), reverse=True)
for rule in top_rules[:10]:
print(f"规则:{rule['id']} | 命中率:{rule['hit_rate']:.1%} | "
f"交易次数:{rule['n_trades']} | 平均收益率:{rule['avg_return']:.3%}")
检查预测市场机会
import requests
arb = requests.get("https://trumpcode.washinmura.jp/api/insights").json()
markets = requests.get("https://trumpcode.washinmura.jp/api/polymarket-trump").json()
# 按交易量排序的市场
active = [m for m in markets.get("markets", []) if m.get("active")]
by_volume = sorted(active, key=lambda m: m.get("volume", 0), reverse=True)
for m in by_volume[:5]:
print(f"{m['title']}:是={m['yes_price']:.0%} | 交易额=${m['volume']:,.0f}")
关联发帖特征与收益率
import json
import numpy as np
features = json.loads(open("data/daily_features.json").read())
market = json.loads(open("data/market_SP500.json").read())
# 构建以日期为索引的收益率映射
returns = {d["date"]: d["close_pct"] for d in market}
# 示例:关联发帖数量与次日收益率
xs, ys = [], []
for day in features:
date = day["date"]
if date in returns:
xs.append(day.get("post_count", 0))
ys.append(returns[date])
correlation = np.corrcoef(xs, ys)[0, 1]
print(f"发帖数量与当日收益率:r={correlation:.3f}")
运行自定义信号的回测
import json
posts = json.loads(open("data/trump_posts_lite.json").read())
market = json.loads(open("data/market_SP500.json").read())
returns = {d["date"]: d["close_pct"] for d in market}
# 查找美国东部时间上午 9:30 前触发 RELIEF 信号的日期
relief_days = [
p["date"] for p in posts
if "RELIEF" in p.get("signals", []) and p.get("hour", 24) < 9
]
hits = [returns[d] for d in relief_days if d in returns]
if hits:
print(f"RELIEF 盘前信号:n={len(hits)},平均收益率={sum(hits)/len(hits):.3%},命中率={sum(1 for h in hits if h > 0)/len(hits):.1%}")
关键信号类型
| 信号 | 描述 | 典型影响 |
|---|---|---|
RELIEF 盘前 |
美国东部时间上午 9:30 前出现“缓解”相关措辞 | 当日平均 +1.12% |
TARIFF 交易时段 |
交易时段提及关税 | 次日平均 -0.758% |
DEAL |
协议/交易相关措辞 | 52.2% 命中率 |
CHINA (仅 Truth Social) |
提及中国(从未在 X 上出现) | 权重提升 1.5 倍 |
SILENCE |
零发帖日 | 80% 看涨,平均 +0.409% |
| 爆发 → 沉默 | 快速发帖后沉寂 | 65.3% 多头信号 |
模型参考
| 模型 | 策略 | 命中率 | 平均收益率 |
|---|---|---|---|
| A3 | 盘前 RELIEF → 上涨 | 72.7% | +1.206% |
| D3 | 交易量激增 → 恐慌性底部 | 70.2% | +0.306% |
| D2 | 签名切换 → 正式声明 | 70.0% | +0.472% |
| C1 | 爆发 → 长期沉默 → 多头 | 65.3% | +0.145% |
| C3 ⚠️ | 深夜关税(反向指标) | 37.5% | −0.414% |
注意: C3 是一个反向指标——如果触发,熔断器会自动将其反转为多头(反转后准确率为 62%)。
系统架构流程
检测到 Truth Social 发帖(每 5 分钟)
→ 分类信号(RELIEF / TARIFF / DEAL / CHINA 等)
→ 双平台加成(仅 TS 上的中国相关 = 1.5 倍权重)
→ 快照 Polymarket + 标普 500 数据
→ 运行 551 条存活规则 → 生成预测
→ 在 1 小时 / 3 小时 / 6 小时跟踪
→ 验证结果 → 更新规则权重
→ 熔断器:如果系统性能下降 → 暂停/反转
→ 每日:规则进化(交叉 / 变异 / 精简)
→ 将数据同步到 GitHub
故障排除
realtime_loop.py 无法检测到新发帖
- 检查网络是否能访问 Truth Social 抓取端点
- 验证
data/trump_posts_all.json的时间戳是否最新 - 运行
python3 trump_code_cli.py health查看熔断器状态
chatbot_server.py 启动失败
- 确保已设置
GEMINI_KEYS环境变量:export GEMINI_KEYS="key1,key2" - 端口 8888 可能被占用:
lsof -i :8888
overnight_search.py 内存不足
- 运行约 3150 万种组合 —— 需要约 4GB 内存
- 在 8GB+ 内存的机器上运行,或在脚本配置中缩小搜索空间
命中率降至 55% 以下
- 检查
data/circuit_breaker_state.json—— 系统可能已自动暂停 - 查看
data/learning_report.json了解被降级的规则 - 重新运行
overnight_search.py以刷新存活规则
data/ 目录中的数据过时
- 如果系统正在运行,每日流程会自动同步到 GitHub
- 手动触发:运行
python3 trump_code_cli.py report强制刷新 - 或从远程拉取最新数据:
git pull origin main
📄 原始文档
完整文档(英文):
https://skills.sh/aradotso/trending-skills/trump-code-market-signals
💡 提示:点击上方链接查看 skills.sh 原始英文文档,方便对照翻译。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)