---
title: "Binance Crypto Future Price Data"
description: "Binance Crypto Future Price Data dataset from QuantConnect."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/binance-crypto-future-price-data
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect/binance-crypto-future-price-data.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/02%20QuantConnect/02%20Binance%20Crypto%20Future%20Price%20Data
modified: 2026-10-31
index: https://www.quantconnect.com/llms.txt
---

# Binance Crypto Future Price Data

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [QuantConnect](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quantconnect.md) > Binance Crypto Future Price Data

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

## Introduction

The Binance Crypto Future Price Data is for Crypto-currency futures price and volume data points. The data covers 806 Cryptocurrency pairs, starts in August 2020, and is delivered on any frequency from tick to daily. This dataset is created by monitoring the trading activity on Binance.

The [Binance Crypto Future Margin Rate Data](https://www.quantconnect.com/datasets/binance-cryptofuture-margin-rate-data) dataset provides margin interest data to model margin costs.

For more information about the Binance Crypto Future Price Data dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/binance-cryptofuture-price-data).

## About the Provider

Binance was founded by Changpeng Zhao in 2017 with the goal to "increase the freedom of money globally". Binance provides access to trading Crypto through spot markets and perpetual Futures. They serve clients with no minimum deposit when depositing Crypto. Binance also provides an NFT marketplace, a mining pool, and services to deposit Crypto coins in liquidity pools to earn rewards.

## Getting Started

The following snippet demonstrates how to request data from the Binance Crypto Future Price dataset:

```python
def initialize(self) -> None:
    self.set_brokerage_model(BrokerageName.BINANCE_FUTURES, AccountType.MARGIN)
    #self.set_brokerage_model(BrokerageName.BINANCE_COIN_FUTURES, AccountType.MARGIN)

    self.crypto_future_symbol = self.add_crypto_future("BTCBUSD", Resolution.MINUTE).symbol
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | August 2020 |
| Asset Coverage | 806 Crypto Futures Pairs |
| Data Density | Dense |
| Resolution | Tick, Second, Minute, Hourly, & Daily |
| Timezone | UTC |
| Market Hours | [Always Open](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/market-hours.md) |

## Requesting Data

To add Binance Crypto Future Price data to your algorithm, call the `add_crypto_future` method. Save a reference to the Crypto Future `Symbol` so you can access the data later in your algorithm.

```python
class CoinAPIDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2020, 6, 1)
        self.set_end_date(2021, 6, 1)

        # Set Account Currency to Binance Stable Coin for USD
        self.set_account_currency("BUSD")
        self.set_cash(100000)

        self.set_brokerage_model(BrokerageName.BINANCE_FUTURES, AccountType.MARGIN)
        self.set_brokerage_model(BrokerageName.BINANCE_COIN_FUTURES, AccountType.MARGIN)

        crypto_future = self.add_crypto_future("BTCBUSD", Resolution.MINUTE)
        # perpetual futures does not have a filter function
        self.btcbusd = crypto_future.symbol
```

For more information about creating Crypto Future subscriptions, see [Requesting Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/crypto-futures/requesting-data.md).

## Accessing Data

To get the current Binance Crypto Future Price data, index the `bars`, `quote_bars`, or `ticks` properties of the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) with the Crypto Future `Symbol`. `Slice` objects deliver unique events to your algorithm as they happen, but the `Slice` may not contain data for your security at every time step. To avoid issues, check if the `Slice` contains the data you want before you index it.

```python
def on_data(self, slice: Slice) -> None:
    if self.btcbusd in slice.bars:
        trade_bar = slice.bars[self.btcbusd]
        self.log(f"{self.btcbusd} close at {slice.time}: {trade_bar.close}")

    if self.btcbusd in slice.quote_bars:
        quote_bar = slice.quote_bars[self.btcbusd]
        self.log(f"{self.btcbusd} bid at {slice.time}: {quote_bar.bid.close}")

    if self.btcbusd in slice.ticks:
        ticks = slice.ticks[self.btcbusd]
        for tick in ticks:
            self.log(f"{self.btcbusd} price at {slice.time}: {tick.price}")
