public QuotePriceClient(QuoteMessage quoteMessage, int waitTimes, InstrumentClient instrument, Customer customer, ExchangeQuotation quotation)
        {
            this._ExchangeQuotation = quotation;
            this._Origin = quotation.Origin;
            this._CustomerClient = customer;
            this._Instrument = instrument;
            this._ExchangeCode = quoteMessage.ExchangeCode;
            this._CustomerId = quoteMessage.CustomerID;
            this._InstrumentId = quoteMessage.InstrumentID;

            this._Lot = (decimal)quoteMessage.QuoteLot;
            this._AnswerLot = this._Lot;
            this._BSStatus = (BSStatus)quoteMessage.BSStatus;
            this._BuyLot = this._BSStatus == BSStatus.Buy ? this._Lot : decimal.Zero;
            this._SellLot = this._BSStatus == BSStatus.Sell ? this._Lot : decimal.Zero;
            if (this._BSStatus == BSStatus.Both)
            {
                this._BuyLot = this._Lot;
                this._SellLot = this._Lot;
            }
            this._WaitTimes = waitTimes;
            this._TimeStamp = quoteMessage.TimeStamp;
        }
        private List<ExchangeQuotation> InitExchangeQuotation(SettingSet set)
        {
            try
            {
                List<ExchangeQuotation> quotations = new List<ExchangeQuotation>();
                foreach (Manager.Common.Settings.QuotePolicyDetail item in set.QuotePolicyDetails)
                {
                    ExchangeQuotation quotation = new ExchangeQuotation(item);
                    quotation.QuotationPolicyCode = set.QuotePolicies.SingleOrDefault(q => q.Id == item.QuotePolicyId).Code;
                    quotation.InstrumentCode = set.Instruments.SingleOrDefault(i => i.Id == item.InstrumentId).Code;
                    quotation.OriginInstrumentCode = set.Instruments.SingleOrDefault(i => i.Id == item.InstrumentId).OriginCode;
                    Manager.Common.Settings.OverridedQuotation overridedQuotation = set.OverridedQuotations.SingleOrDefault(o => o.QuotePolicyId == item.QuotePolicyId && o.InstrumentId == item.InstrumentId);
                    if (overridedQuotation != null)
                    {
                        quotation.Ask = overridedQuotation.Ask;
                        quotation.Bid = overridedQuotation.Bid;
                        quotation.High = overridedQuotation.High;
                        quotation.Low = overridedQuotation.Low;
                        quotation.Origin = overridedQuotation.Origin;
                        quotation.Timestamp = overridedQuotation.Timestamp;
                    }
                    quotations.Add(quotation);
                }

                return quotations;
            }
            catch (Exception ex)
            {
               Manager.Common.Logger.TraceEvent(System.Diagnostics.TraceEventType.Error, "InitExchangeQuotation.\r\n{0}", ex.ToString());
               return null;
            }
        }
 public static InstrumentQuotation Convert(ExchangeQuotation quote,string exchangeCode)
 {
     InstrumentQuotation instrument = new InstrumentQuotation();
     instrument.ExchangeCode = exchangeCode;
     instrument.QuotationPolicyId = quote.QuotationPolicyId;
     instrument.QuotationPolicyCode = quote.QuotationPolicyCode;
     instrument.Ask = quote.Ask;
     instrument.Bid = quote.Bid;
     instrument.High = quote.High;
     instrument.InstruemtnId = quote.InstruemtnId;
     instrument.InstrumentCode = quote.InstrumentCode;
     instrument.InstrumentOriginCode = quote.OriginInstrumentCode;
     instrument.Low = quote.Low;
     instrument.Origin = quote.Origin;
     instrument.TimeSpan = quote.Timestamp.ToShortTimeString();
     instrument.PriceType = quote.PriceType;
     instrument.AutoAdjustPoints = quote.AutoAdjustPoints1;
     instrument.AutoAdjustPoints2 = quote.AutoAdjustPoints2;
     instrument.AutoAdjustPoints3 = quote.AutoAdjustPoints3;
     instrument.AutoAdjustPoints4 = quote.AutoAdjustPoints4;
     instrument.SpreadPoints = quote.SpreadPoints1;
     instrument.SpreadPoints2 = quote.SpreadPoints2;
     instrument.SpreadPoints3 = quote.SpreadPoints3;
     instrument.SpreadPoints4 = quote.SpreadPoints4;
     instrument.MaxAuotAdjustPoints = quote.MaxAuotAdjustPoints;
     instrument.MaxSpreadPoints = quote.MaxSpreadPoints;
     instrument.IsOriginHiLo = quote.IsOriginHiLo;
     instrument.IsAutoFill = quote.IsAutoFill;
     instrument.IsPriceEnabled = quote.IsPriceEnabled;
     instrument.IsAutoEnablePrice = quote.IsAutoEnablePrice;
     instrument.OrderTypeMask = quote.OrderTypeMask;
     instrument.AcceptLmtVariation = quote.AcceptLmtVariation;
     instrument.AutoDQMaxLot = quote.AutoDQMaxLot;
     instrument.AlertVariation = quote.AlertVariation;
     instrument.DqQuoteMinLot = quote.DqQuoteMinLot;
     instrument.MaxDQLot = quote.MaxDQLot;
     instrument.NormalWaitTime = quote.NormalWaitTime;
     instrument.AlertWaitTime = quote.AlertWaitTime;
     instrument.MaxOtherLot = quote.MaxOtherLot;
     instrument.CancelLmtVariation = quote.CancelLmtVariation;
     instrument.MaxMinAdjust = quote.MaxMinAdjust;
     instrument.PenetrationPoint = quote.PenetrationPoint;
     instrument.PriceValidTime = quote.PriceValidTime;
     instrument.AutoCancelMaxLot = quote.AutoCancelMaxLot;
     instrument.AutoAcceptMaxLot = quote.AutoAcceptMaxLot;
     return instrument;
 }
        internal void UpdateOverridedQuotation(ExchangeQuotation exchangeQuotation)
        {
            if (exchangeQuotation.InstruemtnId == this.Instrument.Id)
            {
                this.PriceTrend = this.GetPriceTrend(double.Parse(exchangeQuotation.Ask), double.Parse(this.Ask));

                this.Ask = exchangeQuotation.Ask;
                this.Bid = exchangeQuotation.Bid;
                this.Origin = exchangeQuotation.Origin;
            }
        }
        internal void UpdateOverridedQuotation(ExchangeQuotation exchangeQuotation)
        {
            if (exchangeQuotation.InstruemtnId == this.Instrument.Id)
            {
                if (this.BuySell == BuySell.Buy)
                {
                    this.MarketPriceTrend = this.GetPriceTrend(double.Parse(exchangeQuotation.Ask), double.Parse(this.Ask));
                }
                else
                {
                    this.MarketPriceTrend = this.GetPriceTrend(double.Parse(exchangeQuotation.Bid), double.Parse(this.Bid));
                }

                this.Ask = exchangeQuotation.Ask;
                this.Bid = exchangeQuotation.Bid;
                this.UpdateMarketPrice(this.BuySell == BuySell.Buy);
            }
        }