Thanks to a client sponsorship, we built and shipped a CFD integration for Interactive Brokers that provides live trading through Indexes, Metals, Forex, and Global Stock CFDs. 

This integration is particularly valuable for European clients who cannot trade US ETF products due to regulations. Before now, those clients could not trade ETF strategies in live trading, limiting them to single stock assets, which have much higher fees than ETFs for index trading.

Transitions from Research to Live Trading

Although we do not have the historical data for IB CFD products, our live mode flag easily solves the transition between backtest and live trading, allowing you to use Equity products for research and backtesting and then swapping to CFD equivalents for live trading.

self.tickers = ["SPY", "BND", "GLD"]
self.securityType = SecurityType.Equity
for ticker in self.tickers:
	if self.LiveMode:
		securityType = SecurityType.Cfd
	self.AddSecurity(securityType, ticker, Resolution.Minute)

The same concept can be applied to universe selection using the CFD version of an Equity Symbol. Universe filters return a Symbol[], which can be swapped for a CFD version of the same ticker. This allows you to pair our fundamental data universes with CFD vehicles for execution:


self.UniverseSettings.Asynchronous = True # In Initialize:
self.universe = self.AddUniverse(self.FundamentalSelectionFunction)

# Select top ten CFD's by PE ratio and volume
def FundamentalSelectionFunction(self, fundamental: List[Fundamental]) -> List[Symbol]:
	filtered = [f for f in fundamental if f.Price > 10 and f.HasFundamentalData and not np.isnan(f.ValuationRatios.PERatio)]
	sortedByDollarVolume = sorted(filtered, key=lambda f: f.DollarVolume, reverse=True)[:100]
	sortedByPeRatio = sorted(sortedByDollarVolume, key=lambda f: f.ValuationRatios.PERatio, reverse=False)[:10]

	if self.LiveMode:
		return [Symbol.Create(f.Value, SecurityType.Cfd, Market.InteractiveBrokers) 
		        for f in sortedByPeRatio]
	else:
		return [f.Symbol for f in sortedByPeRatio]

For more information on how to use CFD assets in QuantConnect, please see our documentation. You can also explore the Interactive Brokers Product Search for supported CFD assets. 

Live Trading

Select Interactive Brokers as a data source from the live deployment wizard to use this new feature in live trading. This can be used with paper or live trading accounts. We source quotes and tick feeds directly from Interactive Brokers.

As CFD assets don't have corporate actions (such as split and dividend events), we recommend using the underlying Equity asset for indicators and trading with the CFD counterparts. Our documentation shows an example of this with an SMA strategy.

Feature Sponsorships

This feature was developed within four weeks with our feature sponsorship program. This program allows clients to fast-track features they need at a lower cost than building them themselves. QuantConnect core team does the engineering at cost, providing that we own the intellectual property and can open-source the work. This helps the community as corporate sponsors drive the improvements to the open-source LEAN Engine. 

If you're a client or potential client seeking a feature such as an indicator, asset class, order type, data source, or brokerage connection, get in touch about ways we can ship this for your team.

Happy Trading

Team @ QuantConnect