Data Library

Futures

Introduction

QuantConnect provides US Future prices for all assets listed on the CME, CBOT, NYMEX and Comex since January 2008. Data is timestamped to the millisecond. It is also survivorship-bias free (includes symbols no longer traded). Futures live trading only available through Interactive Brokers.


Data Properties
Data ProviderAlgoSeek
Start Date Data is available starting January 1st, 2008
Symbol Universe ≈ 1100 Symbols. All symbols trading on future exchanges each day.
Data Type Trades and Quotes
ResolutionsTick, Second, Minute

Future data comes as trades and quotes, with tick, second and minute resolutions available.

Live Trading futures data is sourced from Interactive Brokers. The data used comes from your futures data subscription. You must have a valid data subscription with Interactive Brokers.

Requesting Futures Data

To subscribe to futures data in QuantConnect you should first select the asset you'd like to trade; and then specify the filter by the contracts expiration that you'd like to see.

// Complete Add Future API - Including Default Parameters:
AddFuture(string symbol,
          Resolution resolution = Resolution.Minute,
          string market = null,
          bool fillDataForward = true,
          decimal leverage = 0m)      

By default, the futures universe is filtered down to contracts that expire within 35 days. A different set of contracts can be chosen with the SetFilter method:

var future = AddFuture(Futures.Indices.SP500EMini);
future.SetFilter(TimeSpan.FromDays(30), TimeSpan.FromDays(180));
future = self.AddFuture(Futures.Indices.SP500EMini)
future.SetFilter(timedelta(30), timedelta(182))

We can also use Linq on the contract list to select the contract(s) we want to trade:

We can also use filter functions on the contract list to select the contract(s) we want to trade:

// In Initialize
var future = AddFuture(Futures.Indices.SP500EMini, Resolution.Minute);
future.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(182));
// or filtering with Linq:
future.SetFilter(universe => universe.Expiration(TimeSpan.Zero, TimeSpan.FromDays(182)));
# In Initialize
future = self.AddFuture(Futures.Indices.SP500EMini, Resolution.Minute)
future.SetFilter(timedelta(0), timedelta(182))
# or with a Lambda Function:
future.SetFilter(lambda universe: universe.Expiration(timedelta(0), timedelta(182)))

Using Futures Data

Quotes and trades for your selected future contracts can be accessed in the Slice object in OnData event handler. The FuturesChains member contains a FutureChain object for each subscribed future. A FutureChain is a collection of individual future contracts with different expiry dates.

// Save accessor symbol in Initialize() function.
futureSymbol = future.Symbol;

// In OnData(Slice slice)
FuturesChain chain;
// Explore the future contract chain
if (slice.FuturesChains.TryGetValue(futureSymbol, out chain))
{
    var underlying = chain.Underlying;
    var contracts = chain.Contracts.Value; 
    foreach (var contract in contracts)
    {
        //
    }
}
# Explore the future contract chain
def OnData(self, slice):
    for chain in slice.FutureChains.Values:
        contracts = chain.Contracts
        for contract in contracts:
            pass

Future contracts have the following properties:

class FuturesContract:
    self.Symbol # (Symbol) Symbol for contract needed to trade.
    self.UnderlyingSymbol # (Symbol) Underlying futures asset.
    self.Expiry # (datetime) When the future expires
    self.OpenInterest # (decimal) Number of open interest.
    self.LastPrice # (decimal) Last sale price.
    self.Volume # (long) reported volume.
    self.BidPrice # (decimal) bid quote price.
    self.BidSize # (long) bid quote size.
    self.AskPrice # (decimal) ask quote price.
    self.AskSize # (long) ask quote size.
public class FuturesContract
{
    Symbol Symbol;
    Symbol UnderlyingSymbol;
    DateTime Expiry;
    DateTime Time;
    decimal OpenInterest;
    decimal LastPrice;
    long Volume;
    decimal BidPrice;
    long BidSize;
    decimal AskPrice;
    long AskSize;
}

Timezone

Algoseek futures data is set in the timezone in which the future is listed. The futures listed in CME or CBOT have their data set in Chicago Time and the futures listed in NYMEX and Comex have their data set in New York Time. So when accessing futures data, make sure to account for the different time zones.

About the Provider

AlgoSeek is a leading provider of historical intraday US market data to banks, hedge funds, academia and individuals worldwide. Their high quality and affordable datasets are used for research and trading around the world.

AlgoSeek has been collecting US Equities and ETF data on all listed USA equities and ETFs since January 2007. Their data is ready for institutional researchers for back testing and quant research. Data is timestamped to the millisecond.

You can also see our Tutorials and Videos. You can also get in touch with us via Chat.

Did you find this page Helpful ?