Ejemplo n.º 1
0
        internal void Merge(OverridedQ overridedQuotation)
        {
            if (this.High.IsEmpty || decimal.Parse(overridedQuotation.Bid) >= decimal.Parse(this.High.OverridedQuotation.Bid))
            {
                if (!this.High.IsEmpty && this.Low.IsEmpty)
                {
                    this.Low = new QuotationPair(this.High);
                }

                this.High = new QuotationPair(overridedQuotation);
                if (!this.Last.IsEmpty && overridedQuotation.Timestamp >= this.Last.OverridedQuotation.Timestamp)
                {
                    this.Last = QuotationPair.Empty;
                }
            }
            else if (this.Low.IsEmpty || decimal.Parse(overridedQuotation.Bid) <= decimal.Parse(this.Low.OverridedQuotation.Bid))
            {
                this.Low = new QuotationPair(overridedQuotation);
                if (!this.Last.IsEmpty && overridedQuotation.Timestamp >= this.Last.OverridedQuotation.Timestamp)
                {
                    this.Last = QuotationPair.Empty;
                }
            }
            else if (this.Last.IsEmpty || overridedQuotation.Timestamp >= this.Last.OverridedQuotation.Timestamp)
            {
                this.Last = new QuotationPair(overridedQuotation);
            }
        }
Ejemplo n.º 2
0
        internal QuotationPair Fetch()
        {
            QuotationPair result = QuotationPair.Empty;

            if (!this.High.IsEmpty)
            {
                if (this.Low.IsEmpty || this.High.OverridedQuotation.Timestamp < this.Low.OverridedQuotation.Timestamp)
                {
                    result    = this.High;
                    this.High = QuotationPair.Empty;
                }
                else
                {
                    result   = this.Low;
                    this.Low = QuotationPair.Empty;
                }
            }
            else if (!this.Low.IsEmpty)
            {
                result   = this.Low;
                this.Low = QuotationPair.Empty;
            }
            else if (!this.Last.IsEmpty)
            {
                result    = this.Last;
                this.Last = QuotationPair.Empty;
            }

            return(result);
        }
Ejemplo n.º 3
0
        internal OverridedQ[] MergeAndGetQuotationToBroadcast(Queue <OverridedQ[]> pendingQuotations)
        {
            if (pendingQuotations.Count > 0)
            {
                foreach (OverridedQ[] pendingQuotation in pendingQuotations)
                {
                    if (pendingQuotation == null)
                    {
                        continue;
                    }

                    foreach (OverridedQ overridedQuotation in pendingQuotation)
                    {
                        if (string.IsNullOrEmpty(overridedQuotation.Ask) || string.IsNullOrEmpty(overridedQuotation.Bid))
                        {
                            continue;
                        }

                        InstrumentQuotePolicyKey mergedQuotationKey = new InstrumentQuotePolicyKey(overridedQuotation.InstrumentID, overridedQuotation.QuotePolicyID);

                        MergedQuotation mergedQuotation = null;
                        if (!this.mergedQuotaions.TryGetValue(mergedQuotationKey, out mergedQuotation))
                        {
                            mergedQuotation = new MergedQuotation(overridedQuotation.InstrumentID, overridedQuotation.QuotePolicyID);
                            this.mergedQuotaions.Add(mergedQuotationKey, mergedQuotation);
                        }
                        mergedQuotation.Merge(overridedQuotation);
                    }
                }
            }

            List <OverridedQ> overridedQuotations = null;

            foreach (MergedQuotation mergedQuotation in this.mergedQuotaions.Values)
            {
                QuotationPair pair = mergedQuotation.Fetch();
                if (!pair.IsEmpty)
                {
                    if (overridedQuotations == null)
                    {
                        overridedQuotations = new List <OverridedQ>();
                    }
                    overridedQuotations.Add(pair.OverridedQuotation);
                }
            }
            return(overridedQuotations.ToArray());
        }
Ejemplo n.º 4
0
 internal QuotationPair(QuotationPair pair)
 {
     _quotation = pair.OverridedQuotation;
 }