/// <summary> /// OperationId is not mandatory - but is should be there when the update was requested by a special recepient. /// </summary> public void TradingValuesUpdate(string symbol, int operationId, double time, int period, int availableBarsCount, Int64[] times, decimal[] opens, decimal[] closes, decimal[] highs, decimal[] lows, decimal[] volumes) { TracerHelper.TraceEntry(); CombinedDataSubscriptionInformation session = GetDataSession(symbol); if (session == null) { SystemMonitor.Error("Failed to find symbol session [" + symbol + "], quotes not sent."); return; } try { // History update. TimeSpan periodValue = TimeSpan.FromMinutes(period); DataHistoryUpdate update = new DataHistoryUpdate(periodValue, GenerateDataBars(periodValue, times, opens, closes, highs, lows, volumes)); update.AvailableHistorySize = availableBarsCount; DataHistoryUpdateMessage message = new DataHistoryUpdateMessage(session.SessionInformation.Info, update, true); SendToDataSubscribers(session, null, message); } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } TracerHelper.TraceExit(); }
void SendToDataSubscribers(CombinedDataSubscriptionInformation session, QuoteUpdateMessage quoteMessage, DataHistoryUpdateMessage updateMessage) { TracerHelper.TraceEntry(); lock (this) { // TODO: make sure proper subscription based filtering is applied here too. foreach (KeyValuePair <TransportInfo, DataSubscriptionInfo> pair in session.SubscriptionsUnsafe.Values) { if (quoteMessage != null && pair.Value.AcceptsUpdate(quoteMessage.Quote)) { TracerHelper.Trace("Sending [" + quoteMessage.GetType().Name + "] to [" + pair.Key.OriginalSenderId.Value.Id.Name + "]."); SendResponding(pair.Key, quoteMessage); } if (updateMessage != null && pair.Value.AcceptsUpdate(updateMessage.Update)) { TracerHelper.Trace("Sending [" + updateMessage.GetType().Name + "] to [" + pair.Key.OriginalSenderId.Value.Id.Name + "]."); SendResponding(pair.Key, updateMessage); } } } }