/// <summary> /// /// </summary> public static DataSubscriptionInfo Combine(DataSubscriptionInfo info, bool subscribeCombine, DataSubscriptionInfo otherInfo) { if (subscribeCombine) {// Combination mode. info._tickSubscription = info._tickSubscription || otherInfo._tickSubscription; info._quoteSubscription = info._quoteSubscription || otherInfo._quoteSubscription; info._dataBarSubscriptions.AddRange(otherInfo._dataBarSubscriptions); } else {// Substraction mode. info._tickSubscription = info._tickSubscription && info._tickSubscription == false; info._quoteSubscription = info._quoteSubscription && info._quoteSubscription == false; info._dataBarSubscriptions.RemoveRange(otherInfo._dataBarSubscriptions); } return(info); }
public void SessionDataSubscriptionUpdate(DataSessionInfo session, bool subscribe, DataSubscriptionInfo? info) { }
public bool SubscribeToData(DataSessionInfo session, bool subscribe, DataSubscriptionInfo subscription) { return _sourceDataDelivery.SubscribeToData(session, subscribe, subscription); }
/// <summary> /// /// </summary> public static DataSubscriptionInfo Combine(DataSubscriptionInfo info, bool subscribeCombine, DataSubscriptionInfo otherInfo) { if (subscribeCombine) {// Combination mode. info._tickSubscription = info._tickSubscription || otherInfo._tickSubscription; info._quoteSubscription = info._quoteSubscription || otherInfo._quoteSubscription; info._dataBarSubscriptions.AddRange(otherInfo._dataBarSubscriptions); } else {// Substraction mode. info._tickSubscription = info._tickSubscription && info._tickSubscription == false; info._quoteSubscription = info._quoteSubscription && info._quoteSubscription == false; info._dataBarSubscriptions.RemoveRange(otherInfo._dataBarSubscriptions); } return info; }
/// <summary> /// /// </summary> public DataSubscriptionRequestMessage(DataSessionInfo sessionInfo, bool subscribe, DataSubscriptionInfo? info) : base(sessionInfo) { _information = info; _subscribe = subscribe; }
/// <summary> /// /// </summary> public void SessionDataSubscriptionUpdate(DataSessionInfo session, bool subscribe, DataSubscriptionInfo? info) { SystemMonitor.CheckError(session.IsEmtpy == false, "Method needs valid session info assigned to operate."); DataSourceStub dataSourceStub = DataSourceStub; if (dataSourceStub == null) { return; } CombinedDataSubscriptionInformation combined = dataSourceStub.GetUnsafeSessionSubscriptions(session); if (combined == null) { SystemMonitor.OperationError("Update on not existing session."); return; } MBTradingConnectionManager manager = _manager; if (manager == null) { return; } DataSubscriptionInfo combinedInfo = combined.GetCombinedDataSubscription(); if (combinedInfo.QuoteSubscription) { if (manager.Adapter != null) { manager.Quotes.SubscribeSymbolSession(session.Symbol, Commission.GenerateSymbolCommission(manager.Adapter, session.Symbol)); } else { SystemMonitor.OperationError("Failed to perform data subscription update, since manager adapter not assigned."); } GeneralHelper.FireAndForget(delegate() {// Run an async update of quotes. string market; Quote? quote = _manager.Quotes.GetSingleSymbolQuote(session.Symbol.Name, TimeSpan.FromSeconds(10), out market); if (quote.HasValue) { DataSourceStub.UpdateQuote(session, quote, null); } }); } else { manager.Quotes.UnSubscribeSymbolSession(session.Symbol.Name); } }
public bool SubscribeToData(DataSessionInfo session, bool subscribe, DataSubscriptionInfo info) { if (OperationalState != OperationalStateEnum.Operational) { return false; } DataSubscriptionRequestMessage request = new DataSubscriptionRequestMessage(session, subscribe, info); DataSessionResponceMessage responce = SendAndReceiveResponding<DataSessionResponceMessage>(SourceTransportInfo, request); return responce != null && responce.OperationResult; }
/// <summary> /// /// </summary> public void HandleRequest(TransportInfo transportInfo, bool subscribe, DataSubscriptionInfo? info) { if (transportInfo.OriginalSenderId.HasValue == false) { SystemMonitor.Error("Original sender not available in transport info."); return; } lock (this) { if (info.HasValue == false) { _subscriptions.Remove(transportInfo.OriginalSenderId.Value); } else { if (_subscriptions.ContainsKey(transportInfo.OriginalSenderId.Value)) { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair<TransportInfo,DataSubscriptionInfo>(transportInfo, DataSubscriptionInfo.Combine(_subscriptions[transportInfo.OriginalSenderId.Value].Value, subscribe, info.Value)); } else { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair<TransportInfo, DataSubscriptionInfo>(transportInfo, info.Value); } } } }
/// <summary> /// /// </summary> public void SessionDataSubscriptionUpdate(DataSessionInfo session, bool subscribe, DataSubscriptionInfo? info) { SystemMonitor.CheckError(session.IsEmtpy == false, "Method needs valid session info assigned to operate."); DataSourceStub dataSourceStub = _dataSourceStub; if (dataSourceStub == null) { return; } CombinedDataSubscriptionInformation combined = dataSourceStub.GetUnsafeSessionSubscriptions(session); if (combined == null) { SystemMonitor.OperationError("Update on not existing session."); return; } DataSubscriptionInfo combinedInfo = combined.GetCombinedDataSubscription(); if (combinedInfo.QuoteSubscription) { if (!_subscribedSymbols.ContainsKey(session.Symbol.Name)) { _subscribedSymbols.Add(session.Symbol.Name, session.Symbol); } } else { if (_subscribedSymbols.ContainsKey(session.Symbol.Name)) { _subscribedSymbols.Remove(session.Symbol.Name); } } }
/// <summary> /// /// </summary> public bool SubscribeToData(DataSessionInfo session, bool subscribe, DataSubscriptionInfo subscription) { return true; }