About CFD Data
The CFD Data by QuantConnect serves 51 contracts for differences (CFD). The data starts as early as May 2002 and is delivered on any frequency from tick to daily. This dataset is created by QuantConnect processing raw tick data from OANDA.
About QuantConnect
QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 50,000 quants are served every month.
About QuantConnect
QuantConnect was founded in 2012 to serve quants everywhere with the best possible algorithmic trading technology. Seeking to disrupt a notoriously closed-source industry, QuantConnect takes a radically open-source approach to algorithmic trading. Through the QuantConnect web platform, more than 50,000 quants are served every month.
Algorithm Example
from AlgorithmImports import *
from QuantConnect.DataSource import *
class SMAPairsTrading(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2018, 7, 1)
self.set_end_date(2019, 3, 31)
self.set_cash(100000)
# Request gold and sliver spot CFDs for trading their spread difference, assuming their spread series is cointegrated
self.add_cfd('XAUUSD', Resolution.HOUR)
self.add_cfd('XAGUSD', Resolution.HOUR)
# Use 500-step mean and SD indicator on determine the spread relative difference for trading signal generation
self.pair = [ ]
self.spread_mean = SimpleMovingAverage(500)
self.spread_std = StandardDeviation(500)
def on_data(self, slice: Slice) -> None:
# Update the indicator with updated spread difference, such that the an updated cointegration threshold is calculated for trade inception
spread = self.pair[1].price - self.pair[0].price
self.spread_mean.update(self.time, spread)
self.spread_std.update(self.time, spread)
spread_mean = self.spread_mean.current.value
upperthreshold = spread_mean + self.spread_std.current.value
lowerthreshold = spread_mean - self.spread_std.current.value
# If the spread is higher than upper threshold, bet their spread series will revert to mean
if spread > upperthreshold:
self.set_holdings(self.pair[0].symbol, 1)
self.set_holdings(self.pair[1].symbol, -1)
elif spread < lowerthreshold:
self.set_holdings(self.pair[0].symbol, -1)
self.set_holdings(self.pair[1].symbol, 1)
# Close positions if mean reverted
elif (self.portfolio[self.pair[0].symbol].quantity > 0 and spread < spread_mean)\
or (self.portfolio[self.pair[0].symbol].quantity < 0 and spread > spread_mean):
self.liquidate()
def on_securities_changed(self, changes: SecurityChanges) -> None:
self.pair = [x for x in changes.added_securities]
#1. Call for 500 bars of history data for each symbol in the pair and save to the variable history
history = self.history([x.symbol for x in self.pair], 500)
#2. Unstack the Pandas data frame to reduce it to the history close price
history = history.close.unstack(level=0)
#3. Iterate through the history tuple and update the mean and standard deviation with historical data
for tuple in history.itertuples():
self.spread_mean.update(tuple[0], tuple[2]-tuple[1])
self.spread_std.update(tuple[0], tuple[2]-tuple[1])
Example Applications
The CFD price data enables you to trade CFD assets in your algorithm. Examples include the following strategies:
- Exploring the daily worldwide news cycles with CFDs that track international indices.
- Trading price movements of commodities with no delivery of physical goods. For example, pairs trading between gold and silver, corn and wheat, brent and crude oil, etc.
Pricing
Cloud Access
Freely harness gigabytes of CFD data in the QuantConnect Cloud for your backtesting and live trading purposes.
Second Download
CFD Second resolution archives in LEAN format for on premise backtesting and research. One file per ticker/day.
Minute Download
CFD Minute resolution archives in LEAN format for on premise backtesting and research. One file per ticker/day.
Hour Download
CFD Hour resolution archives in LEAN format for on premise backtesting and research. One file per ticker.
Daily Download
CFD Daily resolution archives in LEAN format for on premise backtesting and research. One file per ticker.
Bulk Second Updates
Bulk download second data
Bulk Minute Updates
Bulk download minute data
Bulk Hour Updates
Bulk download hour data
Bulk Daily Updates
Bulk download daily data
Bulk Second Download
Bulk download second data
Bulk Minute Download
Bulk download minute data
Bulk Hour Download
Bulk download hour data
Bulk Daily Download
Bulk download daily data
Explore Other Datasets
US Equity Option Universe
Dataset by QuantConnect
US Index Option Universe
Dataset by QuantConnect
FOREX Data
Dataset by QuantConnect