> ## Documentation Index
> Fetch the complete documentation index at: https://scalarfield.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Crypto OHLCV

> Daily and intraday OHLCV bars for cryptocurrencies aggregated from qualifying trades across major exchanges. Uses X: ticker prefix (e.g., X:BTCUSD, X:ETHUSD). All timestamps in New York time.

<Info>**Python function:** `getOHLCV()`</Info>

| Specification      | Value                                                                               |
| ------------------ | ----------------------------------------------------------------------------------- |
| Delivery Frequency | continuous                                                                          |
| Data Frequency     | daily, intraday (min/hour)                                                          |
| Reporting Lag      | Real-time                                                                           |
| Coverage           | Major cryptocurrency pairs (BTC, ETH, SOL, DOGE, XRP, and more vs USD/BTC/ETH/USDT) |
| History            | Since 2003-01-02                                                                    |
| Availability       | Free                                                                                |

# Product Overview

## Overview

Crypto OHLCV provides standardized Open, High, Low, Close, and Volume price bars for cryptocurrencies. Tickers use the `X:` prefix convention (e.g., `X:BTCUSD` for Bitcoin/USD, `X:ETHUSD` for Ethereum/USD). The legacy hyphenated format (e.g., `BTC-USD`) is also accepted.

Crypto OHLCV bars are constructed by aggregating qualifying trades from multiple cryptocurrency exchanges. Each trade carries eligibility flags ("sale conditions") that determine which OHLCV components it updates, following a methodology analogous to Securities Information Processor (SIP) consolidated processing in equity markets. All timestamps returned by scalarLib are in New York time.

## Data Pipeline

### Trade Aggregation

Crypto OHLCV bars are built from tick-level trade data collected across major cryptocurrency exchanges:

* **Multi-exchange sourcing:** Trades are ingested from qualifying centralized exchanges, providing broad market coverage and reducing the impact of single-venue anomalies.
* **Trade eligibility:** Each trade record includes price, size, exchange identification, trade conditions, and a precise timestamp. Sale condition flags determine which trades update specific OHLCV components — for example, a trade may update volume but not the high/low if it carries certain condition codes.
* **Bar construction:** Qualifying trades within each time window are aggregated into a single OHLCV bar with open (first qualifying trade), high (max), low (min), close (last qualifying trade), volume (sum of qualifying trade sizes), and a volume-weighted average price (VWAP).
* **No phantom bars:** If no qualifying trades occur within a time window, no bar is emitted. This transparently indicates periods without trading activity.

### Real-Time Delivery

* **REST API:** Historical aggregated bars over custom date ranges and time intervals.
* **WebSocket:** Minute-by-minute aggregated bars streamed in real-time. If no trades occur in a given minute, no bar is emitted.

## Coverage

* **Pairs:** Major cryptocurrency pairs including BTC, ETH, SOL, DOGE, XRP, ADA, AVAX, MATIC, LINK, DOT, and many more — all quoted against USD, BTC, ETH, or USDT.
* **Daily history:** Extensive historical data varying by pair.
* **Intraday:** Minute and hourly bars available.
* **Timestamp convention:** All timestamps returned by scalarLib are in New York time (the upstream exchange data is collected in UTC but converted to New York time before delivery).

## Supported Modes

| Mode                | Trigger                                  | Notes                                                           |
| ------------------- | ---------------------------------------- | --------------------------------------------------------------- |
| Daily historical    | `start`/`end` as `'YYYY-MM-DD'`          | Timeframe defaults to `'day'`.                                  |
| Intraday historical | `start`/`end` as `'YYYY-MM-DDTHH:MM:SS'` | Timeframe defaults to `'min'`; can set `'hour'`. New York time. |

## Ticker Convention

Crypto tickers use the `X:` prefix with the pair in `BASEQUOTE` format.

| Ticker      | Pair                 |
| ----------- | -------------------- |
| `X:BTCUSD`  | Bitcoin / US Dollar  |
| `X:ETHUSD`  | Ethereum / US Dollar |
| `X:SOLUSD`  | Solana / US Dollar   |
| `X:DOGEUSD` | Dogecoin / US Dollar |
| `X:XRPUSD`  | XRP / US Dollar      |
| `X:BTCETH`  | Bitcoin / Ethereum   |

# Querying the Data

## Basic Usage

```python theme={null}
from scalarlib import getOHLCV

# Daily Bitcoin bars
data = getOHLCV(tickers=['X:BTCUSD'], start='2025-01-01', end='2025-12-31')
btc_df = data['X:BTCUSD']

# Multiple crypto pairs
data = getOHLCV(tickers=['X:BTCUSD', 'X:ETHUSD', 'X:SOLUSD'], start='2025-06-01', end='2025-06-30')

# Intraday minute bars
data = getOHLCV(tickers=['X:BTCUSD'], start='2026-03-24T09:00:00', end='2026-03-24T17:00:00')

# Hourly bars
data = getOHLCV(tickers=['X:ETHUSD'], start='2026-03-20', end='2026-03-24', timeframe='hour')
```

## Parameters

| Parameter   | Type        | Required | Description                                                         |
| ----------- | ----------- | -------- | ------------------------------------------------------------------- |
| `tickers`   | list of str | Yes      | Crypto tickers with `X:` prefix (e.g., `['X:BTCUSD', 'X:ETHUSD']`). |
| `start`     | str         | Yes      | Start date (`'YYYY-MM-DD'`) or datetime (`'YYYY-MM-DDTHH:MM:SS'`).  |
| `end`       | str         | Yes      | End date or datetime (same format as `start`).                      |
| `timeframe` | str         | No       | `'day'`, `'min'`, or `'hour'`. Default: inferred from date format.  |

# Column Definitions

## OHLCV Schema

| Column    | Type            | Description                                                   |
| --------- | --------------- | ------------------------------------------------------------- |
| `ts_recv` | datetime64\[ns] | Bar timestamp (New York time).                                |
| `ticker`  | string          | Crypto ticker (e.g., `X:BTCUSD`).                             |
| `open`    | float64         | Opening price of the bar (first qualifying trade).            |
| `high`    | float64         | Highest price during the bar.                                 |
| `low`     | float64         | Lowest price during the bar.                                  |
| `close`   | float64         | Closing price of the bar (last qualifying trade).             |
| `volume`  | float64         | Total trading volume during the bar (in base currency units). |
