Пример #1
0
 internal static Event EventFactory(Request request, bool isLastRequest)
 {
     Event result;
     if (request is HistoricalDataRequest.RequestHistoric)
     {
         result = new HistoricalDataRequest.EventHistoric((HistoricalDataRequest.RequestHistoric)request);
         result._type = isLastRequest ? EventType.RESPONSE : EventType.PARTIAL_RESPONSE;
         return result;
     }
     else if (request is ReferenceDataRequest.RequestReference)
     {
         result = new ReferenceDataRequest.EventReference((ReferenceDataRequest.RequestReference)request);
         result._type = isLastRequest ? EventType.RESPONSE : EventType.PARTIAL_RESPONSE;
         return result;
     }
     else if (request is IntradayTickRequest.RequestIntradayTick)
     {
         result = new IntradayTickRequest.EventIntradayTick((IntradayTickRequest.RequestIntradayTick)request);
         result._type = isLastRequest ? EventType.RESPONSE : EventType.PARTIAL_RESPONSE;
         return result;
     }
     else if (request is IntradayBarRequest.RequestIntradayBar)
     {
         result = new IntradayBarRequest.EventIntradayBar((IntradayBarRequest.RequestIntradayBar)request);
         result._type = isLastRequest ? EventType.RESPONSE : EventType.PARTIAL_RESPONSE;
         return result;
     }
     else
     {
         throw new NotImplementedException(string.Format("Request type {0} is not implemented", request.GetType()));
     }
 }
Пример #2
0
        public CorrelationID SendRequest(Request request, CorrelationID correlationId)
        {
            if (request is HistoricalDataRequest.RequestHistoric)
            {
                if (!((HistoricalDataRequest.RequestHistoric)request).DtStart.HasValue)
                    throw new ArgumentException("Historic requests must have start dates");
            }

            request.correlationId = correlationId;
            this._sentRequests.Enqueue(request);
            return correlationId;
        }