Пример #1
0
        /// <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);

            //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.AddData(
                        new OHLCBar
                    {
                        Open          = e.Open,
                        High          = e.High,
                        Low           = e.Low,
                        Close         = e.Close,
                        Volume        = e.Volume,
                        DateTimeClose = MyUtils.TimestampToDateTime(e.Time)
                    },
                        requests[e.RequestID].Instrument,
                        requests[e.RequestID].Frequency);
                }
            }

#if DEBUG
            Log(LogLevel.Trace,
                $"RTD Received Instrument ID: {e.InstrumentID} O:{e.Open} H:{e.High} L:{e.Low} C:{e.Close} V:{e.Volume} T:{e.Time}");
#endif
        }
Пример #2
0
        /// <summary>
        /// Forwards a data addition request to local storage.
        /// </summary>
        public void AddData(DataAdditionRequest request)
        {
            if (request.Data.Count == 0)
            {
                Log(LogLevel.Info, string.Format("HDB: AddData called with zero bars, request: {0}", request));
                return;
            }

            lock (_localStorageLock)
            {
                _dataStorage.AddData(request.Data, request.Instrument, request.Frequency, request.Overwrite);
            }
        }
        public async Task Post([FromBody] T value)
        {
            await _storage.AddData(value);

            await _storage.SaveData();
        }