Forex
AvailableDaily bars for four major currency pairs from OANDA.
Daily bars for EURUSD, GBPUSD, EURGBP and NZDUSD, quoted by OANDA, from January 2007 to December 2018.
How the data works
- Available pairs are EURUSD, GBPUSD, EURGBP and NZDUSD. Any other pair has no data.
- Pass Market.OANDA, and use Resolution.DAILY: finer OANDA bars exist only for EURUSD and NZDUSD, mostly for a few days in May 2014.
- Forex has no central exchange, so these prices are OANDA's own quotes. Other brokers' prices differ a little.
- Bars are quote bars, not trades, so there is no volume. Orders fill at the bid or the ask.
Fields
4 columns| Field | Description |
|---|---|
| time | When the bar began, in the market's time zone |
| end_time | When the bar closed: the moment it reaches your algorithm |
| open, high, low, close | Prices in the bar |
| bid, ask | Bid and ask bars, each with its own open, high, low and close, read from data.quote_bars[symbol] |
Example algorithm
# region imports
from AlgorithmImports import *
# endregion
class MeanReversionAlgorithm(QCAlgorithm):
def initialize(self):
self.set_start_date(2010, 1, 1)
self.set_end_date(2018, 12, 1)
self.set_cash(100000)
self.eurusd = self.add_forex("EURUSD", Resolution.DAILY, Market.OANDA).symbol
self.strength = self.rsi(self.eurusd, 14, resolution=Resolution.DAILY)
self.set_warm_up(14, Resolution.DAILY)
def on_data(self, slice):
if self.is_warming_up or not self.strength.is_ready:
return
# Buy when oversold, and sell once the move has recovered.
if self.strength.current.value < 30 and not self.portfolio.invested:
self.set_holdings(self.eurusd, 1)
elif self.strength.current.value > 50 and self.portfolio.invested:
self.liquidate(self.eurusd)
Sample data distributed with the open-source LEAN engine.