CoinAPI
Binance Crypto Future Price Data
Introduction
The Binance Crypto Future Price Data by CoinAPI is for Crypto-currency futures price and volume data points. The data covers 421 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 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.
About the Provider
CoinAPI was founded by Artur Pietrzyk in 2016 with the goal of providing real-time and historical cryptocurrency market data, collected from hundreds of exchanges. CoinAPI provides access to Cryptocurrencies for traders, market makers, and developers building third-party applications.
Getting Started
The following snippet demonstrates how to request data from the Binance Crypto Future Price dataset:
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 | 421 Crypto Futures Pairs |
Data Density | Dense |
Resolution | Tick, Second, Minute, Hourly, & Daily |
Timezone | UTC |
Market Hours | Always Open |
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
For more example algorithms, see Examples.
Data Point Attributes
The Binance Crypto Future Price dataset provides TradeBar
, QuoteBar
, and Tick
objects.
TradeBar Attributes
TradeBar
objects have the following attributes:
QuoteBar Attributes
QuoteBar
objects have the following attributes:
Tick Attributes
Tick
objects have the following attributes:
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.
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.
Accessing Data
To get the current Binance Crypto Future Price data, index the bars
, quote_bars
, or ticks
properties of the current Slice
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.
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
.
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.
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.
# 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.
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
For more example algorithms, see Examples.