> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> - Base URLs: models `https://api.aisa.one/v1` (Gemini GenerateContent: `https://api.aisa.one/v1beta`); data APIs `https://api.aisa.one/apis/v1`. The `servers` of each operation in https://aisa.one/openapi.yaml is authoritative.
> - Auth: `Authorization: Bearer $AISA_API_KEY`. Never print, log, or commit the key.
> - MCP (preferred for agents): `https://mcp.aisa.one/mcp`, signed in with OAuth, so there is no key to paste.
> - Agent Skill: `npx skills add AIsa-team/agent-skills --skill aisa`. Fallback with the AIsa CLI: `aisa skills install aisa`.
> - Spending: docs, https://aisa.one/models, https://aisa.one/api, `/v1/models`, and MCP `search`, `list_categories`, `get_details`, `batch_quote`, and the `account` operation are free. Quote the exact calls before running them (MCP `batch_quote`, CLI `aisa quote --json`). If the quote reports `auto_execute_eligible: true`, run it unless the user set a tighter limit or asked only for a quote. Otherwise, tell the user in one message the planned calls, the quoted price, and a total USD budget for the task, then wait for approval. Direct HTTP calls follow the stricter rule at https://aisa.one/docs/get-started/cli.md#direct-http-fallback. Do not make paid calls to test availability. Full rule: https://aisa.one/llms.txt

# 预测市场数据

> 面向自主智能体的 Polymarket 与 Kalshi 市场发现/交易历史挂载数据。

[在 GitHub 上查看 →](https://github.com/AIsa-team/agent-skills/tree/main/financial/prediction-market-data)

**面向自主智能体的预测市场发现数据。** 一个 `AISA_API_KEY` 即可读取已挂载的 Polymarket 和 Kalshi 端点，用于市场发现、事件查询、活动记录和 Kalshi 交易历史。

## 安装

如果还没有安装 AIsa CLI，请先安装：

```bash theme={null}
npm install -g @aisa-one/cli
```

然后安装该技能：

```bash theme={null}
aisa skills install prediction-market-data
```

> [!NOTE]
>
> 需要中文版？安装 [`prediction-market-data-zh`](https://github.com/AIsa-team/agent-skills/tree/main/financial/prediction-market-data-zh)：查询当前已挂载的 Polymarket 和 Kalshi 市场发现、事件、活动与交易历史数据，并以中文输出。
>
> ```bash theme={null}
> aisa skills install prediction-market-data-zh
> ```

## 智能体可以用它做什么？

> [card] 市场发现
>
> “查找与某个主题相关的 Polymarket 和 Kalshi 市场。”

> [card] 事件查询
>
> “浏览 Polymarket 事件组及其关联市场。”

> [card] 交易历史
>
> “按可选 ticker 和 block trade 过滤条件拉取近期 Kalshi 交易记录。”

> [card] 活动检查
>
> “检查特定用户在某段时间内的 Polymarket 活动。”

> [card] 流动性初筛
>
> “使用市场发现响应中的成交量和流动性字段，决定哪些市场值得进一步检查。”

> [card] 研究流程
>
> “在使用交易所原生工具检查价格、订单簿或执行前，先构建候选集合。”

## 核心能力

* **市场发现** —— 使用 provider 支持的过滤条件获取 Polymarket 和 Kalshi 市场。
* **事件索引** —— 获取 Polymarket 事件/分组数据。
* **交易历史** —— 使用 `limit`、`cursor`、`ticker`、`min_ts`、`max_ts` 和 `is_block_trade` 获取 Kalshi trades。
* **活动查询** —— 使用 `user` 以及可选时间/市场过滤条件获取 Polymarket 用户活动。

> [!WARNING]
>
> AIsa 当前挂载的是下方列出的端点。旧版 AIsa-hosted price、orderbook、wallet、candlestick 和 matching-market 端点示例已移除，因为鉴权探测返回 `api endpoint not found`。

## 快速开始

```bash theme={null}
export AISA_API_KEY="your-key"
```

### Polymarket

```bash theme={null}
# 市场发现
curl "https://api.aisa.one/apis/v1/polymarket/markets?limit=5" \
  -H "Authorization: Bearer $AISA_API_KEY"

# 事件
curl "https://api.aisa.one/apis/v1/polymarket/events?limit=5" \
  -H "Authorization: Bearer $AISA_API_KEY"

# 指定用户地址的活动
curl "https://api.aisa.one/apis/v1/polymarket/activity?user=WALLET_ADDRESS&limit=5" \
  -H "Authorization: Bearer $AISA_API_KEY"
```

### Kalshi

```bash theme={null}
# 市场发现
curl "https://api.aisa.one/apis/v1/kalshi/markets?limit=5&status=open" \
  -H "Authorization: Bearer $AISA_API_KEY"

# 交易
curl "https://api.aisa.one/apis/v1/kalshi/trades?limit=5&is_block_trade=false" \
  -H "Authorization: Bearer $AISA_API_KEY"
```

## Python 客户端

```bash theme={null}
# Polymarket
python3 scripts/prediction_market_client.py poly markets --limit 5
python3 scripts/prediction_market_client.py poly events --limit 5
python3 scripts/prediction_market_client.py poly activity --user WALLET_ADDRESS --limit 5

# Kalshi
python3 scripts/prediction_market_client.py kalshi markets --limit 5 --status open
python3 scripts/prediction_market_client.py kalshi trades --limit 5 --is-block-trade false
```

## 端点参考

| Endpoint | 方法 | 用途 |
| - | - | - |
| `/polymarket/markets` | GET | [Polymarket 市场](https://aisa.one/docs/api-reference/prediction-market/get_polymarket-markets.md) |
| `/polymarket/events` | GET | [Polymarket 事件](https://aisa.one/docs/api-reference/prediction-market/get_polymarket-events.md) |
| `/polymarket/activity` | GET | [活动记录](https://aisa.one/docs/api-reference/prediction-market/get_polymarket-activity.md) |
| `/kalshi/markets` | GET | [Kalshi 市场](https://aisa.one/docs/api-reference/prediction-market/get_kalshi-markets.md) |
| `/kalshi/trades` | GET | [Kalshi 交易记录](https://aisa.one/docs/api-reference/prediction-market/get_kalshi-trades.md) |

## 开始使用

1. 在 [aisa.one](https://aisa.one) 注册（新账户有 \$1 免费额度）。
2. 从控制台生成 API key。
3. 设置 key 并安装技能：
   ```bash theme={null}
   export AISA_API_KEY="your-key"
   npm install -g @aisa-one/cli
   aisa skills install prediction-market-data
   ```

## 相关

> [card] [预测市场 API 参考](https://aisa.one/docs/api-reference/prediction-market/get_polymarket-markets.md)
>
> 已挂载的 Polymarket 和 Kalshi 发现端点。

> [card] [套利技能](https://aisa.one/docs/zh/agent-skills/prediction-market-arbitrage.md)
>
> 跨平台市场研究的候选发现流程。

> [card] [错误代码](https://aisa.one/docs/api-reference/errors.md)
>
> 处理上游交易所错误。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.