Multi-Source LLM Estimator
A prediction market trading bot that enriches an LLM with real-time context
from 10+ data sources. It compares the LLM's estimated probability against
the current market price and trades when it detects significant mispricing.
How It Works
CODEBLOCK0
- 1. Fetches active markets from Polymarket (via Simmer SDK)
- For each market, gathers real-time context from relevant data sources
- Also checks cross-platform prices on Manifold and Kalshi
- Sends the question + context to an LLM for probability estimation
- If the LLM's estimate diverges from the market price by more than the
threshold (default 15%), it places a trade
Data Sources
| # | Source | What It Provides | API Key Required |
|---|
| 1 | RSS News | Headlines from 10 feeds (Reuters, BBC, Bloomberg, etc.) | No |
| 2 |
FRED | Economic indicators (Fed rate, CPI, GDP, VIX, oil, gold) | Yes (free) |
| 3 |
GDELT | Geopolitical event sentiment scores | No |
| 4 |
Odds API | Sports bookmaker consensus probabilities | Yes (free tier) |
| 5 |
FiveThirtyEight | US presidential approval polling averages | No |
| 6 |
Congress.gov | Bill status and legislative tracking | Yes (free) |
| 7 |
OpenFDA | Drug approval status and clinical trial data | No |
| 8 |
Open-Meteo | Weather forecasts for major cities | No |
| 9 |
USGS | Significant earthquake data | No |
| 10 |
Finnhub | Earnings calendar and IPO data | Yes (free) |
| 11 |
Manifold | Cross-platform prediction market prices | No |
| 12 |
Kalshi | Cross-platform prediction market prices | No |
Sources are selected automatically based on category detection from the
question text. Only relevant sources are queried to minimize latency.
Remixable Template
This skill is designed as a template you can customize:
- - Add your own data source: Implement a
_get_X_context(question) function
that returns a
list[str] of context lines. Add it to
_dispatch_sources().
- - Swap the LLM: Set
LLM_API_URL and LLM_MODEL env vars to point at
any OpenAI-compatible API (OpenRouter, Ollama, vLLM, etc.).
- - Adjust the threshold: Set
ESTIMATOR_THRESHOLD higher for fewer but
higher-conviction trades, or lower for more frequent trading.
- - Change the prompt: Edit the
_build_prompt() function to customize
the LLM's reasoning style.
Environment Variables
Required
| Variable | Description |
|---|
| INLINECODE7 | Simmer SDK API key for trading |
| INLINECODE8 |
API key for your LLM provider (default: OpenRouter) |
Optional
| Variable | Default | Description |
|---|
| INLINECODE9 | INLINECODE10 | Trading venue (sim for paper, polymarket for real) |
| INLINECODE13 |
10.0 | Trade size in USD per trade |
|
LLM_API_URL | OpenRouter endpoint | OpenAI-compatible chat completions URL |
|
LLM_MODEL |
xiaomi/mimo-v2-flash:free | Model identifier |
|
ESTIMATOR_THRESHOLD |
0.15 | Min divergence to trigger a trade (0.0-1.0) |
|
FRED_API_KEY | — | FRED API key (free at api.stlouisfed.org) |
|
ODDS_API_KEY | — | The Odds API key (free at the-odds-api.com) |
|
CONGRESS_API_KEY | — | Congress.gov API key (free) |
|
FINNHUB_API_KEY | — | Finnhub API key (free tier) |
|
LLM_CACHE_TTL |
1800 | LLM response cache TTL in seconds |
|
LLM_MAX_CALLS |
50 | Max LLM calls per run |
Usage
Dry-run (no trades, just log estimates):
CODEBLOCK1
Live trading:
CODEBLOCK2
Quiet mode (errors only):
CODEBLOCK3
Limit markets scanned:
CODEBLOCK4
Scheduling
Runs every 5 minutes via cron (*/5 * * * *). Managed automaton (auto-executes on schedule).
Capped at 50 LLM calls per run (LLM_MAX_CALLS) to control costs.
Security
- - All trades go through
SimmerClient.trade() only. No direct CLOB or wallet access. - Dry-run by default. The
--live flag must be explicitly passed to execute trades. - No wallet private keys are required or read by this script.
- LLM receives only the market question text and publicly available context (news headlines, economic indicators, odds). No credentials or private data are sent to the LLM.
- INLINECODE32 defaults to OpenRouter. You control which LLM endpoint is used.
- All optional API keys (FRED, Odds, Congress, Finnhub) are for free public data APIs. If unset, those data sources are simply skipped.
多源LLM估计器
一个预测市场交易机器人,通过10+数据源为LLM提供实时上下文信息。它将LLM的估计概率与当前市场价格进行比较,当检测到显著错误定价时进行交易。
工作原理
10+数据源 --> 上下文字符串 --> LLM提示词 --> 概率估计
|
与市场价格比较
|
如果偏差超过阈值则进行交易
- 1. 从Polymarket获取活跃市场(通过Simmer SDK)
- 对每个市场,从相关数据源收集实时上下文
- 同时检查Manifold和Kalshi的跨平台价格
- 将问题+上下文发送给LLM进行概率估计
- 如果LLM的估计与市场价格偏差超过阈值(默认15%),则进行交易
数据源
| # | 数据源 | 提供内容 | 需要API密钥 |
|---|
| 1 | RSS新闻 | 10个新闻源的头条(路透社、BBC、彭博等) | 否 |
| 2 |
FRED | 经济指标(美联储利率、CPI、GDP、VIX、石油、黄金) | 是(免费) |
| 3 |
GDELT | 地缘政治事件情感评分 | 否 |
| 4 |
Odds API | 体育博彩公司共识概率 | 是(免费版) |
| 5 |
FiveThirtyEight | 美国总统支持率民调平均值 | 否 |
| 6 |
Congress.gov | 法案状态和立法追踪 | 是(免费) |
| 7 |
OpenFDA | 药物批准状态和临床试验数据 | 否 |
| 8 |
Open-Meteo | 主要城市天气预报 | 否 |
| 9 |
USGS | 重大地震数据 | 否 |
| 10 |
Finnhub | 财报日历和IPO数据 | 是(免费) |
| 11 |
Manifold | 跨平台预测市场价格 | 否 |
| 12 |
Kalshi | 跨平台预测市场价格 | 否 |
数据源根据问题文本的类别检测自动选择。仅查询相关数据源以最小化延迟。
可混编模板
此技能设计为可自定义的模板:
- - 添加自己的数据源:实现一个返回list[str]上下文行的getXcontext(question)函数。将其添加到dispatchsources()中。
- 更换LLM:设置LLMAPIURL和LLMMODEL环境变量指向任何兼容OpenAI的API(OpenRouter、Ollama、vLLM等)。
- 调整阈值:将ESTIMATORTHRESHOLD设置更高可减少但提高交易确定性,设置更低可增加交易频率。
- 更改提示词:编辑build_prompt()函数自定义LLM的推理风格。
环境变量
必需
| 变量 | 描述 |
|---|
| SIMMERAPIKEY | Simmer SDK交易API密钥 |
| LLMAPIKEY |
LLM提供商的API密钥(默认:OpenRouter) |
可选
| 变量 | 默认值 | 描述 |
|---|
| TRADINGVENUE | sim | 交易场所(sim为模拟,polymarket为真实) |
| TRADESIZE |
10.0 | 每笔交易金额(美元) |
| LLM
APIURL | OpenRouter端点 | 兼容OpenAI的聊天补全URL |
| LLM_MODEL | xiaomi/mimo-v2-flash:free | 模型标识符 |
| ESTIMATOR_THRESHOLD | 0.15 | 触发交易的最小偏差(0.0-1.0) |
| FRED
APIKEY | — | FRED API密钥(免费,api.stlouisfed.org) |
| ODDS
APIKEY | — | The Odds API密钥(免费,the-odds-api.com) |
| CONGRESS
APIKEY | — | Congress.gov API密钥(免费) |
| FINNHUB
APIKEY | — | Finnhub API密钥(免费版) |
| LLM
CACHETTL | 1800 | LLM响应缓存有效期(秒) |
| LLM
MAXCALLS | 50 | 每次运行最大LLM调用次数 |
使用方法
模拟运行(不交易,仅记录估计值):
bash
python multisourceestimator.py
实盘交易:
bash
python multisourceestimator.py --live
静默模式(仅显示错误):
bash
python multisourceestimator.py --live --quiet
限制扫描市场数量:
bash
python multisourceestimator.py --live --max-markets 20
调度
通过cron每5分钟运行一次(/5 *)。自动管理(按计划自动执行)。
每次运行最多50次LLM调用(LLMMAXCALLS)以控制成本。
安全性
- - 所有交易仅通过SimmerClient.trade()进行。无直接CLOB或钱包访问。
- 默认模拟运行。必须显式传递--live标志才能执行交易。
- 此脚本不需要也不读取钱包私钥。
- LLM仅接收市场问题文本和公开可用的上下文(新闻头条、经济指标、赔率)。不会向LLM发送任何凭证或私有数据。
- LLMAPIURL默认为OpenRouter。您可以控制使用哪个LLM端点。
- 所有可选的API密钥(FRED、Odds、Congress、Finnhub)均用于免费的公共数据API。如果未设置,这些数据源将被跳过。