```

You can also iterate through all of the data objects in the current `Slice`.

```python
def on_data(self, slice: Slice) -> None:
    for symbol, trade_bar in slice.bars.items():
        self.log(f"{symbol} close at {slice.time}: {trade_bar.close}")

    for symbol, quote_bar in slice.quote_bars.items():
        self.log(f"{symbol} bid at {slice.time}: {quote_bar.bid.close}")

    for symbol, ticks in slice.ticks.items():
        for tick in ticks:
            self.log(f"{symbol} price at {slice.time}: {tick.price}")
```

For more information about accessing Crypto Future data, see [Handling Data](https://www.quantconnect.com/docs/v2/writing-algorithms/securities/asset-classes/crypto-futures/handling-data.md).

## Historical Data

To get historical Binance Crypto Future Price data, call the `history` method with the Crypto Future `Symbol`. If there is no data in the period you request, the history result is empty.

```python
# DataFrame
history_df = self.history(self.btcbusd, 100, Resolution.DAILY)

# TradeBar objects
history_trade_bars = self.history[TradeBar](self.btcbusd, 100, Resolution.MINUTE)

# QuoteBar objects
history_quote_bars = self.history[QuoteBar](self.btcbusd, 100, Resolution.MINUTE)

# Tick objects
history_ticks = self.history[Tick](self.btcbusd, timedelta(seconds=10), Resolution.TICK)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Remove Subscriptions

To unsubscribe from a Crypto Future contract that you added with the `add_crypto_future` method, call the `remove_security` method.

```python
self.remove_security(self.btcbusd)
```

The `remove_security` method cancels your open orders for the security and liquidates your Crypto Future holdings.

## Supported Assets

The following table shows the available Crypto Future pairs:

