private void L1OnSystemMsg(IQMessageArgs args) { var systemMessage = args.Message; switch (systemMessage) { case L1SystemMsg.SERVER_CONNECTED: ChangeConnectionStatus(ConnectionStatus.Connected); break; case L1SystemMsg.SERVER_DISCONNECTED: ChangeConnectionStatus(ConnectionStatus.Disconnected); break; case L1SystemMsg.SYMBOL_LIMIT_REACHED: OnMessageReceived(new ErrorMessage { Message = systemMessage }); break; default: if (systemMessage.StartsWith(L1SystemMsg.CURRENT_UPDATE_FIELDNAMES)) { fieldIndex.UpdateFromL1SystemMsg(args); ChangeConnectionStatus(ConnectionStatus.Connected); } break; } }
private void L1OnErrorMsg(IQMessageArgs args) { OnMessageReceived(new ErrorMessage { Message = args.Message }); ChangeConnectionStatus(ConnectionStatus.Disconnected); }
private void HistoryOnHistoryMsg(IQMessageArgs args) { HistoryRequest request; using (historyRequestsLock.Lock()) { if (!historyRequests.TryGetValue(args.RequestId, out request)) { return; } } HistoryMsg mgs; HistoryMsg.Parse(args, request.Span, out mgs); request.AddPoint(new HistoryDataPoint( mgs.Time, mgs.High, mgs.Low, mgs.Open, mgs.Close, mgs.Volume, mgs.OpenInterest)); }
private void L1OnFundamentalMsg(IQMessageArgs args) { L1FundamentalMsg msg; L1FundamentalMsg.Parse(args, out msg); InstrumentSubscription subscription; using (instrumentSubscriptionsLock.Lock()) { if (!instrumentSubscriptionsByCode.TryGetValue(msg.Symbol, out subscription)) { return; } } switch (subscription.SecurityType) { case SecurityType.FUTURE: case SecurityType.FOPTION: break; default: subscription.InstrumentParams.PriceStepValue = subscription.InstrumentParams.PriceStep; break; } var shouldTransmit = subscription.Update(ref msg); if (shouldTransmit) { OnMessageReceived(subscription.InstrumentParams); } }
private void L1OnSubscriptionErrorMsg(IQMessageArgs args) { // args.RequestId /* * TODO * InstrumentSubscription subscription; * using (instrumentSubscriptionsLock.Lock()) * { * if(!instrumentSubscriptionsByCode.TryGetValue(args.Message, out subscription)) * { * return; * } * * if (instrumentSubscriptionsByCode.TryGetValue(args.RequestId, out subscription)) * { * instrumentSubscriptionsByCode.Remove(subscription.Code); * instrumentSubscriptionsByInstrument.Remove(instrument); * } * } * * subscription.TrySetResult( * new SubscriptionResult(subscription.Instrument, false, string.Format("Can't subscribe \"{0}\"", args.Message)) * );*/ }
private bool SymbolLookupOnResultMsg(IQMessageArgs args) { SymbolLookupRequest operation; using (symbolLookupRequestsLock.Lock()) { if (!symbolLookupRequests.TryGetValue(args.RequestId, out operation)) { return(false); } } bool isCompleted; operation.Handle(args, out isCompleted); if (isCompleted) { using (symbolLookupRequestsLock.Lock()) { symbolLookupRequests.Remove(args.RequestId); } } return(true); }
protected static void RaiseEvent(ProcessMessageDelegate handler, IQMessageArgs args) { if (handler != null) { handler(args); } }
private void LookupOnSecurityTypeMsg(IQMessageArgs args) { var isCompleted = securityTypeIndex.UpdateFromSecurityTypeMsg(args); if (isCompleted) { securityTypeIndexCompleted.TrySetResult(true); } }
private void LookupOnErrorMsg(IQMessageArgs args) { if (SubscriptionTestOnErrorMsg(args)) { return; } if (SymbolLookupOnErrorMsg(args)) { return; } Logger.Trace().PrintFormat("Message LOOKUP.{0} wasn't handled. request_id={1}", args.Message, args.RequestId); }
private void HistoryOnHistoryEndMsg(IQMessageArgs args) { HistoryRequest request; using (historyRequestsLock.Lock()) { if (!historyRequests.TryGetValue(args.RequestId, out request)) { return; } historyRequests.Remove(args.RequestId); } request.Complete(); }
private bool SymbolLookupOnErrorMsg(IQMessageArgs args) { SymbolLookupRequest operation; using (symbolLookupRequestsLock.Lock()) { if (!symbolLookupRequests.TryGetValue(args.RequestId, out operation)) { return(false); } symbolLookupRequests.Remove(args.RequestId); } operation.Fail(args); return(true); }
private bool SubscriptionTestOnErrorMsg(IQMessageArgs args) { SubscriptionTest operation; using (subscriptionTestsLock.Lock()) { if (!subscriptionTests.TryGetValue(args.RequestId, out operation)) { return(false); } subscriptionTests.Remove(args.RequestId); } operation.Message = args.Message; operation.TrySetResult(false); Logger.Warn().PrintFormat("Unable to find {0} {1} due to error {2}", operation.Type, operation.Code, args.Message); return(true); }
private bool SubscriptionTestOnResultMsg(IQMessageArgs args) { SubscriptionTest operation; using (subscriptionTestsLock.Lock()) { if (!subscriptionTests.TryGetValue(args.RequestId, out operation)) { return(false); } subscriptionTests.Remove(args.RequestId); } var passed = args.Message.Split(',')[0] == operation.Code; operation.Message = args.Message; operation.TrySetResult(passed); Logger.Debug().PrintFormat("{0} {1} is found ({2})", operation.Type, operation.Code, args.Message); return(true); }
public void Handle(IQMessageArgs args, out bool isCompleted) { var parts = args.Message.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length < 2) { TrySetResult(codes.ToArray()); isCompleted = true; return; } codes.Add(parts[0]); isCompleted = false; if (maxResults != null && codes.Count >= maxResults.Value) { // Если установлен лимит на число результатов, то прерываемся преждевременно // Все последующие сообщения будут проигнорированы. // Увы, мощный API не позволяет задать макс. число результатов в запросе. TrySetResult(codes.ToArray()); isCompleted = true; } }
private void L1OnUpdateMsg(IQMessageArgs args) { if (!L1UpdateMsg.TryParse(args, fieldIndex, out var msg)) { return; } InstrumentSubscription subscription; using (instrumentSubscriptionsLock.Lock()) { if (!instrumentSubscriptionsByCode.TryGetValue(msg.Symbol, out subscription)) { return; } } var shouldTransmit = subscription.Update(ref msg); if (shouldTransmit) { OnMessageReceived(subscription.InstrumentParams); } }
private void HistoryOnErrorMsg(IQMessageArgs args) { HistoryRequest request; using (historyRequestsLock.Lock()) { if (!historyRequests.TryGetValue(args.RequestId, out request)) { return; } historyRequests.Remove(args.RequestId); } var message = args.Message.Trim(',', '\r', '\n'); if (message == "!NO_DATA!") { request.NoData(); } else { request.Fail(message); } }
public void Fail(IQMessageArgs args) { TrySetCanceled(); }
protected void RaiseError(IQMessageArgs args) { RaiseEvent(OnErrorMsg, args); }