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); } }
/// <summary> /// /// </summary> /// <param name="msg"></param> /// <returns></returns> public bool Update(ref L1UpdateMsg msg) { Confirm(); using (syncRoot.Lock()) { InstrumentParams.BestBidPrice = msg.BestBidPrice; InstrumentParams.BestBidQuantity = msg.BestBidQuantity; InstrumentParams.BestOfferPrice = msg.BestOfferPrice; InstrumentParams.BestOfferQuantity = msg.BestOfferQuantity; InstrumentParams.LastPrice = msg.LastPrice; InstrumentParams.Settlement = msg.Settlement; InstrumentParams.PreviousSettlement = msg.PreviousSettlement; var date = DateTime.UtcNow; if ((date - lastUpdateTime).TotalMilliseconds >= UpdateIntervalMs) { lastUpdateTime = date; return(true); } return(false); } }