Пример #1
0
 internal QuotationTrend CalculateTrend(Quotation other)
 {
     if (other.Bid == this.Bid)
     {
         return(QuotationTrend.Identical);
     }
     else if (this.Bid > other.Bid)
     {
         return(QuotationTrend.Up);
     }
     else
     {
         return(QuotationTrend.Down);
     }
 }
Пример #2
0
 internal void Merge(Quotation quotation)
 {
     if (this.Timestamp <= quotation.Timestamp)
     {
         this.Timestamp = quotation.Timestamp;
         if (quotation.Ask != null)
         {
             this.Ask = quotation.Ask;
         }
         if (quotation.Bid != null)
         {
             this.Bid = quotation.Bid;
         }
         if (quotation.High != null)
         {
             this.High = quotation.High;
         }
         if (quotation.Low != null)
         {
             this.Low = quotation.Low;
         }
     }
     else
     {
         if (this.Ask == null)
         {
             this.Ask = quotation.Ask;
         }
         if (this.Bid == null)
         {
             this.Bid = quotation.Bid;
         }
         if (this.High == null)
         {
             this.High = quotation.High;
         }
         if (this.Low == null)
         {
             this.Low = quotation.Low;
         }
     }
 }
Пример #3
0
        public static Quotation Create(Guid instrumentId, string ask, string bid,
                                       string high, string low, DateTime timestamp, Setting quotationParameterProvider)
        {
            QuotationParameter quotationParameter = quotationParameterProvider.GetQuotationParameter(instrumentId);

            if (quotationParameter == QuotationParameter.Invalid)
            {
                return(null);
            }
            Quotation quotation = new Quotation();

            quotation.IsNormal     = quotationParameter.IsNormal;
            quotation.InstrumentId = instrumentId;
            quotation.Timestamp    = timestamp;

            quotation.Ask  = CommonPrice.CreateInstance(ask, quotationParameter.Numerator, quotationParameter.Denominator);
            quotation.Bid  = CommonPrice.CreateInstance(bid, quotationParameter.Numerator, quotationParameter.Denominator);
            quotation.High = CommonPrice.CreateInstance(high, quotationParameter.Numerator, quotationParameter.Denominator);
            quotation.Low  = CommonPrice.CreateInstance(low, quotationParameter.Numerator, quotationParameter.Denominator);
            return(quotation);
        }
Пример #4
0
        private void Initialize(OverridedQ[] overridedQs)
        {
            _timeStamp = Market.MarketManager.Now;
            foreach (OverridedQ eachOverridedQuotation in overridedQs)
            {
                Quotation quotation = Quotation.Create(eachOverridedQuotation);
                if (quotation == null)
                {
                    continue;
                }
                QuotePolicy2QuotationDict quotationList;

                if (!this.TryGetValue(eachOverridedQuotation.InstrumentID, out quotationList))
                {
                    quotationList = new QuotePolicy2QuotationDict();
                    _instrument2QuotationsDict.Add(new KeyValuePair <Guid, QuotePolicy2QuotationDict>(eachOverridedQuotation.InstrumentID, quotationList));
                }
                if (quotationList.ContainsKey(eachOverridedQuotation.QuotePolicyID))
                {
                    throw new ApplicationException("Can't have more than one price for one instrument + quotepolicy in a batch of quotation");
                }
                quotationList.Add(eachOverridedQuotation.QuotePolicyID, quotation);
            }
        }
Пример #5
0
 internal static Quotation Create(OverridedQ overridedQuotation)
 {
     return(Quotation.Create(overridedQuotation.InstrumentID, overridedQuotation.Ask,
                             overridedQuotation.Bid, overridedQuotation.High, overridedQuotation.Low, overridedQuotation.Timestamp, Settings.Setting.Default));
 }
Пример #6
0
        internal bool TryGetQuotation(Guid instrumentId, IQuotePolicyProvider quotePolicyProvider, out Quotation quotation)
        {
            quotation = null;
            QuotePolicy2QuotationDict quotations = null;

            if (this.TryGetValue(instrumentId, out quotations))
            {
                quotation = quotePolicyProvider.Get <Quotation>(delegate(Guid id, out Quotation q)
                {
                    return(quotations.TryGetValue(id, out q));
                });
            }
            return(quotation != null);
        }