internal void SetQuotation(QuotationsMessage message) { foreach (GeneralQuotation generalQuotation in message.Quotations) { VmInstrument vmInstrument = this._Instruments.SingleOrDefault(i => i.Id == generalQuotation.InstrumentId); if (vmInstrument != null) { vmInstrument.SetQuotation(generalQuotation, vmInstrument.DecimalPlace); } } }
public void Initialize() { try { //if (this._MetadataNotLoaded) //{ ConfigMetadata metadata = ConsoleClient.Instance.GetConfigMetadata(); this._QuotationSources.Clear(); foreach (var source in metadata.QuotationSources.Values) { this._QuotationSources.Add(new VmQuotationSource(source)); } this._Instruments.Clear(); foreach (var instrument in metadata.Instruments.Values) { VmInstrument vmInstrument = new VmInstrument(instrument); if (instrument.IsDerivative) { vmInstrument.VmDerivativeRelation = new VmDerivativeRelation(metadata.DerivativeRelations[instrument.Id]); } else { foreach (Dictionary <string, InstrumentSourceRelation> dict in metadata.InstrumentSourceRelations.Values) { var relation = dict.Values.SingleOrDefault(r => r.InstrumentId == instrument.Id); if (relation != null) { VmQuotationSource vmQuotationSource = this._QuotationSources.Single(s => s.Id == relation.SourceId); vmInstrument.SourceRelations.Add(new VmInstrumentSourceRelation(relation, vmInstrument, vmQuotationSource)); } } if (!instrument.IsDerivative) { vmInstrument.VmPriceRangeCheckRule = new VmPriceRangeCheckRule(metadata.PriceRangeCheckRules[instrument.Id]); if (metadata.WeightedPriceRules.ContainsKey(instrument.Id)) { vmInstrument.VmWeightedPriceRule = new VmWeightedPriceRule(metadata.WeightedPriceRules[instrument.Id]); } else { vmInstrument.VmWeightedPriceRule = new VmWeightedPriceRule(new WeightedPriceRule()); } } } // set quotation GeneralQuotation generalQuotation; if (metadata.LastQuotations.TryGetValue(instrument.Id, out generalQuotation)) { vmInstrument.SetQuotation(generalQuotation, vmInstrument.DecimalPlace); } this._Instruments.Add(vmInstrument); //} //this._MetadataNotLoaded = false; } } catch (Exception exception) { Logger.TraceEvent(TraceEventType.Error, "VmQuotationManager.LoadMetadata\r\n{0}", exception); } }
public void Initialize() { try { //if (this._MetadataNotLoaded) //{ ConfigMetadata metadata = ConsoleClient.Instance.GetConfigMetadata(); this._QuotationSources.Clear(); foreach (var source in metadata.QuotationSources.Values) { this._QuotationSources.Add(new VmQuotationSource(source)); } this._Instruments.Clear(); foreach (var instrument in metadata.Instruments.Values) { VmInstrument vmInstrument = new VmInstrument(instrument); if (instrument.IsDerivative) { vmInstrument.VmDerivativeRelation = new VmDerivativeRelation(metadata.DerivativeRelations[instrument.Id]); } else { foreach (Dictionary<string, InstrumentSourceRelation> dict in metadata.InstrumentSourceRelations.Values) { var relation = dict.Values.SingleOrDefault(r => r.InstrumentId == instrument.Id); if (relation != null) { VmQuotationSource vmQuotationSource = this._QuotationSources.Single(s => s.Id == relation.SourceId); vmInstrument.SourceRelations.Add(new VmInstrumentSourceRelation(relation, vmInstrument, vmQuotationSource)); } } if (!instrument.IsDerivative) { vmInstrument.VmPriceRangeCheckRule = new VmPriceRangeCheckRule(metadata.PriceRangeCheckRules[instrument.Id]); if (metadata.WeightedPriceRules.ContainsKey(instrument.Id)) { vmInstrument.VmWeightedPriceRule = new VmWeightedPriceRule(metadata.WeightedPriceRules[instrument.Id]); } else { vmInstrument.VmWeightedPriceRule = new VmWeightedPriceRule(new WeightedPriceRule()); } } } // set quotation GeneralQuotation generalQuotation; if (metadata.LastQuotations.TryGetValue(instrument.Id, out generalQuotation)) { vmInstrument.SetQuotation(generalQuotation, vmInstrument.DecimalPlace); } this._Instruments.Add(vmInstrument); //} //this._MetadataNotLoaded = false; } } catch(Exception exception) { Logger.TraceEvent(TraceEventType.Error, "VmQuotationManager.LoadMetadata\r\n{0}", exception); } }