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 Basevar 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 Contractvar 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.
Jared Broad
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!