public void Merge(AlertOverridedQuotation overridedQ) { if (this.timestamp <= overridedQ.timestamp) { this.timestamp = overridedQ.timestamp; if (overridedQ.ask != null) { this.ask = overridedQ.ask; } if (overridedQ.bid != null) { this.bid = overridedQ.bid; } if (overridedQ.high != null) { this.high = overridedQ.high; } if (overridedQ.low != null) { this.low = overridedQ.low; } } else { if (this.ask == null) { this.ask = overridedQ.ask; } if (this.bid == null) { this.bid = overridedQ.bid; } if (this.high == null) { this.high = overridedQ.high; } if (this.low == null) { this.low = overridedQ.low; } } }
private List <AlertOverridedQuotation> UpdateInstrumentQuotation(OverridedQ[] overridedQs) { List <AlertOverridedQuotation> result = new List <AlertOverridedQuotation>(); foreach (OverridedQ eachOverridedQ in overridedQs) { AlertInstrument instrument; if (!_alertInstrumentDict.TryGetValue(eachOverridedQ.InstrumentID, out instrument)) { continue; } AlertOverridedQuotation alertoverridedQ = new AlertOverridedQuotation(eachOverridedQ, instrument); if (!instrument.OverridedQuotations.ContainsKey(alertoverridedQ.QuotePolicyID)) { instrument.OverridedQuotations.Add(alertoverridedQ.QuotePolicyID, alertoverridedQ); } else { AlertOverridedQuotation overridedQuotation = instrument.OverridedQuotations[alertoverridedQ.QuotePolicyID]; if (alertoverridedQ.Timestamp < overridedQuotation.Timestamp) { continue; } else { overridedQuotation.Merge(alertoverridedQ); } } //Guids key = new Guids(overridedQ2.Instrument.Id, overridedQ2.QuotePolicyID); result.Add(alertoverridedQ); } return(result); }
internal static Quotation From(AlertOverridedQuotation overridedQuotation) { return(new Quotation(overridedQuotation.Instrument.Id, overridedQuotation.QuotePolicyID, overridedQuotation.Timestamp, overridedQuotation.Ask, overridedQuotation.Bid)); }