| Pairs Available (806) |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- |
| 0GUSDT | 1000000BOBUSDT | 1000000MOGUSDT | 1000BONKUSDC | 1000BONKUSDT | 1000CATUSDT |
| 1000CHEEMSUSDT | 1000FLOKIUSDT | 1000LUNCBUSD | 1000LUNCUSDT | 1000PEPEUSDC | 1000PEPEUSDT |
| 1000RATSUSDT | 1000SATSUSDT | 1000SHIBBUSD | 1000SHIBUSDC | 1000SHIBUSDT | 1000WHYUSDT |
| 1000XECUSDT | 1000XUSDT | 1INCHUSDT | 1MBABYDOGEUSDT | 2ZUSDT | 42USDT |
| 4USDT | A2ZUSDT | AAVEUSD | AAVEUSDC | AAVEUSDT | ACEUSDT |
| ACHUSDT | ACTUSDT | ACUUSDT | ACXUSDT | ADABUSD | ADAUSD |
| ADAUSDC | ADAUSDT | AERGOUSDT | AEROUSDT | AEVOUSDT | AGIXBUSD |
| AGIXUSDT | AGLDUSDT | AGTUSDT | AI16ZUSDT | AIAUSDT | AIGENSYNUSDT |
| AINUSDT | AIOTUSDT | AIOUSDT | AIUSDT | AIXBTUSDT | AKEUSDT |
| AKTUSDT | ALCHUSDT | ALGOUSD | ALGOUSDT | ALICEUSDT | ALLOUSDT |
| ALLUSDT | ALPACAUSDT | ALPHAUSDT | ALPINEUSDT | ALTUSDT | AMBBUSD |
| AMBUSDT | ANCBUSD | ANIMEUSDT | ANKRUSDT | ANTUSDT | APEBUSD |
| APEUSD | APEUSDT | API3USDT | APRUSDT | APTBUSD | APTUSD |
| APTUSDT | ARBUSDC | ARBUSDT | ARCUSDT | ARIAUSDT | ARKMUSDT |
| ARKUSDT | ARPAUSDT | ARUSDT | ARXUSDT | ASRUSDT | ASTERUSDT |
| ASTRUSDT | ATAUSDT | ATHUSDT | ATOMUSD | ATOMUSDT | ATUSDT |
| AUCTIONBUSD | AUCTIONUSDT | AUDIOUSDT | AUSDT | AVAAIUSDT | AVAUSDT |
| AVAXBUSD | AVAXUSD | AVAXUSDC | AVAXUSDT | AVNTUSDT | AWEUSDT |
| AXLUSDT | AXSUSD | AXSUSDT | AZTECUSDT | B2USDT | B3USDT |
| BABYUSDT | BADGERUSDT | BAKEUSDT | BALUSDT | BANANAS31USDT | BANANAUSDT |
| BANDUSDT | BANKUSDT | BANUSDT | BARDUSDT | BASEDUSDT | BASUSDT |
| BATUSDT | BBUSDT | BCHUSD | BCHUSDC | BCHUSDT | BDXNUSDT |
| BEAMXUSDT | BEATUSDT | BELUSDT | BERAUSDT | BICOUSDT | BIDUSDT |
| BIGTIMEUSDT | BILLUSDT | BIOUSDC | BIOUSDT | BIRBUSDT | BLESSUSDT |
| BLUAIUSDT | BLUEBIRDUSDT | BLURUSDT | BLZUSDT | BMTUSDT | BNBBUSD |
| BNBUSD | BNBUSDC | BNBUSDT | BNTUSDT | BNXUSDT | BOBUSDT |
| BOMEUSDC | BOMEUSDT | BONDUSDT | BRETTUSDT | BREVUSDT | BROCCOLI714USDT |
| BROCCOLIF3BUSDT | BRUSDT | BSBUSDT | BSVUSDT | BSWUSDT | BTCBUSD |
| BTCDOMUSDT | BTCSTUSDT | BTCU | BTCUSD | BTCUSD1 | BTCUSDC |
| BTCUSDT | BTRUSDT | BTSUSDT | BTWUSDT | BULLAUSDT | BUSDT |
| C98USDT | CAKEUSDT | CAPUSDT | CARVUSDT | CATIUSDT | CCUSDT |
| CELOUSDT | CELRUSDT | CETUSUSDT | CFGUSDT | CFXUSDT | CGPTUSDT |
| CHESSUSDT | CHILLGUYUSDT | CHIPUSDT | CHRUSDT | CHZUSD | CHZUSDT |
| CKBUSDT | CLANKERUSDT | CLOUSDT | COAIUSDT | COCOSUSDT | COLLECTUSDT |
| COMBOUSDT | COMMONUSDT | COMPUSDT | COOKIEUSDT | COSUSDT | COTIUSDT |
| COWUSDT | CROSSUSDT | CRVUSDC | CRVUSDT | CTKUSDT | CTRUSDT |
| CTSIUSDT | CUDISUSDT | CUSDT | CVCUSDT | CVXBUSD | CVXUSDT |
| CYBERUSDT | CYSUSDT | DAMUSDT | DARUSDT | DASHUSDT | DATAIPUSDC |
| DATAIPUSDT | DEEPUSDT | DEFIUSDT | DEGENUSDT | DEGOUSDT | DENTUSDT |
| DEXEUSDT | DFUSDT | DGBUSDT | DIAUSDT | DMCUSDT | DODOBUSD |
| DODOXUSDT | DOGEBUSD | DOGEUSD | DOGEUSDC | DOGEUSDT | DOGSUSD |
| DOGSUSDT | DOLOUSDT | DOODUSDT | DOSUSDT | DOTBUSD | DOTUSD |
| DOTUSDT | DRIFTUSDT | DUSDT | DUSKUSDT | DYDXUSDT | DYMUSDT |
| EDENUSDT | EDGEUSDT | EDUUSDT | EGLDUSD | EGLDUSDT | EIGENUSDT |
| ELSAUSDT | ENAUSDC | ENAUSDT | ENJUSDT | ENSOUSDT | ENSUSD |
| ENSUSDT | EOSUSD | EOSUSDT | EPICUSDT | EPTUSDT | ERAUSDT |
| ESPORTSUSDT | ESPUSDT | ETCBUSD | ETCUSD | ETCUSDT | ETHBTC |
| ETHBUSD | ETHFIUSDC | ETHFIUSDT | ETHU | ETHUSD | ETHUSD1 |
| ETHUSDC | ETHUSDT | ETHWUSDT | EULUSDT | EVAAUSDT | FARTCOINUSDT |
| FETUSDT | FFUSDT | FHEUSDT | FIDAUSDT | FIGHTUSDT | FILBUSD |
| FILUSD | FILUSDC | FILUSDT | FIOUSDT | FISUSDT | FLMUSDT |
| FLOCKUSDT | FLOWUSDT | FLUIDUSDT | FLUXUSDT | FOGOUSDT | FOLKSUSDT |
| FOOTBALLUSDT | FORMUSDT | FORTHUSDT | FRAXUSDT | FRONTUSDT | FTMBUSD |
| FTMUSD | FTMUSDT | FTTBUSD | FTTUSDT | FUNUSDT | FUSDT |
| FXSUSDT | GAIBUSDT | GALABUSD | GALAUSD | GALAUSDT | GALBUSD |
| GALUSDT | GASUSDT | GENIUSUSDT | GHSTUSDT | GIGGLEUSDT | GLMRUSDT |
| GLMUSDT | GMTBUSD | GMTUSD | GMTUSDT | GMXUSDT | GOATUSDT |
| GPSUSDT | GRAMUSDT | GRASSUSDT | GRIFFAINUSDT | GRTUSDT | GRVTUSDT |
| GTCUSDT | GUAUSDT | GUNUSDT | GUSDT | GWEIUSDT | HAEDALUSDT |
| HANAUSDT | HBARUSDC | HBARUSDT | HEIUSDT | HEMIUSDT | HFTUSDT |
| HIFIUSDT | HIGHUSDT | HIPPOUSDT | HIVEUSDT | HMSTRUSDT | HNTUSDT |
| HOLOUSDT | HOMEUSDT | HOOKUSDT | HOTUSDT | HUMAUSDT | HUSDT |
| HYPERUSDT | HYPEUSDT | ICNTUSDT | ICPBUSD | ICPUSDT | ICXUSD |
| ICXUSDT | IDEXUSDT | IDOLUSDT | IDUSDT | ILVUSDT | IMXUSDT |
| INITUSDT | INJUSDT | INUSDT | INXUSDT | IOSTUSDT | IOTAUSDT |
| IOTXUSDT | IOUSDT | IPUSDC | IPUSDT | IRUSDT | IRYSUSDT |
| JASMYUSDT | JCTUSDT | JELLYJELLYUSDT | JOEUSDT | JSTUSDT | JTOUSDT |
| JUPUSDT | KAIAUSDT | KAITOUSDC | KAITOUSDT | KASUSDT | KATUSDT |
| KAVAUSDT | KDAUSDT | KERNELUSDT | KEYUSDT | KGENUSDT | KITEUSDT |
| KLAYUSDT | KMNOUSDT | KNCUSD | KNCUSDT | KOMAUSDT | KSMUSDT |
| LABUSDT | LAUSDT | LAYERUSDT | LDOBUSD | LDOUSDT | LEVERBUSD |
| LEVERUSDT | LIGHTUSDT | LINAUSDT | LINEAUSDT | LINKBUSD | LINKUSD |
| LINKUSDC | LINKUSDT | LISTAUSDT | LITUSDT | LOKAUSDT | LOOMUSDT |
| LPTUSDT | LQTYUSDT | LRCUSDT | LSKUSDT | LTCBUSD | LTCUSD |
| LTCUSDC | LTCUSDT | LUMIAUSDT | LUNA2BUSD | LUNA2USDT | LYNUSDT |
| MAGICUSDT | MAGMAUSDT | MANAUSD | MANAUSDT | MANTAUSDT | MANTRAUSDT |
| MASKUSDT | MATICBUSD | MATICUSD | MATICUSDC | MATICUSDT | MAVIAUSDT |
| MAVUSDT | MBLUSDT | MBOXUSDT | MDTUSDT | MEGAUSDT | MELANIAUSDT |
| MEMEFIUSDT | MEMEUSDT | MERLUSDT | METISUSDT | METUSDT | MEUSDT |
| MEWUSDT | MILKUSDT | MINAUSDT | MIRAUSDT | MITOUSDT | MKRUSDT |
| MLNUSDT | MMTUSDT | MOCAUSDT | MONUSDT | MOODENGUSDT | MORPHOUSDT |
| MOVEUSDT | MOVRUSDT | MTLUSDT | MUBARAKUSDT | MUSDT | MYROUSDT |
| MYXUSDT | NAORISUSDT | NEARBUSD | NEARUSD | NEARUSDC | NEARUSDT |
| NEIROETHUSDT | NEIROUSDT | NEOUSDC | NEOUSDT | NEWTUSDT | NFPUSDT |
| NIGHTUSDT | NILUSDT | NKNUSDT | NMRUSDT | NOMUSDT | NOTUSDT |
| NTRNUSDT | NULSUSDT | NXPCUSDT | OBOLUSDT | OCEANUSDT | OGNUSDT |
| OGUSDT | OLUSDT | OMGUSDT | OMNIUSDT | OMUSDT | ONDOUSDT |
| ONEUSDT | ONGUSDT | ONTUSDT | ONUSDT | OPENUSDT | OPGUSDT |
| OPNUSDT | OPUSD | OPUSDT | ORBSUSDT | ORCAUSDT | ORDERUSDT |
| ORDIUSDC | ORDIUSDT | OUSDT | OXTUSDT | PARTIUSDT | PAXGUSDT |
| PENDLEUSDT | PENGUUSDC | PENGUUSDT | PEOPLEUSDT | PERPUSDT | PHAROSUSDT |
| PHAUSDT | PHBBUSD | PHBUSDT | PIEVERSEUSDT | PIPPINUSDT | PIXELUSDT |
| PLAYUSDT | PLUMEUSDT | PNUTUSDC | PNUTUSDT | POLUSDT | POLYXUSDT |
| PONKEUSDT | POPCATUSDT | PORT3USDT | PORTALUSDT | POWERUSDT | POWRUSDT |
| PRLUSDT | PROMPTUSDT | PROMUSDT | PROVEUSDT | PTBUSDT | PUFFERUSDT |
| PUMPBTCUSDT | PUMPUSDT | PUNDIXUSDT | PYTHUSDT | QNTUSDT | QTUMUSDT |
| QUICKUSDT | QUSDT | RADUSDT | RAREUSDT | RAVEUSDT | RAYSOLUSDT |
| RAYUSDT | RDNTUSDT | RECALLUSDT | REDUSDT | REEFUSDT | REIUSDT |
| RENDERUSDT | RENUSDT | RESOLVUSDT | REUSDT | REZUSDT | RIFUSDT |
| RIVERUSDT | RLCUSDT | RLSUSDT | RNDRUSDT | ROBOUSDT | RONINUSDT |
| ROSEUSD | ROSEUSDT | RPLUSDT | RSRUSDT | RUNEUSD | RUNEUSDT |
| RVNUSDT | RVVUSDT | SAFEUSDT | SAGAUSDT | SAHARAUSDT | SANDBUSD |
| SANDUSD | SANDUSDT | SANTOSUSDT | SAPIENUSDT | SCRTUSDT | SCRUSDT |
| SCUSDT | SEIUSDT | SENTUSDT | SFPUSDT | SHELLUSDT | SIGNUSDT |
| SIRENUSDT | SKATEUSDT | SKLUSDT | SKRUSDT | SKYAIUSDT | SKYUSDT |
| SLERFUSDT | SLPUSDT | SLXUSDT | SNTUSDT | SNXUSDT | SOLBUSD |
| SOLUSD | SOLUSDC | SOLUSDT | SOLVUSDT | SOMIUSDT | SONICUSDT |
| SOONUSDT | SOPHUSDT | SPACEUSDT | SPELLUSDT | SPKUSDT | SPORTFUNUSDT |
| SPXUSDT | SQDUSDT | SRMUSDT | SSVUSDT | STABLEUSDT | STARUSDT |
| STBLUSDT | STEEMUSDT | STGUSDT | STMXUSDT | STORJUSDT | STOUSDT |
| STPTUSDT | STRAXUSDT | STRKUSDT | STXUSDT | SUIUSD | SUIUSDC |
| SUIUSDT | SUNUSDT | SUPERUSDT | SUSDT | SUSHIUSDT | SWARMSUSDT |
| SWELLUSDT | SXPUSDT | SXTUSDT | SYNUSDT | SYRUPUSDT | SYSUSDT |
| TACUSDT | TAGUSDT | TAIKOUSDT | TAKEUSDT | TANSSIUSDT | TAOUSDT |
| TAUSDT | THETAUSD | THETAUSDT | THEUSDT | TIAUSDC | TIAUSDT |
| TLMBUSD | TLMUSDT | TNSRUSDT | TOKENUSDT | TOMOUSDT | TONUSDT |
| TOSHIUSDT | TOWNSUSDT | TRADOORUSDT | TRBUSDT | TREEUSDT | TRIAUSDT |
| TROYUSDT | TRUMPUSDC | TRUMPUSDT | TRUSTUSDT | TRUTHUSDT | TRUUSDT |
| TRXBUSD | TRXUSD | TRXUSDT | TSTUSDT | TURBOUSDT | TURTLEUSDT |
| TUSDT | TUTUSDT | TWTUSDT | UAIUSDT | UBUSDT | UMAUSDT |
| UNFIUSDT | UNIBUSD | UNIUSD | UNIUSDC | UNIUSDT | USDCUSDT |
| USELESSUSDT | USTCUSDT | USUALUSDT | USUSDT | UXLINKUSDT | VANAUSDT |
| VANRYUSDT | VELODROMEUSDT | VELVETUSDT | VETUSD | VETUSDT | VFYUSDT |
| VICUSDT | VIDTUSDT | VINEUSDT | VIRTUALUSDT | VOXELUSDT | VTHOUSDT |
| VVVUSDT | WALUSDT | WAVESBUSD | WAVESUSDT | WAXPUSDT | WCTUSDT |
| WETUSDT | WIFUSD | WIFUSDC | WIFUSDT | WLDUSD | WLDUSDC |
| WLDUSDT | WLFIUSDC | WLFIUSDT | WOOUSDT | WUSDT | XAIUSDT |
| XANUSDT | XAUTUSDT | XCNUSDT | XEMUSDT | XLMUSD | XLMUSDT |
| XMRUSD | XMRUSDT | XNYUSDT | XPINUSDT | XPLUSDT | XRPBUSD |
| XRPUSD | XRPUSDC | XRPUSDT | XTZUSD | XTZUSDT | XVGUSDT |
| XVSUSDT | YALAUSDT | YBUSDT | YFIUSDT | YGGUSDT | ZAMAUSDT |
| ZBTUSDT | ZECUSDC | ZECUSDT | ZENUSDT | ZEREBROUSDT | ZESTUSDT |
| ZETAUSDT | ZILUSD | ZILUSDT | ZKCUSDT | ZKJUSDT | ZKPUSDT |
| ZKUSDT | ZORAUSDT | ZRCUSDT | ZROUSDT | ZRXUSDT | 币安人生USDT |
| 我踏马来了USDT | 龙虾USDT |  |  |  |  |

