Options and Futures Trading on QuantConnect

We are very excited to announce the beta launch of options and futures trading on QuantConnect! Through the open-source platform LEAN, algorithmic trading has never been so accessible to investors.

The new asset classes tie into our existing offering of Equities, FOREX and CFD products bringing us to a total of five asset classes. We can now simultaneously trade multiple asset classes when used with a supporting brokerage. You write strategies in C#, Python and F#.

Options and futures are highly requested features from the community so we are happy to be shipping this feature. Like our other asset classes, all data is event driven manner to avoid look ahead bias.

Starting today you can also live trade your options and futures strategies on Interactive Brokers! (An accompanying options data subscription from Interactive Brokers required). If you’re an options/futures wizz get in touch!

Data and Period Available

Option data is available at minute resolution from January 2014-December 2016. Because of its sheer size we’re processing dates in reverse order backwards through time. When processing is complete the library will start January 2007. The data is survivorship bias free, and delivered as trades, quotes and open interest information. We cover all symbols in the OPRA feed. You can see a full example of an option algorithm in the BasicTemplateOptionsFilterUniverseAlgorithm.cs.

//Add Option Base 
var option = AddOption("SPY");

//Filter down to what we want.
option.SetFilter(universe => 
		from symbol in universe
		      .WeeklysOnly().Expiration(TimeSpan.Zero, TimeSpan.FromDays(10))
		where symbol.ID.OptionRight != OptionRight.Put
		select symbol);

// Search option chain:
if (slice.OptionChains.TryGetValue(OptionSymbol, out chain))
{
	// find the second call strike under market price expiring today
	var contract = (
		from optionContract in chain.OrderByDescending(x => x.Strike)
		where optionContract.Right == OptionRight.Call
		where optionContract.Expiry == Time.Date
		where optionContract.Strike < chain.Underlying.Price
		select optionContract
		).Skip(2).FirstOrDefault();

	if (contract != null)
	{
		MarketOrder(contract.Symbol, 1);
	}
}

Futures trading is available in tick, second and minute resolutions from January 2009 – December 2016. Our futures library covers all symbols from CME, NYMEX, CBOT and COMEX exchanges. You can see an example of a future algorithm in the BasicTemplateFutureAlgorithm.cs.

//Add Future Contract
var futureGold = AddFuture(Futures.Metals.Gold);

// What contracts do you want?
futureGold.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(182)); 

// Search future chain for specific contracts to trade.
foreach(var chain in slice.FutureChains) 
{
	// find the front contract expiring no earlier than in 90 days
	var contract = (
		from futuresContract in chain.Value.OrderBy(x => x.Expiry)
		where futuresContract.Expiry > Time.Date.AddDays(90)
		select futuresContract
		).FirstOrDefault();

	// if found, trade it
	if (contract != null)
	{
		MarketOrder(contract.Symbol, 1);
	}
}

Options and futures trading also introduces the concept of QuoteBars to QuantConnect – a representation of the quote movements over time. QuoteBars have a Bid (OHLC) and Ask (OHLC) Bar. This allows us to better model spread for low volume assets such as option contracts. QuoteBars are limited to Options and Futures now, but will be extended to FX and CFD soon.

Data Provider

We’d like to give a special thank you to our data provider AlgoSeek. AlgoSeek shares the QuantConnect vision and has generously sponsored data for the QuantConnect community. You can download more data for LEAN from https://www.algoseek.com.

AlgoSeek is a leading provider of historical intraday US market data to banks, hedge funds, academia and individuals worldwide.

3 Comments

  1. Hey Jared

    Keep up the good work👏

    Thanks

    Nik Milev

  2. Hi Jared. Great job with the option data. The post says Dec 2016 and going backward through time. I can see data for Aug 2016 and backward, but nothing from Aug 2016 and beyond. Will that data become available soon? I have looked at SPY and GOOG, but there doesn’t seem to be anything beyond Aug 2016.

    Thanks!

    Brandon

    • Hey Brandon! We’ve processed from 2010 -> August 26th, 2016. We’re working on getting the other data in place but as you can imagine its a gigantic task! We’ll post to the community forums once its getting updated each day.

Leave a Reply

Your email address will not be published.

*

© 2017 QuantConnect Blog

Democratizing algorithmic investments Up ↑