# Bids and asks

## What is this dataset?&#x20;

All bids and asks on an exchange's order book. Use Kaiko Stream for real-time tick-level updates, or CSV for backdated information.

### File structure details

* File Name: \[kaiko\_legacy\_slug]\_\[instrument\_symbol]\_\[date].csv.gz
  * Files are generated on a daily basis.
  * example: bf\_btcusdt\_2022-09-01.csv
* Cut-off time: `00:00:00 UTC`
  * We use the timestamp when exchanges send the order book data points through websocket in order to cut-off the data points between days, if the timestamps are provided by the exchanges.&#x20;
  * When the timestamps are not provided by the exchanges, we use the data collection timestamp when the data points arrive at Kaiko's collection system (see below for these exchanges).
* Column Delimeter: ; (semi-colon)
* Decimal Mark (in numbers): . (dot)

{% hint style="info" %}
**The exchanges do not provide a timestamp:**

1. Bitfinex (`bfnx`)
2. Bitflyer (`bfly`)
3. CEX.io (`cexi`)
   {% endhint %}

| Column      | Description                                                                                                     | Example                                    |
| ----------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| `timestamp` | Timestamp when the exchanges send the data or we collect the data, depending on exchanges. In the epoch format. | `1661990400274591751`                      |
| `type`      | Type of the message. s: snapshot. u: update.                                                                    | `s`                                        |
| `asks`      | List of `[ask price, volume]`                                                                                   | `[[20103,0],[20207,0],[20057,1.00111351]]` |
| `bids`      | List of `[bid price, volume]`                                                                                   | `[[19584,0],[19904,21.9973]]`              |

### How to create a local order book with CSV files <a href="#how-to-create-a-local-order-book-with-csv-files" id="how-to-create-a-local-order-book-with-csv-files"></a>

1. Download the CSV files, which usually start with updates (`type`: `u`).
2. Ignore the updates before the 1st snapshot (`type`: `s`) that appears in the CSV file.
3. If the prices in the updates exist in the locally managed order book, update the amount. The amount 0 means to remove the price level from the order book, because it is cancelled or filled.
4. If the prices in the updates do not exist in the locally managed order book, insert that price level in the order book.
5. Receiving an update that removes a price level that is not in your local order book is a normal exchange's behavior that can happen. In this case, you can just ignore the updates.

{% hint style="warning" %}
Please dump the locally managed order book if you encounter a snapshot between updates while maintaining the orderbook, and start fresh with the new snapshot.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kaiko.com/cloud-delivery/data-feeds/level-2-tick-level/bids-and-asks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