## Example Applications

The Binance Crypto Future Price dataset enables you to accurately design strategies for Cryptocurrencies with term structure. Examples include the following strategies:

- Horizontal/Diagonal arbitrage with the underlying cryptocurrencies
- Trade Contango/Backwardation predictions
- Hedge for illiquid cryptocurrencies

### Classic Algorithm Example

The following example algorithm buys BTCUSDT perpetual future contract if the last day's close price was close to ask close price than bid close price, sells short of that in opposite, through the Binance exchange:

```
from AlgorithmImports import *

class BinanceCryptoFutureDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        # Set the account currency to USDT, since you can't trade with
        # USD and the algorithm doesn't automatically convert USD & USDT
        # holdings.
        self.set_account_currency("USDT", 100000)
        # Binance Futures Exchange accepts both Cash and Margin account
        # types. Select the one you need for the best reality modeling.
        self.set_brokerage_model(BrokerageName.BINANCE_FUTURES, AccountType.MARGIN)
        # Add BTCUSDT data from the Binance Future exchange.
        # Perpetual futures does not have a filter function.
        self._btc = self.add_crypto_future("BTCUSDT", Resolution.DAILY)
        # Historical data
        history = self.history(self._btc, 10, Resolution.DAILY)

    def on_data(self, slice: Slice) -> None:
        # Trade only based on updated price data.
        if self._btc.symbol not in slice.bars or self._btc.symbol not in slice.quote_bars:
            return
        # Scalp-trade the bid-ask spread based on the supply-demand strength
        if self._btc.price - self._btc.bid_price > self._btc.ask_price - self._btc.price:
            self.set_holdings(self._btc, -0.5)
        else:
            self.set_holdings(self._btc, 1)
```

