> For the complete documentation index, see [llms.txt](https://docs.koinju.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.koinju.io/exchanges/kraken.md).

# Kraken Spot: data collection and validation

Kraken spot historical trade data on Koinju, available since 2013-10-01. How trades are collected from Kraken's live feed and validated against Kraken's own candles and trade IDs.

Koinju provides trades and OHLCV candles for all Kraken spot markets since **2013-10-01**, under the exchange ID `kraken`. This page explains how we collect those trades and how we check them against Kraken's own data.

{% hint style="info" %}
How far back you can query depends on your plan: see [Pricing](/pricing.md). Every exchange and its start date is listed on [Coverage](/data/coverage.md).
{% endhint %}

## At a glance

| Property                | Value                                           |
| ----------------------- | ----------------------------------------------- |
| Exchange ID             | `kraken`                                        |
| Available since         | 2013-10-01                                      |
| Data                    | Public trades, OHLCV                            |
| Live source             | Kraken WebSocket API v2, `trade` channel        |
| Daily validation        | Every day, against Kraken's daily OHLC candles  |
| Trade-ID sequence check | Several times a day, against Kraken's trade IDs |

## How we collect Kraken trades

* **Kraken WebSocket API v2.** We subscribe to Kraken's `trade` channel for every listed Kraken spot market. Each record keeps Kraken's own trade ID.
* **New listings picked up automatically.** The market list is refreshed every minute, and new markets are subscribed without a restart.
* **Two collectors.** Two collectors subscribe to every market in parallel. Both copies of a trade carry the same key (exchange, market and trade ID), and the second copy is dropped before storage, so either collector alone is enough to capture a trade.
* **Kraken's timestamps.** A trade's `timestamp` is the trade time reported by Kraken, not the time we received it.
* **Automatic reconnection.** Connections are kept alive with regular pings. A dropped connection is re-established and resubscribed automatically, and anything missed while reconnecting is recovered by the validation below.

## How we validate Kraken trades

Kraken spot data goes through two independent checks: daily validation against Kraken's candles, and a trade-ID sequence check against Kraken's trade IDs. The two complement each other: the trade-ID check pinpoints individual missing trades within hours, while daily validation also catches a market that goes completely quiet, which leaves no trade IDs to check.

### Daily validation against Kraken's own candles

Every day, for every market, we compare the volume we collected with the volume in Kraken's own daily OHLC candle. Kraken's figure is independent of our live feed, so a shortfall means trades are missing.

1. **Compare** each market's daily volume with Kraken's daily candle.
2. **Fill:** for a market with a shortfall, compare hour by hour, fetch the trades of the hours that differ from Kraken's REST API, and add only the trades we do not already hold.
3. **Compare again** on the updated data. Any difference that remains is traced to Kraken's own data.

A day is marked as validated only after all three steps complete. If any step fails, the day stays open and is checked again on the next run.

### Trade-ID sequence check

Kraken gives every trade in a market a sequential trade ID, so a jump in the sequence shows exactly which trades are missing. Several times a day, we scan newly collected trades inside our ClickHouse database for jumps in trade IDs (gaps) and repeated trade IDs (duplicates).

* For each gap, the missing trades are requested from Kraken's REST API and added, but only if their timestamps fall inside the gap's time window.
* A repeated trade ID is reduced to a single record, and the hour's volume is verified afterwards.

## Kraken-specific details

* **Both checks run.** Kraken is validated by daily validation and by the live trade-ID sequence check.
* **Kraken's own trade IDs.** `trade_id` is the ID Kraken assigned, so any trade can be matched against Kraken's own data.

## Access Kraken data

* [Public trades](/data/public-trades.md): every trade, through SQL (`api.trade`) or REST, with `exchange = 'kraken'`.
* [OHLCV](/data/ohlcv.md): candles for every market.
* [Market list](/data/market-list.md): all `kraken` markets and their symbols.
* [How to connect](/how-to-connect.md): SQL, REST and client setup.

## FAQ

**How complete is Koinju's Kraken trade data?**

It is checked in two independent ways: every day against Kraken's own daily candles, and several times a day trade ID by trade ID. Missing trades found by either check are fetched from Kraken's REST API and added.

**Can reconnections create duplicate Kraken trades?**

Repeated copies are removed: the two collectors' copies of a trade share one key, so the second copy is dropped before storage, and the trade-ID sequence check reduces any repeated trade ID to a single record.

**Which timestamp does Koinju store?**

The trade time reported by Kraken.

**Which Kraken markets are included?**

Every spot market Kraken lists as online. The market list is refreshed every minute, so new listings are collected from their first minutes.
