private void Initialize(OriginQuotation quotation) { this.Ask = quotation.Ask; this.Bid = quotation.Bid; this.DealereID = quotation.DealereID; this.FromDealer = quotation.FromDealer; this.HasWatchOnlyQuotePolicies = quotation.HasWatchOnlyQuotePolicies; this.High = quotation.High; this.InstrumentID = quotation.InstrumentID; this.IsProblematic = quotation.IsProblematic; this.Low = quotation.Low; this.Origin = quotation.Origin; this.Timestamp = quotation.Timestamp; this.TotalVolume = quotation.TotalVolume; this.Volume = quotation.Volume; }
internal void Merge(Token token, OverridedQuotation overridedQuotation, OriginQuotation originQuotation) { if (this.High.IsEmpty || decimal.Parse(overridedQuotation.Bid) >= decimal.Parse(this.High.OverridedQuotation.Bid)) { if (!this.High.IsEmpty && this.Low.IsEmpty) { this.Low.OverridedQuotation = this.High.OverridedQuotation; this.Low.OriginQuotation = this.High.OriginQuotation; this.Low.Token = this.High.Token; } this.High.OverridedQuotation = overridedQuotation; this.High.OriginQuotation = originQuotation; this.High.Token = token; if (!this.Last.IsEmpty && overridedQuotation.Timestamp >= this.Last.OverridedQuotation.Timestamp) { this.Last.Clear(); } } else if (this.Low.IsEmpty || decimal.Parse(overridedQuotation.Bid) <= decimal.Parse(this.Low.OverridedQuotation.Bid)) { this.Low.OverridedQuotation = overridedQuotation; this.Low.OriginQuotation = originQuotation; this.Low.Token = token; if (!this.Last.IsEmpty && overridedQuotation.Timestamp >= this.Last.OverridedQuotation.Timestamp) { this.Last.Clear(); } } else if (this.Last.IsEmpty || overridedQuotation.Timestamp >= this.Last.OverridedQuotation.Timestamp) { this.Last.OverridedQuotation = overridedQuotation; this.Last.OriginQuotation = originQuotation; this.Last.Token = token; } }
internal void Broadcast(Common.Token token, OriginQuotation[] originQs, OverridedQuotation[] overridedQs) { }
public void Reset(OriginQuotation quotation) { this.Initialize(quotation); }
public OriginQ(OriginQuotation quotation) { this.Initialize(quotation); }
internal QuotationForBroadcast MergeAndGetQuotationToBroadcast(Queue <QuotationForBroadcast> pendingQuotations) { if (pendingQuotations.Count > 0) { if (pendingQuotations.Count > 3) { string warning = string.Format("Too much {0} quotation wait for sending to TransactionServer", pendingQuotations.Count); AppDebug.LogEvent("StateServer.QuotationBroadcastHelper", warning, EventLogEntryType.Warning); } foreach (QuotationForBroadcast pendingQuotation in pendingQuotations) { if (pendingQuotation.OverridedQuotations == null) { continue; } foreach (OverridedQuotation overridedQuotation in pendingQuotation.OverridedQuotations) { if (string.IsNullOrEmpty(overridedQuotation.Ask) || string.IsNullOrEmpty(overridedQuotation.Bid)) { continue; } string mergedQuotationKey = overridedQuotation.InstrumentID.ToString() + overridedQuotation.QuotePolicyID.ToString(); MergedQuotation mergedQuotation = null; if (!this.mergedQuotaions.TryGetValue(mergedQuotationKey, out mergedQuotation)) { mergedQuotation = new MergedQuotation(overridedQuotation.InstrumentID, overridedQuotation.QuotePolicyID); this.mergedQuotaions.Add(mergedQuotationKey, mergedQuotation); } OriginQuotation originQuotation = null; if (pendingQuotation.OriginQuotations != null) { originQuotation = pendingQuotation.OriginQuotations.FirstOrDefault <OriginQuotation>(t => { return(t.InstrumentID == overridedQuotation.InstrumentID); }); } mergedQuotation.Merge(pendingQuotation.Token, overridedQuotation, originQuotation); } } } List <OverridedQuotation> overridedQuotations = null; List <OriginQuotation> originQuotations = null; Token token = null; foreach (MergedQuotation mergedQuotation in this.mergedQuotaions.Values) { QuotationPair pair = mergedQuotation.Fetch(); if (pair != null) { if (overridedQuotations == null) { overridedQuotations = new List <OverridedQuotation>(); } overridedQuotations.Add(pair.OverridedQuotation); if (token != null) { token = pair.Token; } if (pair.OriginQuotation != null) { if (originQuotations == null) { originQuotations = new List <OriginQuotation>(); } if (!originQuotations.Contains(pair.OriginQuotation)) { originQuotations.Add(pair.OriginQuotation); } } } } if (overridedQuotations != null) { QuotationForBroadcast result = new QuotationForBroadcast(); result.OverridedQuotations = overridedQuotations.ToArray(); result.Token = token; result.OriginQuotations = originQuotations == null ? null : originQuotations.ToArray(); return(result); } else { return(null); } }