```
public class BinanceCryptoFutureDataAlgorithm : QCAlgorithm
{
    public CryptoFuture _btc;

    public override void Initialize()
    {
        SetStartDate(2024, 9, 1);
        SetEndDate(2024, 12, 31);
        // Set the account currency to USDT, since you can't trade with
        // USD and the algorithm doesn't automatically convert USD & USDT
        // holdings.
        SetAccountCurrency("USDT", 100000);
        // Binance Futures Exchange accepts both Cash and Margin account
        // types. Select the one you need for the best reality modeling.
        SetBrokerageModel(BrokerageName.BinanceFutures, AccountType.Margin);
        // Add BTCUSDT data from the Binance Future exchange.
        // Perpetual futures does not have a filter function.
        _btc = AddCryptoFuture("BTCUSDT", Resolution.Daily);
        // Historical data
        var history = History(_btc, 10, Resolution.Daily);
    }

    public override void OnData(Slice slice)
    {
        // Trade only based on updated price data.
        if (!slice.Bars.ContainsKey(_btc) || !slice.QuoteBars.ContainsKey(_btc))
        {
            return;
        }
        // Scalp-trade the bid-ask spread based on the supply-demand strength
        if (_btc.Price - _btc.BidPrice > _btc.AskPrice - _btc.Price)
        {
            SetHoldings(_btc, -0.5m);
        }
        else
        {
            SetHoldings(_btc, 1m);
        }
    }
}
```

