> ## 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.

# Prediction Market Data ZH

> 查询当前已挂载的 Polymarket 和 Kalshi 市场发现、事件、活动与交易历史数据。

[View on GitHub ->](https://github.com/AIsa-team/agent-skills/tree/main/prediction-market-data-zh)

**预测市场数据查询。** 用 AIsa 访问当前已挂载的 Polymarket 和 Kalshi 只读数据接口：市场发现、事件查询、用户活动和 Kalshi 交易历史。

## Install

First, install the AIsa CLI if you have not already:

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

Then install the skill:

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

## What can agents do with it?

<CardGroup cols={2}>
  <Card title="Market lookup" icon="magnifying-glass-dollar">
    Find relevant prediction markets for a topic.
  </Card>

  <Card title="Event lookup" icon="calendar-days">
    Review Polymarket event groups and related markets.
  </Card>

  <Card title="Trade history" icon="chart-line">
    Pull recent Kalshi trades with optional ticker and block-trade filters.
  </Card>

  <Card title="Chinese reports" icon="language">
    Summarize mounted market-discovery evidence in Chinese.
  </Card>
</CardGroup>

## 配置

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

在 [aisa.one](https://aisa.one) 获取 Key（按量付费）。

## 工作流程

查询预测市场数据的步骤：

1. **搜索市场/事件**：先用 Polymarket 或 Kalshi discovery endpoint 找候选市场。
2. **提取标识符**：例如 Polymarket `slug`/`conditionId`/`clobTokenIds`，Kalshi `ticker`/`event_ticker`。
3. **继续验证**：如果需要实时价格、订单簿或交易执行，请使用交易所官方 API 或交易系统继续验证。

<Warning>
  AIsa 当前挂载的是下面列出的 discovery/trade-history endpoint。旧版 AIsa-hosted price、orderbook、wallet、candlestick、matching-market 示例已移除，因为鉴权实测返回 `api endpoint not found`。
</Warning>

## 快速示例

### Polymarket：市场与事件

```bash theme={null}
# 市场发现
python3 scripts/prediction_market_client.py polymarket markets --limit 5

# 事件查询
python3 scripts/prediction_market_client.py polymarket events --limit 5

# 指定用户活动
python3 scripts/prediction_market_client.py polymarket activity --user <钱包地址> --limit 5
```

### Kalshi：市场与交易

```bash theme={null}
# 市场发现
python3 scripts/prediction_market_client.py kalshi markets --status open --limit 5

# 交易历史
python3 scripts/prediction_market_client.py kalshi trades --limit 5 --is-block-trade false
```

## ID 参考

大多数后续分析需要从 discovery 返回中获取 ID 或 ticker。

| 平台         | ID 字段          | 获取位置                                      |
| ---------- | -------------- | ----------------------------------------- |
| Polymarket | `slug`         | `/polymarket/markets` 返回中的 `slug`         |
| Polymarket | `conditionId`  | `/polymarket/markets` 返回中的 `conditionId`  |
| Polymarket | `clobTokenIds` | `/polymarket/markets` 返回中的 `clobTokenIds` |
| Kalshi     | `ticker`       | `/kalshi/markets` 返回中的 `ticker`           |
| Kalshi     | `event_ticker` | `/kalshi/markets` 返回中的 `event_ticker`     |

## 命令参考

### Polymarket

```bash theme={null}
python3 scripts/prediction_market_client.py polymarket markets [--limit <数值>]
python3 scripts/prediction_market_client.py polymarket events [--limit <数值>]
python3 scripts/prediction_market_client.py polymarket activity --user <钱包地址> [--market-slug <slug>] [--limit <数值>]
```

### Kalshi

```bash theme={null}
python3 scripts/prediction_market_client.py kalshi markets [--status unopened|open|paused|closed|settled] [--limit <数值>]
python3 scripts/prediction_market_client.py kalshi trades [--ticker <ticker>] [--min-ts <unix时间戳>] [--max-ts <unix时间戳>] [--is-block-trade true|false] [--limit <数值>]
```

## 理解返回数据

* Polymarket `/markets` 和 `/events` 返回顶层 JSON 数组。
* Kalshi `/markets` 返回 `{ markets, cursor }`。
* Kalshi `/trades` 返回 `{ trades, cursor }`。
* 如需实时可执行价格、订单簿深度或交易动作，请以交易所官方接口/交易系统为准。

## 安全与权限

**需要：** `AISA_API_KEY` 环境变量。

所有操作均为**只读**，通过 HTTPS GET 请求 `api.aisa.one`。不执行交易、不连接钱包、除 API Key 外不发送个人数据。

完整文档：[AIsa API 参考](https://aisa.one/docs/api-reference)。

## Get started

1. Sign up at [aisa.one](https://aisa.one) (new accounts start with \$2 free credit).
2. Generate an API key from the console.
3. Set your key and install the skill:
   ```bash theme={null}
   export AISA_API_KEY="your-key"
   npm install -g @aisa-one/cli
   aisa skills install prediction-market-data-zh
   ```
4. Start a new agent session so the runtime loads the updated skill instructions.

## Related

<CardGroup cols={3}>
  <Card title="Prediction Market Data" icon="chart-simple" href="/agent-skills/prediction-market-data">
    English-language prediction market data skill.
  </Card>

  <Card title="Prediction Market Arbitrage ZH" icon="scale-balanced" href="/agent-skills/prediction-market-arbitrage-zh">
    Chinese-language cross-market research workflow.
  </Card>

  <Card title="Prediction Market API" icon="code" href="/api-reference/prediction-market/get_polymarket-events">
    Polymarket and Kalshi mounted endpoint docs.
  </Card>
</CardGroup>
