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

# Candles

> 1-minute and 1-hour OHLC candles per launch in the launch currency, with volume and trade counts, ready for a chart.

`candle` holds OHLC buckets per launch at two intervals: `60` seconds and `3600` seconds. Every indexed trade updates both buckets it falls into, so the table is complete for the trades the indexer sees and has no rows for minutes without a trade.

## Fields

| Field                          | Type   | Unit                  | Meaning                                                                                                      |
| ------------------------------ | ------ | --------------------- | ------------------------------------------------------------------------------------------------------------ |
| `launch`                       | hex    | address               | Launch token address. Part of the primary key.                                                               |
| `interval`                     | int    | seconds               | `60` or `3600`. Part of the primary key.                                                                     |
| `openTime`                     | bigint | unix seconds          | Bucket start: `floor(timestamp / interval) * interval`. Part of the primary key.                             |
| `open`, `high`, `low`, `close` | bigint | quote per token, 1e18 | Spot price after each trade in the bucket. `open` is the spot after the first trade, not the previous close. |
| `volume`                       | bigint | quote units           | Sum of `quoteAmount` of the trades in the bucket.                                                            |
| `trades`                       | int    |                       | Number of trades in the bucket.                                                                              |

The primary key `(launch, interval, openTime)` is the only index; always filter on `launch` and `interval` and order by `openTime`.

<Note>
  Candle prices are the spot price after each trade (the curve's `spotPrice()` or the pool price from `sqrtPriceX96`), so a candle's `close` equals `launch.lastPriceQuote` right after its last trade. Execution prices live on the [trade](/api/queries/trades) rows.
</Note>

## Examples

Candles for a chart, oldest first, from a start time:

```graphql theme={"system"}
query Candles($token: String!, $interval: Int!, $from: BigInt!) {
  candles(
    where: { launch: $token, interval: $interval, openTime_gte: $from }
    orderBy: "openTime"
    orderDirection: "asc"
    limit: 1000
  ) {
    items { openTime open high low close volume trades }
  }
}
```

The most recent hourly candles (fetch descending, then reverse client side, which is what the app does):

```graphql theme={"system"}
{
  candles(where: { launch: "0x...", interval: 3600 }, orderBy: "openTime", orderDirection: "desc", limit: 168) {
    items { openTime open high low close volume }
  }
}
```

Paging through a long minute series:

```graphql theme={"system"}
query Minutes($token: String!, $after: String) {
  candles(where: { launch: $token, interval: 60 }, orderBy: "openTime", orderDirection: "asc", limit: 1000, after: $after) {
    items { openTime open high low close volume trades }
    pageInfo { hasNextPage endCursor }
  }
}
```

A single bucket by its composite key:

```graphql theme={"system"}
{ candle(launch: "0x...", interval: 3600, openTime: "1789690800") { open high low close volume trades } }
```

Through the launch relation, together with the launch's current price:

```graphql theme={"system"}
{
  launch(token: "0x...") {
    symbol lastPriceQuote
    candles(where: { interval: 3600 }, orderBy: "openTime", orderDirection: "desc", limit: 24) {
      items { openTime open high low close volume }
    }
  }
}
```

With `curl`:

```bash theme={"system"}
curl -s https://api.windrose.market/graphql \
  -H 'content-type: application/json' \
  -d '{"query":"query($t:String!){ candles(where:{launch:$t, interval:3600}, orderBy:\"openTime\", orderDirection:\"desc\", limit:24){ items { openTime open high low close volume trades } } }","variables":{"t":"0x..."}}'
```

## Charting notes

* Prices are `1e18` fixed point in the launch currency. Divide by `1e18` before handing them to a chart, or multiply by `1e18 / currency.lastRate` first for a USD chart.
* Gaps are real: there is no row for a bucket with no trade. Fill forward from the previous `close` if your chart library expects a continuous series.
* `volume` is quote units, so `volume / 1e18` is the bucket's turnover in the launch currency.
* Post-graduation candles only exist on chains that index pool swaps (the testnets). On Robinhood Chain the series ends at graduation.
* Timestamps are seconds. Lightweight Charts and most libraries take seconds directly; convert to milliseconds only if yours needs it.
