//---------- API #region public DataSourceNorgate(Dictionary<DataSourceValue, string> info) /// <summary> /// Create and initialize new data source for Norgate Data. /// </summary> /// <param name="info">info dictionary</param> public DataSourceNorgate(Dictionary <DataSourceParam, string> info) : base(info) { // make sure Norgate api is properly loaded NorgateHelpers.HandleUnresovledAssemblies(); if (info[DataSourceParam.name] == info[DataSourceParam.nickName]) { // no proper name given, try to retrieve from Norgate SetName(); } }
private void LoadData(List <Bar> data, DateTime startTime, DateTime endTime) { if (!NorgateHelpers.isAPIAvaliable) { throw new Exception(string.Format("{0}: Norgate Data Updater not installed", GetType().Name)); } //--- Norgate setup NDU.Api.SetAdjustmentType = GlobalSettings.AdjustForDividends ? NDU.AdjustmentType.TotalReturn : NDU.AdjustmentType.CapitalSpecial; NDU.Api.SetPaddingType = NDU.PaddingType.AllMarketDays; //--- run NDU as required #if false // this should work, but seems broken as of 01/09/2019 DateTime dbTimeStamp = NDU.Api.LastDatabaseUpdateTime; #else List <NDU.RecOHLC> q = new List <NDU.RecOHLC>(); NDU.Api.GetData("$SPX", out q, DateTime.Now - TimeSpan.FromDays(5), DateTime.Now + TimeSpan.FromDays(5)); DateTime dbTimeStamp = q .Select(ohlc => ohlc.Date) .OrderByDescending(d => d) .First(); #endif if (endTime > dbTimeStamp) { NorgateHelpers.RunNDU(); } //--- get data from Norgate List <NDU.RecOHLC> norgateData = new List <NDU.RecOHLC>(); NDU.OperationResult result = NDU.Api.GetData(Info[DataSourceParam.symbolNorgate], out norgateData, startTime, endTime); //--- copy to TuringTrader bars double priceMultiplier = Info.ContainsKey(DataSourceParam.dataUpdaterPriceMultiplier) ? Convert.ToDouble(Info[DataSourceParam.dataUpdaterPriceMultiplier]) : 1.0; foreach (var ohlc in norgateData) { // Norgate bars only have dates, no time. // we need to make sure that we won't return bars // outside of the requested range, as otherwise // the simulator's IsLastBar will be incorrect Bar bar = CreateBar(ohlc, priceMultiplier); if (bar.Time >= startTime && bar.Time <= endTime) { data.Add(bar); } } }
public UniverseNorgate(string nickname) { // make sure Norgate api is properly loaded NorgateHelpers.HandleUnresovledAssemblies(); if (!_watchlistNames.ContainsKey(nickname)) { throw new Exception(string.Format("{0}: no watchlist found for '{1}'", GetType().Name, nickname)); } _nickname = nickname; getWatchlist(); }