public static void Main(string[] args) { var d = new Downloader(); d.Initialize("token here", "../"); var symbol = QuantConnect.Symbol.Create("JP225USD", SecurityType.Cfd, Market.Oanda); d.DownloadData(symbol, Resolution.Minute, new DateTime(2018, 1, 17, 0, 0, 0, 0, System.DateTimeKind.Utc)); }
public static void Main(string[] args) { var d = new Downloader(); d.Initialize("token here", "Data"); var tickers = new string[] { "EURCHF", "EURGBP", "EURJPY", "EURUSD", "GBPCHF", "GBPJPY", "GBPUSD", "USDCAD", "USDCHF", "USDJPY", "GBPCAD" }; Parallel.ForEach(tickers, (ticker) => { var symbol = QuantConnect.Symbol.Create(ticker, SecurityType.Forex, Market.Oanda); d.DownloadData(symbol, Resolution.Hour, new DateTime(2008, 1, 1)); }); }
/// <summary> /// Retrieves data to be used in an algorithm. /// If file does not exist, an attempt is made to download them from the api /// </summary> /// <param name="key">A string representing where the data is stored</param> /// <returns>A <see cref="Stream"/> of the data requested</returns> public Stream Fetch(string key) { if (File.Exists(key)) { if (new FileInfo(key).Length > 50) { return(new FileStream(key, FileMode.Open, FileAccess.Read)); } } // If the file cannot be found on disc, attempt to retrieve it from the API Symbol symbol; DateTime date; Resolution resolution; if (LeanDataFix.TryParsePath(key, out symbol, out date, out resolution)) { Log.Trace("OandaDataProvider.Fetch(): Attempting to get data from Oanda.com's data library for symbol({0}), resolution({1}) and date({2}).", symbol.Value, resolution, date.Date.ToShortDateString()); var downloadSuccessful = _api.DownloadData(symbol, resolution, date); if (downloadSuccessful) { Log.Trace("OandaDataProvider.Fetch(): Successfully retrieved data for symbol({0}), resolution({1}) and date({2}).", symbol.Value, resolution, date.Date.ToShortDateString()); if (new FileInfo(key).Length > 50) { return(new FileStream(key, FileMode.Open, FileAccess.Read)); } } } Log.Error("OandaDataProvider.Fetch(): Unable to remotely retrieve data for path {0}. " + "Please make sure you have the necessary data in your online Oanda data library.", key); return(null); }