### Framework Algorithm Example

The following example algorithm hold a long BTCUSDT Future portfolio if the last day's close price was close to ask close price than bid close price, while hold short of that in opposite, through the Binance exchange using the [algorithm framework](https://www.quantconnect.com/docs/v2/writing-algorithms/algorithm-framework/overview.md) implementation:

```
from AlgorithmImports import *

class BinanceCryptoFutureDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        # Set the account currency to USDT, since you can't trade with
        # USD and the algorithm doesn't automatically convert USD & USDT
        # holdings.
        self.set_account_currency("USDT", 100000)
        # Binance Futures Exchange accepts both Cash and Margin account types, select the one you need for the best reality modeling.
        self.set_brokerage_model(BrokerageName.BINANCE_FUTURES, AccountType.MARGIN)
        self.universe_settings.resolution = Resolution.DAILY
        self.universe_settings.leverage = 2
        # We only trade on BTCUSDT Future in Binance Future exchange
        symbols = Symbol.create("BTCUSDT", SecurityType.CRYPTO_FUTURE, Market.BINANCE)
        self.add_universe_selection(ManualUniverseSelectionModel(symbols))
        # Custom alpha model to emit insights based on the Crypto Future price data
        self.add_alpha(CryptoFutureAlphaModel())
        # Equally invest to evenly dissipate the capital concentration risk of inidividual crypto pair
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
        self.set_execution(ImmediateExecutionModel())

class CryptoFutureAlphaModel(AlphaModel):

    def __init__(self) -> None:
        self.symbols = []

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        insights = []

        for symbol in self.symbols:
            # Trade only based on updated price data
            if not slice.bars.contains_key(symbol) or not slice.quote_bars.contains_key(symbol):
                continue

            quote = slice.quote_bars[symbol]
            price = slice.bars[symbol].price

            # Scalp-trade the bid-ask spread based on the supply-demand strength
            if price - quote.bid.close > quote.ask.close - price:
                direction = InsightDirection.DOWN
            else:
                direction = InsightDirection.UP
            insights.append(Insight.price(symbol, timedelta(1), direction))

        return insights

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            symbol = security.symbol
            self.symbols.append(symbol)

            # Historical data
            history = algorithm.history(symbol, 10, Resolution.DAILY)

        for security in changes.removed_securities:
            symbol = security.symbol
            if symbol in self.symbols:
                self.symbols.remove(symbol)
```

