> 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/bybit.md).

# Bybit Spot historical trade data

Bybit Spot historical trade data since 2022-11-10, available through SQL or REST in one unified schema and checked every day against Bybit's own data.

Koinju provides Bybit Spot trades and OHLCV candles for all markets since **2022-11-10**, under the exchange ID `bybit`. This page explains what that gives you compared with Bybit's own API, how we collect the data, and how we verify that no trades are missed.

{% 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 %}

## Why use Koinju for Bybit data

* **Full history in one place.** Bybit publishes its trade history as daily trade files ([Bybit history data](https://www.bybit.com/en/derivative-activity/history-data)), which our volume check uses to replace hours where trades are missing. Koinju provides it as one continuous history since 2022-11-10, aligned to UTC days and queryable for any period through SQL or REST.
* **One schema across exchanges.** Unified symbols and columns across every exchange we cover, Bybit included, so the same query works on all of them.
* **Checked against Bybit's own data.** Every day, each market's volume is compared with Bybit's own daily candle and any missing trades are added.
* **Faithful to Bybit.** Bybit's own trade times, with prices and quantities exactly as Bybit publishes them.

## At a glance

| Property              | Value                                                                    |
| --------------------- | ------------------------------------------------------------------------ |
| Exchange ID           | `bybit`                                                                  |
| Historical data since | 2022-11-10                                                               |
| Data types            | Public trades, OHLCV                                                     |
| Collected from        | Bybit's real-time WebSocket, public trade topic (`publicTrade.<symbol>`) |
| Volume check          | Every day, against Bybit's UTC daily candles                             |

## How we collect Bybit trades

* **Every trade, individually.** We subscribe to Bybit's [public trade topic](https://bybit-exchange.github.io/docs/v5/websocket/public/trade) (`publicTrade.<symbol>`) for every Bybit Spot market listed as trading. Bybit pushes trades in real time, several per message when needed, and each trade is stored as its own row.
* **New listings picked up automatically.** The market list is refreshed every minute, and new markets are subscribed without a restart.
* **Active redundancy.** Every market is collected twice, by two collectors running in parallel. If one connection drops, it reconnects and resubscribes automatically while the other keeps collecting trades. Both copies of a trade share one key (exchange, market and trade ID), so the second copy is dropped before storage, and anything missed is recovered by the checks below.
* **Bybit's timestamps.** A trade's `timestamp` is the trade time reported by Bybit, not the time we received it.
* **Exact values.** Prices and quantities are stored exactly as Bybit publishes them, as high-precision decimals with no rounding.

## From Bybit's message to your data

Each trade Bybit publishes is stored as one row, with Bybit's fields mapped to the same columns used for every exchange:

| Bybit field | Koinju column | Notes                                                         |
| ----------- | ------------- | ------------------------------------------------------------- |
| `s`         | `market`      | Koinju's universal symbol, for example `BTC-USDT`             |
| `i`         | `trade_id`    | Bybit's trade ID, for trades collected live                   |
| `p`         | `price`       | Exact decimal, no rounding                                    |
| `v`         | `quantity`    | Exact decimal, as Bybit publishes it                          |
| `S`         | `side`        | `buy` or `sell`: the side of the taker, as Bybit publishes it |
| `T`         | `timestamp`   | Bybit's trade time, in milliseconds                           |

## How we verify that no Bybit trades are missed

### Volume check against Bybit's own candles

The reference is Bybit's own daily candle for each UTC day. A daily candle is only final once the day has closed, so each day is checked the morning after, against Bybit's final figures for that day. The daily rhythm follows the reference data rather than an arbitrary time window.

1. **Compare.** Each market's volume for the UTC day is compared with Bybit's daily candle. Markets where our volume is lower than Bybit's go to step 2.
2. **Replace.** For those markets, the comparison is repeated hour by hour, and each hour that differs is replaced with the trades from Bybit's daily trade files.
3. **Re-check.** The whole comparison runs again on the updated data, and any difference that remains is flagged for review.

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

## Bybit-specific details

* **UTC daily candles.** Bybit's Spot daily candles (`interval=D`) start at 00:00 UTC, the same day boundaries as our daily total.
* **The exact figure compared.** The volume check compares the daily candle's `volume` field with the sum of the trade quantities we hold for that day.

## Access Bybit data

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

## FAQ

**Which timestamp does Koinju store?**

The trade time reported by Bybit.

**Which Bybit Spot markets are included?**

Every Spot market Bybit lists as trading. The market list is refreshed every minute, so a new listing is subscribed within a minute of appearing in Bybit's market list.
