---
title: "Crypto"
description: "Learn how to request and handle crypto in the research environment in QuantConnect"
canonical: https://www.quantconnect.com/docs/v2/research-environment/datasets/crypto
markdown: https://www.quantconnect.com/docs/v2/research-environment/datasets/crypto.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/04%20Research%20Environment/03%20Datasets/10%20Crypto
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Crypto

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Research Environment](https://www.quantconnect.com/docs/v2/research-environment.md) > Datasets > Crypto

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## Introduction

This page explains how to request, manipulate, and visualize historical Crypto data.

## Create Subscriptions

Follow these steps to subscribe to a Crypto security:

1. Create a `QuantBook`.
   ```python
   qb = QuantBook()
   ```
2. (Optional) [Set the time zone](https://www.quantconnect.com/docs/v2/research-environment/initialization.md#04-Set-Time-Zone) to the [exchange time zone](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/time-zones.md#03-Exchange-Time-Zone).
   ```python
   qb.set_time_zone(TimeZones.UTC)
   ```
3. Call the `add_crypto` method with a ticker and then save a reference to the Crypto `Symbol`.
   ```python
   btcusd = qb.add_crypto("BTCUSD").symbol
   ethusd = qb.add_crypto("ETHUSD").symbol
   ```

To view the supported assets in the Crypto datasets, see the **Supported Assets** section of the [QuantConnect dataset listings](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect.md).

## Get Historical Data

You need a [subscription](https://www.quantconnect.com/docs/v2/research-environment/datasets/crypto.md#03-Create-Subscriptions) before you can request historical data for a security. On the time dimension, you can request an amount of historical data based on a trailing number of bars, a trailing period of time, or a defined period of time. On the security dimension, you can request historical data for a single Cryptocurrency, a subset of the Cryptocurrencies you created subscriptions for in your notebook, or all of the Cryptocurrencies in your notebook.

### Trailing Number of Bars

To get historical data for a number of trailing bars, call the `history` method with the `Symbol` object(s) and an integer.

```python
# DataFrame of trade and quote data
single_history_df = qb.history(btcusd, 10)
subset_history_df = qb.history([btcusd, ethusd], 10)
all_history_df = qb.history(qb.securities.keys(), 10)

# DataFrame of trade data
single_history_trade_bar_df = qb.history(TradeBar, btcusd, 10)
subset_history_trade_bar_df = qb.history(TradeBar, [btcusd, ethusd], 10)
all_history_trade_bar_df = qb.history(TradeBar, qb.securities.keys(), 10)

# DataFrame of quote data
single_history_quote_bar_df = qb.history(QuoteBar, btcusd, 10)
subset_history_quote_bar_df = qb.history(QuoteBar, [btcusd, ethusd], 10)
all_history_quote_bar_df = qb.history(QuoteBar, qb.securities.keys(), 10)

# Slice objects
all_history_slice = qb.history(10)

# TradeBar objects
single_history_trade_bars = qb.history[TradeBar](btcusd, 10)
subset_history_trade_bars = qb.history[TradeBar]([btcusd, ethusd], 10)
all_history_trade_bars = qb.history[TradeBar](qb.securities.keys(), 10)

# QuoteBar objects
single_history_quote_bars = qb.history[QuoteBar](btcusd, 10)
subset_history_quote_bars = qb.history[QuoteBar]([btcusd, ethusd], 10)
all_history_quote_bars = qb.history[QuoteBar](qb.securities.keys(), 10)
```

### Trailing Period of Time

To get historical data for a trailing period of time, call the `history` method with the `Symbol` object(s) and a `timedelta`.

```python
# DataFrame of trade and quote data
single_history_df = qb.history(btcusd, timedelta(days=3))
subset_history_df = qb.history([btcusd, ethusd], timedelta(days=3))
all_history_df = qb.history(qb.securities.keys(), timedelta(days=3))

# DataFrame of trade data
single_history_trade_bar_df = qb.history(TradeBar, btcusd, timedelta(days=3))
subset_history_trade_bar_df = qb.history(TradeBar, [btcusd, ethusd], timedelta(days=3))
all_history_trade_bar_df = qb.history(TradeBar, qb.securities.keys(), timedelta(days=3))

# DataFrame of quote data
single_history_quote_bar_df = qb.history(QuoteBar, btcusd, timedelta(days=3))
subset_history_quote_bar_df = qb.history(QuoteBar, [btcusd, ethusd], timedelta(days=3))
all_history_quote_bar_df = qb.history(QuoteBar, qb.securities.keys(), timedelta(days=3))

# DataFrame of tick data
single_history_tick_df = qb.history(btcusd, timedelta(days=3), Resolution.TICK)
subset_history_tick_df = qb.history([btcusd, ethusd], timedelta(days=3), Resolution.TICK)
all_history_tick_df = qb.history(qb.securities.keys(), timedelta(days=3), Resolution.TICK)

# Slice objects
all_history_slice = qb.history(timedelta(days=3))

# TradeBar objects
single_history_trade_bars = qb.history[TradeBar](btcusd, timedelta(days=3))
subset_history_trade_bars = qb.history[TradeBar]([btcusd, ethusd], timedelta(days=3))
all_history_trade_bars = qb.history[TradeBar](qb.securities.keys(), timedelta(days=3))

# QuoteBar objects
single_history_quote_bars = qb.history[QuoteBar](btcusd, timedelta(days=3), Resolution.MINUTE)
subset_history_quote_bars = qb.history[QuoteBar]([btcusd, ethusd], timedelta(days=3), Resolution.MINUTE)
all_history_quote_bars = qb.history[QuoteBar](qb.securities.keys(), timedelta(days=3), Resolution.MINUTE)

# Tick objects
single_history_ticks = qb.history[Tick](btcusd, timedelta(days=3), Resolution.TICK)
subset_history_ticks = qb.history[Tick]([btcusd, ethusd], timedelta(days=3), Resolution.TICK)
all_history_ticks = qb.history[Tick](qb.securities.keys(), timedelta(days=3), Resolution.TICK)
```

### Defined Period of Time

To get historical data for a specific period of time, call the `history` method with the `Symbol` object(s), a start `datetime`, and an end `datetime`. The start and end times you provide are based in the [notebook time zone](https://www.quantconnect.com/docs/v2/research-environment/initialization.md#04-Set-Time-Zone).

```python
start_time = datetime(2021, 1, 1)
end_time = datetime(2021, 2, 1)

# DataFrame of trade and quote data
single_history_df = qb.history(btcusd, start_time, end_time)
subset_history_df = qb.history([btcusd, ethusd], start_time, end_time)
all_history_df = qb.history(qb.securities.keys(), start_time, end_time)

# DataFrame of trade data
single_history_trade_bar_df = qb.history(TradeBar, btcusd, start_time, end_time)
subset_history_trade_bar_df = qb.history(TradeBar, [btcusd, ethusd], start_time, end_time)
all_history_trade_bar_df = qb.history(TradeBar, qb.securities.keys(), start_time, end_time)

# DataFrame of quote data
single_history_quote_bar_df = qb.history(QuoteBar, btcusd, start_time, end_time)
subset_history_quote_bar_df = qb.history(QuoteBar, [btcusd, ethusd], start_time, end_time)
all_history_quote_bar_df = qb.history(QuoteBar, qb.securities.keys(), start_time, end_time)

# DataFrame of tick data
single_history_tick_df = qb.history(btcusd, start_time, end_time, Resolution.TICK)
subset_history_tick_df = qb.history([btcusd, ethusd], start_time, end_time, Resolution.TICK)
all_history_tick_df = qb.history(qb.securities.keys(), start_time, end_time, Resolution.TICK)

# TradeBar objects
single_history_trade_bars = qb.history[TradeBar](btcusd, start_time, end_time)
subset_history_trade_bars = qb.history[TradeBar]([btcusd, ethusd], start_time, end_time)
all_history_trade_bars = qb.history[TradeBar](qb.securities.keys(), start_time, end_time)

# QuoteBar objects
single_history_quote_bars = qb.history[QuoteBar](btcusd, start_time, end_time, Resolution.MINUTE)
subset_history_quote_bars = qb.history[QuoteBar]([btcusd, ethusd], start_time, end_time, Resolution.MINUTE)
all_history_quote_bars = qb.history[QuoteBar](qb.securities.keys(), start_time, end_time, Resolution.MINUTE)

# Tick objects
single_history_ticks = qb.history[Tick](btcusd, start_time, end_time, Resolution.TICK)
subset_history_ticks = qb.history[Tick]([btcusd, ethusd], start_time, end_time, Resolution.TICK)
all_history_ticks = qb.history[Tick](qb.securities.keys(), start_time, end_time, Resolution.TICK)
```

## Resolutions

The following table shows the available resolutions and data formats for Crypto subscriptions:

| Resolution | TradeBar | QuoteBar | Trade Tick | Quote Tick |
| --- | --- | --- | --- | --- |
| `TICK` | Not supported | Not supported | Supported✓ | Supported✓ |
| `SECOND` | Supported✓ | Supported✓ | Not supported | Not supported |
| `MINUTE` | Supported✓ | Supported✓ | Not supported | Not supported |
| `HOUR` | Supported✓ | Supported✓ | Not supported | Not supported |
| `DAILY` | Supported✓ | Supported✓ | Not supported | Not supported |

## Markets

The following `Market` enumeration members are available for Crypto:

*Members of `QuantConnect.Market` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.Market&language=python*

Fields: `BINANCE`, `Binance`, `BINANCE_US`, `BinanceUS`, `BITFINEX`, `Bitfinex`, `BYBIT`, `Bybit`, `COINBASE`, `Coinbase`, `KRAKEN`, `Kraken`

## Data Normalization

The data normalization mode doesn't affect data from history request. If you change the data normalization mode, it won't change the outcome.

## Wrangle Data

You need some [historical data](https://www.quantconnect.com/docs/v2/research-environment/datasets/crypto.md#04-Get-Historical-Data) to perform wrangling operations. The process to manipulate the historical data depends on its data type. To display `pandas` objects, run a cell in a notebook with the `pandas` object as the last line. To display other data formats, call the `print` method.

### DataFrame Objects

If the `history` method returns a `DataFrame`, the first level of the `DataFrame` index is the [encoded Crypto Symbol](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/security-identifiers.md#02-Encoding-Symbols) and the second level is the `end_time` of the data sample. The columns of the `DataFrame` are the data properties.

| symbol | time | askclose | askhigh | asklow | askopen | asksize | bidclose | bidhigh | bidlow | bidopen | bidsize | close | high | low | open | volume |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| ETHUSD XJ | 2021-01-01 05:01:00 | 744.17 | 744.27 | 743.41 | 743.58 | 0.250185 | 743.94 | 744.11 | 743.28 | 743.47 | 1.800000 | 744.18 | 744.24 | 743.40 | 743.58 | 133.964910 |
| ETHUSD XJ | 2021-01-01 05:02:00 | 743.81 | 744.55 | 743.81 | 744.17 | 0.888586 | 743.80 | 744.25 | 743.77 | 743.94 | 0.267552 | 743.80 | 744.51 | 743.80 | 744.17 | 111.379343 |
| ETHUSD XJ | 2021-01-01 05:03:00 | 743.02 | 744.02 | 743.02 | 743.81 | 24.000000 | 743.01 | 743.82 | 743.01 | 743.80 | 0.200230 | 743.02 | 743.82 | 743.01 | 743.81 | 108.750352 |
| ETHUSD XJ | 2021-01-01 05:04:00 | 741.66 | 743.02 | 741.66 | 743.02 | 1.800000 | 741.50 | 743.01 | 741.50 | 743.01 | 0.157696 | 741.50 | 743.01 | 741.50 | 743.01 | 280.399706 |
| ETHUSD XJ | 2021-01-01 05:05:00 | 742.71 | 743.02 | 741.62 | 741.66 | 2.510539 | 742.46 | 743.01 | 741.50 | 741.50 | 2.000000 | 742.69 | 743.02 | 741.62 | 741.63 | 120.165379 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| BTCUSD XJ | 2021-02-01 04:56:00 | 33626.70 | 33667.29 | 33593.23 | 33612.77 | 1.900000 | 33626.69 | 33660.54 | 33588.24 | 33606.35 | 0.020804 | 33626.70 | 33664.27 | 33589.22 | 33612.42 | 11.218419 |
| BTCUSD XJ | 2021-02-01 04:57:00 | 33569.52 | 33626.70 | 33559.43 | 33626.70 | 0.012492 | 33565.49 | 33626.69 | 33558.72 | 33626.69 | 0.100000 | 33569.52 | 33626.70 | 33559.44 | 33626.70 | 1.547286 |
| BTCUSD XJ | 2021-02-01 04:58:00 | 33578.82 | 33602.37 | 33564.16 | 33569.52 | 1.580643 | 33578.81 | 33593.02 | 33563.81 | 33565.49 | 0.115128 | 33578.82 | 33602.37 | 33565.47 | 33569.52 | 4.658471 |
| BTCUSD XJ | 2021-02-01 04:59:00 | 33569.08 | 33650.37 | 33564.22 | 33578.82 | 0.500000 | 33564.82 | 33641.04 | 33563.81 | 33578.81 | 0.043120 | 33568.86 | 33650.37 | 33563.82 | 33578.82 | 7.315090 |
| BTCUSD XJ | 2021-02-01 05:00:00 | 33581.76 | 33602.80 | 33563.91 | 33569.08 | 0.013800 | 33579.89 | 33597.63 | 33563.81 | 33564.82 | 0.050000 | 33581.76 | 33600.07 | 33563.90 | 33565.84 | 7.636029 |

To select the historical data of a single Crypto, index the `loc` property of the `DataFrame` with the Crypto `Symbol`.

```python
all_history_df.loc[btcusd]  # or all_history_df.loc['BTCUSD']
```

| time | askclose | askhigh | asklow | askopen | asksize | bidclose | bidhigh | bidlow | bidopen | bidsize | close | high | low | open | volume |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 2021-01-01 05:01:00 | 29409.07 | 29409.07 | 29367.25 | 29388.93 | 0.371000 | 29400.00 | 29400.05 | 29365.25 | 29388.00 | 0.024050 | 29409.07 | 29409.07 | 29367.25 | 29388.93 | 14.852419 |
| 2021-01-01 05:02:00 | 29408.07 | 29420.00 | 29370.49 | 29409.07 | 0.012560 | 29400.00 | 29420.00 | 29369.00 | 29400.00 | 0.510000 | 29408.00 | 29420.00 | 29370.00 | 29409.07 | 11.396783 |
| 2021-01-01 05:03:00 | 29370.00 | 29412.00 | 29345.43 | 29408.07 | 0.100000 | 29360.00 | 29403.00 | 29340.00 | 29400.00 | 0.880000 | 29365.00 | 29412.00 | 29345.00 | 29408.07 | 18.285416 |
| 2021-01-01 05:04:00 | 29350.51 | 29380.00 | 29325.00 | 29370.00 | 0.500000 | 29340.01 | 29370.00 | 29321.00 | 29360.00 | 0.150000 | 29345.26 | 29375.00 | 29323.00 | 29365.00 | 22.106951 |
| 2021-01-01 05:05:00 | 29390.00 | 29395.00 | 29345.00 | 29350.51 | 1.200000 | 29380.00 | 29385.00 | 29335.00 | 29340.01 | 0.300000 | 29385.00 | 29395.00 | 29340.00 | 29345.26 | 15.473208 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 2021-02-01 04:56:00 | 33626.70 | 33667.29 | 33593.23 | 33612.77 | 1.900000 | 33626.69 | 33660.54 | 33588.24 | 33606.35 | 0.020804 | 33626.70 | 33664.27 | 33589.22 | 33612.42 | 11.218419 |
| 2021-02-01 04:57:00 | 33569.52 | 33626.70 | 33559.43 | 33626.70 | 0.012492 | 33565.49 | 33626.69 | 33558.72 | 33626.69 | 0.100000 | 33569.52 | 33626.70 | 33559.44 | 33626.70 | 1.547286 |
| 2021-02-01 04:58:00 | 33578.82 | 33602.37 | 33564.16 | 33569.52 | 1.580643 | 33578.81 | 33593.02 | 33563.81 | 33565.49 | 0.115128 | 33578.82 | 33602.37 | 33565.47 | 33569.52 | 4.658471 |
| 2021-02-01 04:59:00 | 33569.08 | 33650.37 | 33564.22 | 33578.82 | 0.500000 | 33564.82 | 33641.04 | 33563.81 | 33578.81 | 0.043120 | 33568.86 | 33650.37 | 33563.82 | 33578.82 | 7.315090 |
| 2021-02-01 05:00:00 | 33581.76 | 33602.80 | 33563.91 | 33569.08 | 0.013800 | 33579.89 | 33597.63 | 33563.81 | 33564.82 | 0.050000 | 33581.76 | 33600.07 | 33563.90 | 33565.84 | 7.636029 |

To select a column of the `DataFrame`, index it with the column name.

```python
all_history_df.loc[btcusd]['close']
```

```python
time
2021-01-01 05:01:00    29409.07
2021-01-01 05:02:00    29408.00
2021-01-01 05:03:00    29365.00
2021-01-01 05:04:00    29345.26
2021-01-01 05:05:00    29385.00
                         ...
2021-02-01 04:56:00    33626.70
2021-02-01 04:57:00    33569.52
2021-02-01 04:58:00    33578.82
2021-02-01 04:59:00    33568.86
2021-02-01 05:00:00    33581.76
Name: close, dtype: float64
```

If you request historical data for multiple Crypto pairs, you can transform the `DataFrame` so that it's a time series of close values for all of the Crypto pairs. To transform the `DataFrame`, select the column you want to display for each Crypto pair and then call the [unstack](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.unstack.html) method.

```python
all_history_df['close'].unstack(level=0)
```

The `DataFrame` is transformed so that the column indices are the `Symbol` of each Crypto pair and each row contains the close value.

| symbol time | BTCUSD XJ | ETHUSD XJ |
| --- | --- | --- |
| 2021-01-01 05:01:00 | 29409.07 | 744.18 |
| 2021-01-01 05:02:00 | 29408.00 | 743.80 |
| 2021-01-01 05:03:00 | 29365.00 | 743.02 |
| 2021-01-01 05:04:00 | 29345.26 | 741.50 |
| 2021-01-01 05:05:00 | 29385.00 | 742.69 |
| ... | ... | ... |
| 2021-02-01 04:56:00 | 33626.70 | 1371.55 |
| 2021-02-01 04:57:00 | 33569.52 | 1370.82 |
| 2021-02-01 04:58:00 | 33578.82 | 1371.20 |
| 2021-02-01 04:59:00 | 33568.86 | 1370.95 |
| 2021-02-01 05:00:00 | 33581.76 | 1371.40 |

### Slice Objects

If the `history` method returns `Slice` objects, iterate through the `Slice` objects to get each one. The `Slice` objects may not have data for all of your Crypto subscriptions. To avoid issues, check if the `Slice` contains data for your Crypto pair before you index it with the Crypto `Symbol`.

```python
for slice in all_history_slice:
        if slice.bars.contains_key(btcusd):
        trade_bar = slice.bars[btcusd]
    if slice.quote_bars.contains_key(btcusd):
        quote_bar = slice.quote_bars[btcusd]
```

You can also iterate through each `TradeBar` and `QuoteBar` in the `Slice`.

```python
for slice in all_history_slice:
    for kvp in slice.bars:
        symbol = kvp.key
        trade_bar = kvp.value
    for kvp in slice.quote_bars:
        symbol = kvp.key
        quote_bar = kvp.value
```

### TradeBar Objects

If the `history` method returns `TradeBar` objects, iterate through the `TradeBar` objects to get each one.

```python
for trade_bar in single_history_trade_bars:
    print(trade_bar)
```

If the `history` method returns `TradeBars`, iterate through the `TradeBars` to get the `TradeBar` of each Crypto pair. The `TradeBars` may not have data for all of your Crypto subscriptions. To avoid issues, check if the `TradeBars` object contains data for your security before you index it with the Crypto `Symbol`.

```python
for trade_bars in all_history_trade_bars:
    if trade_bars.contains_key(btcusd):
        trade_bar = trade_bars[btcusd]
```

You can also iterate through each of the `TradeBars`.

```python
for trade_bars in all_history_trade_bars:
    for kvp in trade_bars:
        symbol = kvp.key
        trade_bar = kvp.value
```

### QuoteBar Objects

If the `history` method returns `QuoteBar` objects, iterate through the `QuoteBar` objects to get each one.

```python
for quote_bar in single_history_quote_bars:
    print(quote_bar)
```

If the `history` method returns `QuoteBars`, iterate through the `QuoteBars` to get the `QuoteBar` of each Crypto pair. The `QuoteBars` may not have data for all of your Crypto subscriptions. To avoid issues, check if the `QuoteBars` object contains data for your security before you index it with the Crypto `Symbol`.

```python
for quote_bars in all_history_quote_bars:
    if quote_bars.contains_key(btcusd):
        quote_bar = quote_bars[btcusd]
```

You can also iterate through each of the `QuoteBars`.

```python
for quote_bars in all_history_quote_bars:
    for kvp in quote_bars:
        symbol = kvp.key
        quote_bar = kvp.value
```

### Tick Objects

If the `history` method returns `TICK` objects, iterate through the `TICK` objects to get each one.

```python
for tick in single_history_ticks:
    print(tick)
```

If the `history` method returns `Ticks`, iterate through the `Ticks` to get the `TICK` of each Crypto pair. The `Ticks` may not have data for all of your Crypto subscriptions. To avoid issues, check if the `Ticks` object contains data for your security before you index it with the Crypto `Symbol`.

```python
for ticks in all_history_ticks:
    if ticks.contains_key(btcusd):
        ticks = ticks[btcusd]
```

You can also iterate through each of the `Ticks`.

```python
for ticks in all_history_ticks:
    for kvp in ticks:
        symbol = kvp.key
        tick = kvp.value
```

The `Ticks` objects only contain the last tick of each security for that particular [timeslice](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md)

## Plot Data

You need some [historical Crypto data](https://www.quantconnect.com/docs/v2/research-environment/datasets/crypto.md#04-Get-Historical-Data) to produce plots. You can use many of the [supported plotting libraries](https://www.quantconnect.com/docs/v2/research-environment/charting.md) to visualize data in various formats. For example, you can plot candlestick and line charts.

### Candlestick Chart

Follow these steps to plot candlestick charts:

1. Get some [historical data](https://www.quantconnect.com/docs/v2/research-environment/datasets/crypto.md#04-Get-Historical-Data).
   ```python
   history = qb.history(btcusd, datetime(2020, 12, 27), datetime(2021, 12, 21), Resolution.DAILY).loc[btcusd]
   ```
2. Import the `plotly` library.
   ```python
   import plotly.graph_objects as go
   ```
3. Create a `Candlestick`.
   ```python
   candlestick = go.Candlestick(x=history.index,
                                open=history['open'],
                                high=history['high'],
                                low=history['low'],
                                close=history['close'])
   ```
4. Create a `Layout`.
   ```python
   layout = go.Layout(title=go.layout.Title(text='BTCUSD OHLC'),
                      xaxis_title='Date',
                      yaxis_title='Price',
                      xaxis_rangeslider_visible=False)
   ```
5. Create the `Figure`.
   ```python
   fig = go.Figure(data=[candlestick], layout=layout)
   ```
6. Show the `Figure`.
   ```python
   fig.show()
   ```
   Candlestick charts display the open, high, low, and close prices of the security.

![Candlestick plot of BTCUSD OHLC](https://cdn.quantconnect.com/i/tu/research-history-crypto-candlestickplot.png)

### Line Chart

Follow these steps to plot line charts using built-in methods:

1. Get some historical data.
   ```python
   history = qb.history([btcusd, ethusd], datetime(2020, 12, 27), datetime(2021, 12, 21), Resolution.DAILY)
   ```
2. Select the data to plot.
   ```python
   volume = history['volume'].unstack(level=0)
   ```
3. Call the `plot` method on the `pandas` object.
   ```python
   volume.plot(title="Volume", figsize=(15, 10))
   ```
4. Show the plot.
   ```python
   plt.show()
   ```
   Line charts display the value of the property you selected in a time series.

![Line chart of volume of BTCUSD, & ETHUSD](https://cdn.quantconnect.com/i/tu/research-env-crypto-volume-plot.jpg)

## Examples

The following examples demonstrate some common practices for applying the Crypto dataset.

### Example 1: 5-Minute Candlestick Plot

The following example studies the candlestick pattern of the BTCUSD. To study the short term pattern, we consolidate the data into 5 minute bars and plot the 5-minute candlestick plot.

```python
# Import plotly library for plotting.
import plotly.graph_objects as go

# Create a QuantBook
qb = QuantBook()

# Request SPY's historical data.
symbol = qb.add_crypto("BTCUSD", market=Market.COINBASE).symbol
history = qb.history(symbol,
    start=qb.time - timedelta(days=182),
    end=qb.time,
    resolution=Resolution.MINUTE)

# Drop level 0 index (Symbol index) from the DataFrame
history = history.droplevel([0])

# Select the required columns to obtain the 5-minute OHLC data.
history = history[["open", "high", "low", "close"]].resample("5T").agg({
    "open": "first",
    "high": "max",
    "low": "min",
    "close": "last"
})

# Crete the Candlestick chart using the 5-minute windows.
candlestick = go.Candlestick(x=history.index,
                             open=history['open'],
                             high=history['high'],
                             low=history['low'],
                             close=history['close'])
# Create a Layout as the plot settings.
layout = go.Layout(title=go.layout.Title(text=f'{symbol} OHLC'),
                   xaxis_title='Date',
                   yaxis_title='Price',
                   xaxis_rangeslider_visible=False)
# Create the Figure.
fig = go.Figure(data=[candlestick], layout=layout)
# Display the plot.
fig.show()
```