```
public class BinanceCryptoFutureDataAlgorithm : QCAlgorithm
{
    public Symbol _symbol;

    public override void Initialize()
    {
        SetStartDate(2024, 9, 1);
        SetEndDate(2024, 12, 31);
        // Set the account currency to USDT, since you can't trade with
        // USD and the algorithm doesn't automatically convert USD & USDT
        // holdings.
        SetAccountCurrency("USDT", 100000);
        // Binance Futures Exchange accepts both Cash and Margin account types, select the one you need for the best reality modeling.
        SetBrokerageModel(BrokerageName.BinanceFutures, AccountType.Margin);
        UniverseSettings.Resolution = Resolution.Daily;
        UniverseSettings.Leverage = 2;
        // We only trade on BTCUSDT Future in Binance Future exchange
        var symbols = new List<Symbol> {
            QuantConnect.Symbol.Create("BTCUSDT", SecurityType.CryptoFuture, Market.Binance)
        };
        AddUniverseSelection(new ManualUniverseSelectionModel(symbols));
        // Custom alpha model to emit insights based on the Crypto Future price data
        AddAlpha(new CryptoFutureAlphaModel());
        // Equally invest to evenly dissipate the capital concentration risk of inidividual crypto pair
        SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
        SetExecution(new ImmediateExecutionModel());
    }
}

public class CryptoFutureAlphaModel : AlphaModel
{
    private List<Symbol> _symbols = new();

    public override IEnumerable<Insight> Update(QCAlgorithm algorithm, Slice slice)
    {
        var insights = new List<Insight>();

        foreach (var symbol in _symbols)
        {
            // Trade only based on updated price data
            if (!slice.Bars.ContainsKey(symbol) || !slice.QuoteBars.TryGetValue(symbol, out var quote))
            {
                continue;
            }
            var price = slice.Bars[symbol].Price;

            // Scalp-trade the bid-ask spread based on the supply-demand strength
            InsightDirection direction;
            if (price - quote.Bid.Close > quote.Ask.Close - price)
            {
                direction = InsightDirection.Down;
            }
            else
            {
                direction = InsightDirection.Up;
            }
            insights.Add(Insight.Price(symbol, TimeSpan.FromDays(1), direction));
        }
        return insights;
    }

    public override void OnSecuritiesChanged(QCAlgorithm algorithm, SecurityChanges changes)
    {
        foreach (var security in changes.AddedSecurities)
        {
            var symbol = security.Symbol;
            _symbols.Add(symbol);

            // Historical data
            var history = algorithm.History(symbol, 10, Resolution.Daily);
        }

        foreach (var security in changes.RemovedSecurities)
        {
            _symbols.Remove(security.Symbol);
        }
    }
}
```

## Data Point Attributes

The Binance Crypto Future Price dataset provides `TradeBar`, `QuoteBar`, and `Tick` objects.

### TradeBar Attributes

`TradeBar` objects have the following attributes:

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

### QuoteBar Attributes

`QuoteBar` objects have the following attributes:

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

### Tick Attributes

`Tick` objects have the following attributes:

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