QuantConnect
US Futures Security Master
Introduction
The US Futures Security Master dataset by QuantConnect provides mapping reference data for the most liquid contracts of the CME Group exchanges, calculated with popular rolling techniques. The data covers 75 root Future contracts, starts in 2012, and is delivered on a daily frequency with a zip file with all the contract mappings. This dataset is created by daily processing of the US historical Future chains.
This dataset, paired the US Futures dataset, supports the following rolling techniques: ForwardPanamaCanal, BackwardsPanamaCanal, and Backwards Ratio. You can set the specific date of rolling to occur on the LastTradingDay, FirstDayMonth, or on the day where the contract with the greatest OpenInterest changes.
For more information about the US Futures Security Master dataset, including CLI commands and pricing, see the dataset listing.
About the Provider
QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 50,000 quants are served every month.
Getting Started
You don't need any special code to utilize the US Futures Security Master. It automatically loads when you request US Futures data.
Key Concept
The US Futures Security Master lets you to construct continuous Futures, allowing the access of normalized historical data of the underlying assets, as well as trading the “lead” Future contracts for those assets.
Continuous Futures refer to sets of rolling lead Future contracts during their actively trading periods. Since Future contracts expire at their maturities, to analyze the historical price of a Future and to apply technical indicators, you need the continuous Future price series.
To access the continuous Future, use the Future's Symbol property.
future = self.AddFuture(Futures.Energies.CrudeOilWTI, dataNormalizationMode = DataNormalizationMode.BackwardsRatio, dataMappingMode = DataMappingMode.OpenInterest, contractDepthOffset = 0) self.continuous_contract_symbol = future.Symbol
var future = AddFuture(Futures.Energies.CrudeOilWTI, dataNormalizationMode: DataNormalizationMode.BackwardsRatio, dataMappingMode: DataMappingMode.OpenInterest, contractDepthOffset: 0 ); _continuousFutureSymbol = future.Symbol;
The dataNormalizationMode and dataMappingMode arguments makes the transition of the underlying contracts seemless. However, the Future Symbol doesn't map to an underlying Future contract. It works fine to trade within backtests, but could be subjected to friction costs during live trading since the order price could be a normalized price. For more information about this topic, see the Live Trading Considerations section.
Data Normalization Modes
The data normalization mode defines how the price series of two contracts are stitched together when the contract rollovers occur. The DataNormalizatoinMode enumeration has the following members available for continuous contracts:
If you use a data normalization mode that's not in the preceding list, LEAN automatically converts it to DataNormalizationMode.BackwardsRatio.
Tracking Contract Changes
As the contracts roll over, the Mapped property of the Future object references the next contract in the series and you receive a SymbolChangedEvent. To get the current Symbol change events, index the SymbolChangedEvents property of the current Slice with the continuous Futures Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your Future at every time step. To avoid issues, check if the Slice contains the data you want before you index it.
def OnData(self, slice: Slice)0 -> None: if slice.SymbolChangedEvents.ContainsKey(self.continuous_future_symbol): symbol_changed_event = slice.SymbolChangedEvents[self.continuous_future_symbol] self.Log(f"Symbol changed: {symbolChangedEvent.OldSymbol} -> {symbolChangedEvent.NewSymbol}")
public override void OnData(Slice slice) { if (slice.SymbolChangedEvents.ContainsKey(_continuousFutureSymbol)) { var symbolChangedEvent = slice.SymbolChangedEvents[_continuousFutureSymbol]; Log($"Symbol changed: {symbolChangedEvent.OldSymbol} -> {symbolChangedEvent.NewSymbol}"); } }
SymbolChangedEvent objects have the following attributes:
Live Trading Considerations
You can trade continuous Futures, but the continuous Future Symbol doesn't map to a single underlying Future contract. Instead, it represents a set of rolling contracts. Thus, the prices could be frictional during a contract rollover, which could be catastrophic in live trading! For live trading, you should place your orders directly on the underlying contracts. To get the current underlying contract in the continuous Future series, use the Mapped property.
current_contract = self.continuous_contract.Mapped self.Buy(current_contract, 1)
var currentContract = _continuousContract.Mapped; Buy(currentContract, 1);
Data Format
If you download the files in the US Futures Security Master, you get a factor file and a map file for each of the exchanges with supported continuous Futures. To view the files, see the \data\future\<exchange_name> directory under your LEAN CLI base directory.
For the factor file, it is a .zip collection of REST API styled .csv files for each Future Symbol, including the date, scaling factors for each type of data normalization and the data mapping mode that indicates the Symbol changing event is on that day for that mapping mode. The following line is an example line in the .csv file:
{"Date":"2009-10-31T00:00:00","BackwardsRatioScale":[0.9914163090128755364806866953,1.0,1.0],"BackwardsPanamaCanalScale":[-2.0,0.0,0.0],"ForwardPanamaCanalScale":[0.0,0.0,0.0],"DataMappingMode":1}
For the map file, it is a .zip collection of .csv files for each Future Symbol, including the date, new underlying contract Symbol, the exchange code, and the data mapping mode that indicates the Symbol changing event is on that day for that mapping mode. The following line is an example line in the .csv file:
20091130,aw uii3j0m6zbj9,CBOT,1
Example Applications
The US Futures Security Master enables you to design strategies harnessing continuous Futures contracts. Examples include the following strategies:
- Trading cyclical patterns in commodity Futures.
- Buying gold Futures as an inflation hedge with automatic contract roll overs.
- Detecting arbitrage opportunities between index Futures and Equities.