Crypto Futures
Requesting Data
Introduction
Request Crypto Futures data in your algorithm to receive a feed of asset prices in the OnData
on_data
method. For more information about the specific datasets we use for backtests, see the Binance Crypto Future Price Data dataset listing. To trade Crypto Futures live, you can use the QuantConnect data provider.
Create Subscriptions
To create a Crypto Futures subscription, in the Initialize
initialize
method, call the AddCryptoFuture
add_crypto_future
method. The AddCryptoFuture
add_crypto_future
method returns a CryptoFuture
object, which contains a Symbol
symbol
property. Save a reference to the Symbol
symbol
so you can use it in OnData
on_data
to access the security data in the Slice
.
_symbol = AddCryptoFuture("BTCUSD").Symbol;
self._symbol = self.add_crypto_future("BTCUSD").symbol
The AddCryptoFuture
add_crypto_future
method creates a subscription for a single Crypto Futures asset and adds it to your user-defined universe.
To view the supported assets in the Crypto Futures dataset, see Supported Assets.
Resolutions
The following table shows the available resolutions and data formats for Crypto Futures contract subscriptions:
Resolution | TradeBar | QuoteBar | Trade Tick | Quote Tick |
---|---|---|---|---|
Tick TICK | ||||
Second SECOND | ||||
Minute MINUTE | ||||
Hour HOUR | ||||
Daily DAILY |
The default resolution for Crypto Futures subscriptions is Resolution.Minute
Resolution.MINUTE
. To change the resolution, pass a resolution
argument to the AddCryptoFuture
add_crypto_future
method.
_symbol = AddCryptoFuture("BTCUSD", Resolution.Daily).Symbol;
self._symbol = self.add_crypto_future("BTCUSD", Resolution.DAILY).symbol
To create custom resolution periods, see Consolidating Data.
Supported Markets
The following Market
enumeration members are available for Cryptofuture:
_symbol = AddCryptoFuture("BTCUSD", market: Market.Binance).Symbol;
self._symbol = self.add_crypto_future("BTCUSD", market=Market.BINANCE).symbol
The brokerage models have a default market for each asset class. If you set a brokerage model, you may not need to specify the market to use.
Fill Forward
Fill forward means if there is no data point for the current slice, LEAN uses the previous data point. Fill forward is the default data setting. If you disable fill forward, you may get stale fills or you may see trade volume as zero.
To disable fill forward for a security, set the fillForward
fill_forward
argument to false when you create the security subscription.
_symbol = AddCryptoFuture("BTCUSD", fillForward: false).Symbol;
self._symbol = self.add_crypto_future("BTCUSD", fill_forward=False).symbol
Margin and Leverage
LEAN models buying power and margin calls to ensure your algorithm stays within the margin requirements. The amount of leverage available to you depends on the brokerage you use. To change the amount of leverage you can use for a security, pass a leverage
argument to the AddCryptoFuture
add_crypto_future
method.
_symbol = AddCryptoFuture("BTCUSD", leverage: 3).Symbol;
self._symbol = self.add_crypto_future("BTCUSD", leverage=3).symbol
For more information about the leverage each brokerage provides, see Brokerages.
Data Normalization
The data normalization mode doesn't affect the data that LEAN passes to OnData
on_data
or the data from history request. If you change the data normalization mode, it won't change the outcome.