/// <summary> /// When one of the data sources receives new real time data, it raises an event which is handled by this method, /// which then forwards the data over the PUB socket after serializing it. /// </summary> public void RealTimeData(object sender, RealTimeDataEventArgs e) { RaiseEvent(RealTimeDataArrived, this, e); //continuous futures aliases lock (_aliasLock) { int instrumentID = e.InstrumentID; if (_aliases.ContainsKey(instrumentID)) { for (int i = 0; i < _aliases[instrumentID].Count; i++) { e.InstrumentID = _aliases[instrumentID][i]; RaiseEvent(RealTimeDataArrived, this, e); } } } //save to local storage //perhaps just add it to a queue and then process in a different thread lock (_requestsLock) { if (_requests[e.RequestID].SaveToLocalStorage) { _localStorage.AddDataAsync( new OHLCBar { Open = e.Open, High = e.High, Low = e.Low, Close = e.Close, Volume = e.Volume, DT = MyUtils.TimestampToDateTime(e.Time) }, _requests[e.RequestID].Instrument, _requests[e.RequestID].Frequency, overwrite: false); } } #if DEBUG Log(LogLevel.Trace, string.Format("RTD Received Instrument ID: {0} O:{1} H:{2} L:{3} C:{4} V:{5} T:{6}", e.InstrumentID, e.Open, e.High, e.Low, e.Close, e.Volume, e.Time)); #endif }