Example #1
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;
         }
     }
 }
Example #2
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);
        }