public void Subscribe(Data.MarketData marketData) { Asset asset = GetPxAsset(marketData.Instrument); if (asset == null) { LogEventArgs.ProcessEventArgs(new LogEventArgs(string.Format("{0}: Failed to subscribe to instrument '{1}': empty symbol map", m_NTconnection.Options.Name, marketData.Instrument.FullName), NinjaTrader.Cbi.LogLevel.Error, LogCategory.Connection)); return; } if (m_subscriptions.ContainsKey(asset.ExchangeCode)) { return; } m_subscriptions.Add(asset.ExchangeCode, marketData); // If this is the first time subscribe for quotes if (m_subscriptions.Count == 1) { m_pxConnector.Send(pxNetAdapter.Request.MarketData.SubscribeForQuotes(m_token, m_userInfo.GUID), res => { if (res.Error != null && !string.IsNullOrEmpty(res.Error.Code)) { LogEventArgs.ProcessEventArgs(new LogEventArgs("Unable to subscribe to L1 data for instrument '" + marketData.Instrument.FullName + "': " + res.Error.Message, NinjaTrader.Cbi.LogLevel.Error)); } }); } }
public void Unsubscribe(Data.MarketData marketData) { string symbol = marketData.Instrument.MasterInstrument.GetProviderName(NinjaTrader.Cbi.Provider.Provider10).TrimStart(new char[] { '@' }); if (m_subscriptions.ContainsKey(symbol)) { m_subscriptions.Remove(symbol); } }