Exemplo n.º 1
0
        private void ConnectorOnHistoricalData(object sender, EventArgs <HistoryDataResponse> args)
        {
            HistoryRequest request;

            lock (_historicalDataRequests)
            {
                if (!_historicalDataRequests.TryGetValue(args.Value.ID, out request))
                {
                    return;
                }
            }

            request.Bars.AddRange(args.Value.Bars.Select(DataConverter.ToClientBar));

            if (!args.Value.Tail)
            {
                return;
            }

            lock (_historicalDataRequests)
                _historicalDataRequests.Remove(args.Value.ID);

            OnHistoricalData?.Invoke(this, new EventArgs <string, List <Bar> >(args.Value.ID,
                                                                               request.Bars.OrderBy(bar => bar.Timestamp).ToList()));
        }
Exemplo n.º 2
0
        private void ConnectorOnError(object sender, EventArgs <string> args)
        {
            string requestId;

            lock (_historicalDataRequests)
            {
                requestId = _historicalDataRequests.Keys.FirstOrDefault(k => args.Value.Contains(k));
                if (requestId != null)
                {
                    _historicalDataRequests.Remove(requestId);
                }
            }

            if (string.IsNullOrEmpty(requestId))
            {
                return;
            }

            OnHistoricalData?.Invoke(this, new EventArgs <string, List <Bar> >(requestId, new List <Bar>()));
        }