public void ProcessRequest(Security security, MarketDataMessage message, bool tryAdd) { if (security == null) { throw new ArgumentNullException(nameof(security)); } if (message == null) { throw new ArgumentNullException(nameof(message)); } if (message.TransactionId == 0) { message.TransactionId = _connector.TransactionIdGenerator.GetNextId(); } message.FillSecurityInfo(_connector, security); var value = Tuple.Create((MarketDataMessage)message.Clone(), security); if (tryAdd) { // if the message was looped back via IsBack=true _pendingSubscriptions.TryAdd(message.TransactionId, value); } else { _pendingSubscriptions.Add(message.TransactionId, value); } _connector.SendInMessage(message); }
private void ProcessSecurityMarketData(Security security, MarketDataTypes dataType, Security subscriber) { var message = new MarketDataMessage { DataType = dataType, IsSubscribe = true, //SecurityId = _connector.GetSecurityId(subscriber), TransactionId = _connector.TransactionIdGenerator.GetNextId() }; switch (dataType) { case MarketDataTypes.Trades: message.Arg = ExecutionTypes.Tick; break; case MarketDataTypes.OrderLog: message.Arg = ExecutionTypes.OrderLog; break; } message.FillSecurityInfo(_connector, subscriber); if (security == null) { message.Error = new ArgumentException(LocalizedStrings.Str692Params.Put(message.SecurityId, _connector.Name)); _connector.SendOutMessage(message); } else { _connector.SendInMessage(message); } }
/// <summary> /// To unsubscribe from getting market data by the instrument. /// </summary> /// <param name="security">The instrument by which new information getting should be started.</param> /// <param name="message">The message that contain unsubscribe info.</param> public virtual void UnSubscribeMarketData(Security security, MarketDataMessage message) { if (security == null) { throw new ArgumentNullException(nameof(security)); } if (message == null) { throw new ArgumentNullException(nameof(message)); } if (message.TransactionId == 0) { message.TransactionId = TransactionIdGenerator.GetNextId(); } message.FillSecurityInfo(this, security); _subscriptionManager.UnSubscribe(security, message); }
/// <summary> /// Initializes a new instance of the <see cref="Subscription"/>. /// </summary> /// <param name="dataType">Data type info.</param> /// <param name="security">Security.</param> public Subscription(DataType dataType, Security security) { DataType = dataType ?? throw new ArgumentNullException(nameof(dataType)); Security = security; if (dataType.IsMarketData) { MarketDataMessage = new MarketDataMessage { DataType = dataType.ToMarketDataType().Value, Arg = dataType.Arg, IsSubscribe = true }; if (Security != null) { MarketDataMessage.FillSecurityInfo(Security); } } else if (dataType == DataType.Transactions) { OrderStatusMessage = new OrderStatusMessage { IsSubscribe = true } } ; else if (dataType == DataType.PositionChanges) { PortfolioLookupMessage = new PortfolioLookupMessage { IsSubscribe = true } } ; else { throw new ArgumentOutOfRangeException(nameof(dataType), dataType, LocalizedStrings.Str1219); } }
private void SendUnSubscribeMessage(Security subscriber, MarketDataTypes type) { var msg = new MarketDataMessage { DataType = type, IsSubscribe = false, TransactionId = _connector.TransactionIdGenerator.GetNextId() }; switch (type) { case MarketDataTypes.Trades: msg.Arg = ExecutionTypes.Tick; break; case MarketDataTypes.OrderLog: msg.Arg = ExecutionTypes.OrderLog; break; } msg.FillSecurityInfo(_connector, subscriber); _connector.SendInMessage(msg); }
public void ProcessRequest(Security security, MarketDataMessage message, bool tryAdd) { if (message == null) { throw new ArgumentNullException(nameof(message)); } if (!tryAdd) { var msg = (message.IsSubscribe ? LocalizedStrings.SubscriptionSent : LocalizedStrings.UnSubscriptionSent) .Put(security?.Id, message.ToDataTypeString()); if (message.From != null && message.To != null) { msg += LocalizedStrings.Str691Params.Put(message.From.Value, message.To.Value); } _connector.AddDebugLog(msg + "."); } if (security == null) { if (!message.IsSubscribe) { if (message.OriginalTransactionId != 0) { security = TryGetSecurity(message.OriginalTransactionId); } } } if (security == null) { if (message.DataType != MarketDataTypes.News) { if (message.SecurityId.IsDefault()) { throw new ArgumentNullException(nameof(security)); } security = _connector.LookupById(message.SecurityId); if (security == null) { throw new ArgumentException(LocalizedStrings.Str704Params.Put(message.SecurityId)); } } } if (message.TransactionId == 0) { message.TransactionId = _connector.TransactionIdGenerator.GetNextId(); } if (security != null) { message.FillSecurityInfo(_connector, security); } var value = Tuple.Create((MarketDataMessage)message.Clone(), security); if (tryAdd) { // if the message was looped back via IsBack=true _requests.TryAdd(message.TransactionId, value); } else { _requests.Add(message.TransactionId, value); } _connector.SendInMessage(message); }