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
QuantTrader
That's fantastic news Jared & Team!
I've been looking for this.
In any case, could you please provide information on the CFD equivalents available for Index CFDs such as IBUS500, IBDE40, for backtesting?
Many Thanks
Jared Broad
IBUS500 looks like S&P500, so SPY should be a good parallel. IBDE40 is the German 40, so a quick Google shows “DAX” should be a similar ETF.
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.
Tom Joad
Hi,
That's great news, perfect solution for when you're living in Europe!
Do you need an additional data subscription to trade with CFDs, I got the following message when I tried a live strategy:
“Brokerage Warning: Historical Market Data Service error message:No market data permissions for AMEX STK. Requested market data requires additional subscription for API. See link in 'Market Data Connections' dialog for more details.. Origin: [Id=10] GetHistory: XLK (STK XLK USD Smart ARCA 0 )”
I do not use historical data to do my calculations, I only use CFDs to trade (like proposed in the documentation). And I thought that live data for AMEX is included in the base data subscription of IBKR, like other ETFs.
Greetz
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!