public void UpdateQuote(DataSessionInfo session, Quote?quote, TimeSpan?period) { if (OperationalState != OperationalStateEnum.Operational) { SystemMonitor.OperationWarning("Stub used while not operational, operation ignored.", TracerItem.PriorityEnum.Low); return; } QuoteUpdateMessage message = new QuoteUpdateMessage(session, quote, true); CombinedDataSubscriptionInformation combined; lock (this) { combined = GetUnsafeSessionSubscriptions(session); } bool hasActiveSubscriber = false; lock (combined) { foreach (KeyValuePair <TransportInfo, DataSubscriptionInfo> pair in combined.SubscriptionsUnsafe.Values) { if (pair.Value.AcceptsUpdate(quote)) { hasActiveSubscriber = true; SendResponding(pair.Key, message); } } } SystemMonitor.CheckOperationWarning(hasActiveSubscriber, "Quote update entered for session [" + session.Guid.ToString() + "] symbol [" + session.Symbol.Name + "] and no active subscriber found."); }
/// <summary> /// Helper. /// </summary> static void CreateClientProxyInterface(MessageContainerTransportClient client) { TracerHelper.TraceEntry(); if (client._proxyServerInterface != null && client._connectingEvent.WaitOne(client._defaultConnectionTimeOut) == false) { SystemMonitor.OperationError("Timed out, since another creation is in progress."); return; } SystemMonitor.CheckOperationWarning(string.IsNullOrEmpty(client._connectionSessionID), "Session seems to be active."); client._connectingEvent.Reset(); try { IMessageContainerTransport serverInterface; DuplexChannelFactory <IMessageContainerTransport> channelFactory = null; lock (client) { if (client._proxyServerInterface != null) { ((IChannel)client._proxyServerInterface).Opened -= new EventHandler(client.MessageContainerTransportClient_Opened); ((IChannel)client._proxyServerInterface).Opening -= new EventHandler(client.MessageContainerTransportClient_Opening); ((IChannel)client._proxyServerInterface).Faulted -= new EventHandler(client.MessageContainerTransportClient_Faulted); ((IChannel)client._proxyServerInterface).Closing -= new EventHandler(client.MessageContainerTransportClient_Closing); } client._connectionSessionID = string.Empty; if (client._channelFactory == null) { return; } channelFactory = client._channelFactory; } serverInterface = channelFactory.CreateChannel(); ((IChannel)serverInterface).Opened += new EventHandler(client.MessageContainerTransportClient_Opened); ((IChannel)serverInterface).Opening += new EventHandler(client.MessageContainerTransportClient_Opening); ((IChannel)serverInterface).Faulted += new EventHandler(client.MessageContainerTransportClient_Faulted); ((IChannel)serverInterface).Closing += new EventHandler(client.MessageContainerTransportClient_Closing); lock (client) { client._proxyServerInterface = serverInterface; } ((IChannel)serverInterface).BeginOpen(TimeSpan.FromSeconds(10), BeginOpenAsyncCallback, client); //client._connectionSessionID = serverInterface.ClientRegister(); //SystemMonitor.Report("Client registered sessionID [" + client.ConnectionSessionID + "]"); //// Release this as early as possible, since it might be needed before the event is raised. //client._connectingEvent.Set(); //if (client.ConnectionStatusChangedEvent != null) //{ // GeneralHelper.FireAndForget(delegate() { client.ConnectionStatusChangedEvent(true); }); //} } catch (Exception ex) { TracerHelper.Trace("Failed to create proxy interface [" + ex.Message + "]"); } finally {// Always make sure to leave the baseMethod with a released event. //client._connectingEvent.Set(); } }
/// <summary> /// Check if given order type is buy (or sell). /// </summary> public static bool TypeIsBuy(OrderTypeEnum orderType) { SystemMonitor.CheckOperationWarning(orderType != OrderTypeEnum.UNKNOWN, "Order type not established yet."); return(orderType == OrderTypeEnum.BUY_MARKET || orderType == OrderTypeEnum.BUY_LIMIT_MARKET || orderType == OrderTypeEnum.BUY_STOP_MARKET); }