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

# Bitfinex Futures historical trade data

Bitfinex Futures historical trade data since 2019-07-03, available through SQL or REST in one unified schema and checked every day against Bitfinex's own data.

Koinju provides Bitfinex Futures trades and OHLCV candles for all markets since **2019-07-03**, under the exchange ID `bitfinex-future`. This page explains what that gives you compared with Bitfinex'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 Bitfinex data

* **Full history in one place.** Bitfinex's REST trades endpoint, which our volume check uses to add missing trades, returns up to 10,000 trades per request for a chosen time range and is limited to 15 requests per minute ([Bitfinex docs](https://docs.bitfinex.com/reference/rest-public-trades)). Koinju provides it as one continuous history since 2019-07-03, 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, Bitfinex included, so the same query works on all of them.
* **Checked against Bitfinex's own data.** Every day, each market's volume is compared with Bitfinex's own daily candle and any missing trades are added.
* **Faithful to Bitfinex.** Bitfinex's own trade IDs and trade times.

## At a glance

| Property              | Value                                                            |
| --------------------- | ---------------------------------------------------------------- |
| Exchange ID           | `bitfinex-future`                                                |
| Historical data since | 2019-07-03                                                       |
| Data types            | Public trades, OHLCV                                             |
| Collected from        | Bitfinex's real-time WebSocket API v2, trades channel (`trades`) |
| Volume check          | Every day, against Bitfinex's UTC daily candles                  |

## How we collect Bitfinex trades

* **Every trade, individually.** We subscribe to Bitfinex's [trades channel](https://docs.bitfinex.com/reference/ws-public-trades) (`trades`) for every listed Bitfinex Futures market. Bitfinex sends a trade message whenever a trade occurs, and each row keeps Bitfinex's own trade ID.
* **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.
* **Bitfinex's timestamps.** A trade's `timestamp` is the trade time reported by Bitfinex, not the time we received it.

## From Bitfinex's message to your data

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

| Bitfinex field | Koinju column | Notes                                                                                                 |
| -------------- | ------------- | ----------------------------------------------------------------------------------------------------- |
| `symbol`       | `market`      | Koinju's universal symbol, for example `BTC-USDT-PERP`                                                |
| `ID`           | `trade_id`    | Bitfinex's own trade ID                                                                               |
| `PRICE`        | `price`       | Bitfinex's trade price                                                                                |
| `AMOUNT`       | `quantity`    | The size of the trade, without its sign                                                               |
| `AMOUNT`       | `side`        | `buy` when `AMOUNT` is positive, `sell` when it is negative: the taker's side, as Bitfinex defines it |
| `MTS`          | `timestamp`   | Bitfinex's trade time, in milliseconds                                                                |

## How we verify that no Bitfinex trades are missed

### Volume check against Bitfinex's own candles

The reference is Bitfinex'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 Bitfinex'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 Bitfinex's daily candle. Markets where our volume is lower than Bitfinex's go to step 2.
2. **Add.** For those markets, the comparison is repeated hour by hour. The trades of the hours that differ are fetched from Bitfinex's REST API, and only trades we do not already hold are added.
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.

## Bitfinex-specific details

* **UTC daily candles.** Bitfinex's daily candles (`1D`) 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, the quantity traded within the time frame ([Bitfinex docs](https://docs.bitfinex.com/reference/rest-public-candles)), with the sum of the trade quantities we hold for that day.
* **Side from the sign of the amount.** Bitfinex publishes no separate side field: a trade's `AMOUNT` is positive for a buy and negative for a sell, as decided by the taker ([Bitfinex docs](https://docs.bitfinex.com/reference/ws-public-trades)). We store `buy` or `sell` in `side`, and the size without its sign in `quantity`.
* **Bitfinex futures names.** Bitfinex names its futures markets with an `F0` suffix, for example `tBTCF0:USTF0` ([Bitfinex docs](https://docs.bitfinex.com/docs/derivatives)). Our symbols use plain names, so `BTCF0:USTF0` is `BTC-USDT-PERP`.

## Access Bitfinex data

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

## FAQ

**How does Koinju set the side of a Bitfinex trade?**

From the sign of Bitfinex's `AMOUNT`: positive is a buy and negative is a sell, as decided by the taker. The quantity is stored without the sign.

**Which timestamp does Koinju store?**

The trade time reported by Bitfinex.

**Which Bitfinex Futures markets are included?**

Every futures market Bitfinex lists. The market list is refreshed every minute, so a new listing is subscribed within a minute of appearing in Bitfinex's market list.
