About CFD Data
The CFD Data by OANDA 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 OANDA
OANDA was co-founded by Dr. Stumm, a computer scientist and Dr. Olsen, an economist, in 1997. The company was born out of the belief that the Internet and technology would open up the markets for both currency data and trading. OANDA uses innovative computer and financial technology to provide Internet-based forex trading and currency information services to everyone, from individuals to large corporations, from portfolio managers to financial institutions. OANDA is a market maker and a trusted source for currency data. It has access to one of the world's largest historical, high-frequency, filtered currency databases.
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)
self.add_cfd('XAUUSD', Resolution.HOUR)
self.add_cfd('XAGUSD', Resolution.HOUR)
self.pair = [ ]
self.spread_mean = SimpleMovingAverage(500)
self.spread_std = StandardDeviation(500)
def on_data(self, slice: Slice) -> None:
spread = self.pair[1].price - self.pair[0].price
self.spread_mean.update(self.time, spread)
self.spread_std.update(self.time, spread)
upperthreshold = self.spread_mean.current.value + self.spread_std.current.value
lowerthreshold = self.spread_mean.current.value - self.spread_std.current.value
if spread > upperthreshold:
self.set_holdings(self.pair[0].symbol, 1)
self.set_holdings(self.pair[1].symbol, -1)
if spread < lowerthreshold:
self.set_holdings(self.pair[0].symbol, -1)
self.set_holdings(self.pair[1].symbol, 1)
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 Cash Indices
Dataset by TickData
US Equities
Dataset by AlgoSeek
Composite Factor Bundle
Dataset by Kavout