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

# Candles (OHLC) K 線

> 代幣 / 交易對 / 池子的多週期 K 線——基於完整成交流預聚合。

**Candles (OHLC)** 資料產品就是你本來要自己從 [Trades](/zh-Hant/docs/data-products/trades) 聚合出來的 K 線（Open / High / Low / Close / Volume）。支援多週期，覆蓋代幣、交易對與具體池子。

## 欄位

| 欄位                                       | 說明                   |
| :--------------------------------------- | :------------------- |
| `open`, `high`, `low`, `close`           | USD 或 quote 代幣計價，可配置 |
| `volumeUsd`, `volumeBase`, `volumeQuote` | 分方向成交量               |
| `trades`                                 | 該 bar 的成交筆數          |
| `buyers`, `sellers`                      | 獨立地址數（部分場景可用）        |
| `timestamp`                              | bar 開始時間，UTC         |

## 週期

| 週期              | 最早回溯   | 典型用途     |
| :-------------- | :----- | :------- |
| `1s`            | 最近數小時  | 高頻 / 實時圖 |
| `1m`、`5m`、`15m` | 天級     | 日內圖表與告警  |
| `1h`、`4h`       | 月級     | 波段交易看板   |
| `1d`、`1w`       | 專案生命週期 | 長期分析     |

## 接入方式

<CardGroup cols={2}>
  <Card title="REST" icon="database" href="/zh-Hant/api-reference/endpoint/data/token/v2/token-chain-tokenaddress-candles-get">
    `tokens/{address}/candles`、`pools/{address}/candles`、`pairs/{address}/candles`。
  </Card>

  <Card title="WebSocket" icon="bolt" href="/zh-Hant/api-reference/endpoint/websocket/api">
    `dex-candle:{chain}_{tokenAddress}_{resolution}`（USD）與 `dex-candle-in-native:...`（原生幣計價）。SDK：`client.stream.subscribeTokenCandles({ chain, tokenAddress, resolution, callback })`。
  </Card>

  <Card title="GraphQL" icon="diagram-project" href="/zh-Hant/graphql/getting-started/overview">
    一次查詢同時取 K 線與代幣後設資料。
  </Card>

  <Card title="SDK" icon="box" href="/zh-Hant/sdks/overview">
    `client.token.getCandles(chain, tokenAddress, { resolution })` 返回型別化陣列。
  </Card>
</CardGroup>

## 常見用例

* 渲染 TradingView 風格的價格圖
* 歷史 OHLC 喂回測引擎
* 下游計算 RSI / MACD / VWAP 等指標
* 驅動時序異常告警

## 計費

REST / GraphQL 按返回 bar 數分頁計費；WebSocket 按 bar 更新條數。

## 下一步

<CardGroup cols={2}>
  <Card title="Trades（tick 級）" icon="right-left" href="/zh-Hant/docs/data-products/trades">
    需要 tick 粒度或自定義聚合時用。
  </Card>

  <Card title="DEX Pools 池子" icon="droplet" href="/zh-Hant/docs/data-products/dex-pools">
    池子級 K 線來自池子的成交。
  </Card>
</CardGroup>
