> For the complete documentation index, see [llms.txt](https://docs.kaiko.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kaiko.com/cloud-delivery/cefi-spot-market-data/bids-and-asks.md).

# Bids and asks

{% hint style="info" %}

### This data is included in the following Kaiko packages:

* Level 1 & Level 2 Data \[Level 2 Tick-Level Tier]

*CeFi spot ticker packs.*
{% endhint %}

## What is this dataset?

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 gRPC streaming in order to cut-off the data points between days, if the timestamps are provided by the exchanges.
  * 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 Delimiter: ; (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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kaiko.com/cloud-delivery/cefi-spot-market-data/bids-and-asks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
