名称: 市场索引
描述: “在所有平台中搜索、发现和浏览索引的市场”
表情符号: “🔍”
市场索引 - 完整API参考
在所有预测市场平台中搜索、发现和浏览市场,支持高级过滤和分类。
聊天命令
搜索
/index search "trump" # 搜索所有索引的市场
/index search "election" --platform poly # 搜索特定平台
/index search "fed rate" --category finance # 按类别过滤
/index search "crypto" --min-volume 10000 # 最小成交量过滤器
/index search "sports" --active-only # 仅活跃市场
浏览类别
/index categories # 列出所有类别
/index category politics # 浏览政治市场
/index category crypto # 浏览加密货币市场
/index category sports # 浏览体育市场
/index trending # 趋势市场
市场发现
/index new # 新创建的市场
/index new --last 24h # 过去24小时
/index hot # 高活动市场
/index closing-soon # 即将结束的市场
索引管理
/index update # 刷新市场索引
/index update poly # 更新特定平台
/index stats # 索引统计
/index status # 索引健康状态
TypeScript API参考
创建市场索引
import { createMarketIndex } from 'clodds/market-index';
const index = createMarketIndex({
platforms: ['polymarket', 'kalshi', 'manifold', 'betfair'],
// 自动刷新
autoRefresh: true,
refreshIntervalMs: 300000, // 5分钟
// 存储
cachePath: './market-index.db',
});
搜索市场
// 全文搜索
const results = await index.search('trump election', {
platforms: ['polymarket', 'kalshi'],
limit: 20,
sortBy: 'volume', // 'volume' | 'relevance' | 'endDate' | 'created'
});
for (const market of results) {
console.log(`[${market.platform}] ${market.question}`);
console.log(` 类别: ${market.category}`);
console.log(` 成交量: $${market.volume.toLocaleString()}`);
console.log(` 结束: ${market.endDate}`);
}
// 带过滤器
const filtered = await index.search('', {
category: 'politics',
minVolume: 10000,
activeOnly: true,
endsBefore: '2024-12-31',
});
浏览类别
// 获取所有类别
const categories = await index.getCategories();
for (const cat of categories) {
console.log(`${cat.name}: ${cat.marketCount} 市场`);
}
// 获取类别中的市场
const politics = await index.getMarketsByCategory('politics', {
limit: 50,
sortBy: 'volume',
});
市场发现
// 获取新市场
const newMarkets = await index.getNewMarkets({
since: Date.now() - 24 * 60 * 60 * 1000, // 过去24小时
limit: 20,
});
// 获取趋势/热门市场
const trending = await index.getTrendingMarkets({
period: '24h',
limit: 10,
});
for (const market of trending) {
console.log(`${market.question}`);
console.log(` 24小时成交量: $${market.volume24h.toLocaleString()}`);
console.log(` 成交量变化: ${market.volumeChange > 0 ? '+' : ''}${market.volumeChange}%`);
}
// 即将结束的市场
const closingSoon = await index.getClosingSoon({
within: '48h',
minVolume: 1000,
});
索引管理
// 更新索引
await index.update();
// 更新特定平台
await index.update('polymarket');
// 获取索引统计
const stats = await index.getStats();
console.log(`总市场数: ${stats.totalMarkets}`);
console.log(`按平台:`);
for (const [platform, count] of Object.entries(stats.byPlatform)) {
console.log(` ${platform}: ${count}`);
}
console.log(`按类别:`);
for (const [category, count] of Object.entries(stats.byCategory)) {
console.log(` ${category}: ${count}`);
}
console.log(`最后更新: ${stats.lastUpdated}`);
// 检查状态
const status = await index.getStatus();
console.log(`状态: ${status.status}`);
console.log(`索引市场数: ${status.marketCount}`);
console.log(`索引年龄: ${status.ageMinutes} 分钟`);
获取单个市场
// 获取市场详情
const market = await index.getMarket('polymarket', 'market-123');
console.log(`问题: ${market.question}`);
console.log(`描述: ${market.description}`);
console.log(`类别: ${market.category}`);
console.log(`平台: ${market.platform}`);
console.log(`成交量: $${market.volume.toLocaleString()}`);
console.log(`流动性: $${market.liquidity.toLocaleString()}`);
console.log(`开始: ${market.startDate}`);
console.log(`结束: ${market.endDate}`);
console.log(`结果: ${market.outcomes.join(', ')}`);
类别
平台上的标准类别:
| 类别 |
描述 |
| politics |
选举、政策、政府 |
| crypto |
加密货币价格、事件 |
| finance |
美联储利率、股票、经济 |
| sports |
游戏、锦标赛、奖项 |
| entertainment |
电影、电视、名人 |
| science |
研究、太空、气候 |
| technology |
科技公司、产品 |
| world |
国际事件 |
| other |
杂项 |
搜索语法
| 语法 |
示例 |
描述 |
| 关键词 |
trump election |
匹配任何单词 |
| 精确短语 |
"federal reserve" |
匹配精确短语 |
| 排除 |
election -trump |
排除单词 |
| 平台过滤器 |
platform:poly |
特定平台 |
| 类别过滤器 |
category:politics |
特定类别 |
排序选项
| 选项 |
描述 |
volume |
成交量最高优先 |
relevance |
最佳匹配优先 |
endDate |
即将结束优先 |
created |
最新创建优先 |
liquidity |
流动性最高优先 |
最佳实践
- 定期刷新 - 市场频繁变化
- 使用过滤器 - 缩小大型结果集
- 检查流动性 - 不仅仅是成交量
- 监控新市场 - 新列表中的机会
- 跟踪结束日期 - 不要错过结算