Пример #1
0
        public OriginQuotation(Instrument instrument, DataRow originQuotation)
        {
            this.modifyState = ModifyState.Unchanged;

            this.instrument = instrument;
            this.timestamp = (DateTime)originQuotation["Timestamp"];
            if (originQuotation["Ask"] != DBNull.Value)
            {
                this.ask = Price.CreateInstance((string)originQuotation["Ask"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (originQuotation["Bid"] != DBNull.Value)
            {
                this.bid = Price.CreateInstance((string)originQuotation["Bid"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (originQuotation["High"] != DBNull.Value)
            {
                this.high = Price.CreateInstance((string)originQuotation["High"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (originQuotation["Low"] != DBNull.Value)
            {
                this.low = Price.CreateInstance((string)originQuotation["Low"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (originQuotation.Table.Columns.Contains("Volume") && originQuotation["Volume"] != DBNull.Value)
            {
                this.volume = (string)originQuotation["Volume"];
            }
            if (originQuotation.Table.Columns.Contains("TotalVolume") && originQuotation["TotalVolume"] != DBNull.Value)
            {
                this.totalVolume = (string)originQuotation["TotalVolume"];
            }
            this.origin = instrument.CalculateOrigin(this.ask, this.bid, false);
        }
Пример #2
0
        public OriginQuotation(Instrument instrument, CollectorQuotation cq)
        {
            this.modifyState = ModifyState.Added;
            this.instrument = instrument;
            this.timestamp = cq.Timestamp;
            this.ask = Price.CreateInstance(cq.Ask, instrument.NumeratorUnit, instrument.Denominator);
            this.bid = Price.CreateInstance(cq.Bid, instrument.NumeratorUnit, instrument.Denominator);

            this.high = Price.CreateInstance(cq.High, instrument.NumeratorUnit, instrument.Denominator);
            this.low = Price.CreateInstance(cq.Low, instrument.NumeratorUnit, instrument.Denominator);

            this.volume = cq.Volume;
            this.totalVolume = cq.TotalVolume;

            this.origin = instrument.CalculateOrigin(this.ask, this.bid, instrument.OriginQReceived != null);

            //Special handle, it's not so strict
            //NOTE: Has problem for session clear !
            if (this.origin == null && instrument.OriginQReceived != null)
            {
                if (this.ask == null) this.ask = this.instrument.OriginQReceived.ask;
                if (this.bid == null) this.bid = this.instrument.OriginQReceived.bid;
                this.origin = instrument.CalculateOrigin(this.ask, this.bid, false);
            }

            this.FilterErrorHighLow(instrument, false);
        }
        public QuotePolicyDetail(Instrument instrument, DataRow quotePolicy)
        {
            this.id = (Guid)quotePolicy["QuotePolicyID"];
            this.priceType = (PriceType)(byte)quotePolicy["PriceType"];
            this.autoAdjustPoints = (int)quotePolicy["AutoAdjustPoints"];
            this.spreadPoints = (int)quotePolicy["SpreadPoints"];
            this.isOriginHiLo = (bool)quotePolicy["IsOriginHiLo"];
            this.overrideHigh = null;
            this.overrideLow = null;

            this.SetCrossRef(instrument);
        }
        public QuotePolicyDetail(Instrument instrument, XmlNode quotePolicy)
        {
            this.id = XmlConvert.ToGuid(quotePolicy.Attributes["QuotePolicyID"].Value);
            this.priceType = (PriceType)XmlConvert.ToByte(quotePolicy.Attributes["PriceType"].Value);
            this.autoAdjustPoints = XmlConvert.ToInt32(quotePolicy.Attributes["AutoAdjustPoints"].Value);
            this.spreadPoints = XmlConvert.ToInt32(quotePolicy.Attributes["SpreadPoints"].Value);
            this.isOriginHiLo = XmlConvert.ToBoolean(quotePolicy.Attributes["IsOriginHiLo"].Value);
            this.overrideHigh = null;
            this.overrideLow = null;

            this.SetCrossRef(instrument);
        }
        public OverridedQuotation(Instrument instrument, QuotePolicyDetail quotePolicy, DataRow overridedQuotation)
        {
            this.modifyState = ModifyState.Unchanged;

            this.quotePolicy = quotePolicy;
            this.instrument = instrument;
            this.timestamp = (DateTime)overridedQuotation["Timestamp"];
            if (overridedQuotation["Origin"] != DBNull.Value)
            {
                this.origin = Price.CreateInstance((string)overridedQuotation["Origin"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (overridedQuotation["Ask"] != DBNull.Value)
            {
                this.ask = Price.CreateInstance((string)overridedQuotation["Ask"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (overridedQuotation["Bid"] != DBNull.Value)
            {
                this.bid = Price.CreateInstance((string)overridedQuotation["Bid"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (overridedQuotation["High"] != DBNull.Value)
            {
                this.high = Price.CreateInstance((string)overridedQuotation["High"], instrument.NumeratorUnit, instrument.Denominator);
            }
            if (overridedQuotation["Low"] != DBNull.Value)
            {
                this.low = Price.CreateInstance((string)overridedQuotation["Low"], instrument.NumeratorUnit, instrument.Denominator);
            }

            this.dealerID = (Guid)overridedQuotation["DealerID"];

            if (overridedQuotation.Table.Columns.Contains("Volume") && overridedQuotation["Volume"] != DBNull.Value)
            {
                this.volume = (string)overridedQuotation["Volume"];
            }
            if (overridedQuotation.Table.Columns.Contains("TotalVolume") && overridedQuotation["TotalVolume"] != DBNull.Value)
            {
                this.totalVolume = (string)overridedQuotation["TotalVolume"];
            }
        }
        private void SetCrossRef(Instrument instrument)
        {
            this.instrument = instrument;

            this.instrument.QuotePolicyDetails.Add(this);
        }
        public bool Update(XmlNode quotePolicy, Instrument instrument)
        {
            this.Dispose();

            foreach (XmlAttribute attribute in quotePolicy.Attributes)
            {
                switch (attribute.Name)
                {
                    case "PriceType":
                        this.priceType = (PriceType)XmlConvert.ToInt16(attribute.Value);
                        break;
                    case "AutoAdjustPoints":
                        this.autoAdjustPoints = XmlConvert.ToInt32(attribute.Value);
                        break;
                    case "SpreadPoints":
                        this.spreadPoints = XmlConvert.ToInt32(attribute.Value);
                        break;
                    case "IsOriginHiLo":
                        this.isOriginHiLo = XmlConvert.ToBoolean(attribute.Value);
                        break;
                }
            }

            this.SetCrossRef(instrument);
            return true;
        }
Пример #8
0
 public void FilterErrorHighLow(Instrument instrument, bool useLast)
 {
     if (useLast)
     {
         if (this.high == instrument.ErrorOriginHigh) this.high = instrument.OriginHigh;
         if (this.low == instrument.ErrorOriginLow) this.low = instrument.OriginLow;
     }
     else
     {
         if (this.high == instrument.ErrorOriginHigh) this.high = null;
         if (this.low == instrument.ErrorOriginLow) this.low = null;
     }
 }
Пример #9
0
        internal iExchange.Common.OriginQuotation ToLightVersion(Instrument instrument)
        {
            iExchange.Common.OriginQuotation lightOriginQ = new iExchange.Common.OriginQuotation();
            lightOriginQ.HasWatchOnlyQuotePolicies = instrument.HasWatchOnlyQuotePolicies;
            lightOriginQ.InstrumentID = this.InstrumentID;
            lightOriginQ.Timestamp = this.timestamp;
            lightOriginQ.Ask = (string)this.origin;
            lightOriginQ.Bid = (string)this.origin;
            lightOriginQ.High = (string)this.originHigh;
            lightOriginQ.Low = (string)this.originLow;
            lightOriginQ.Origin = (string)this.origin;
            lightOriginQ.Volume = this.volume;
            lightOriginQ.TotalVolume = this.totalVolume;

            return lightOriginQ;
        }
Пример #10
0
 public void NormalizeOrigins(Instrument instrument)
 {
     this.origin = Price.CreateInstance(this.originString, instrument.NumeratorUnit, instrument.Denominator);
     this.originHigh = Price.CreateInstance(this.highString, instrument.NumeratorUnit, instrument.Denominator);
     this.originLow = Price.CreateInstance(this.lowString, instrument.NumeratorUnit, instrument.Denominator);
 }
        //Changed for emperor 2004-12-22
        public OverridedQuotation(Instrument instrument, QuotePolicyDetail quotePolicy, OriginQuotation originQuotation)
        {
            this.modifyState = ModifyState.Added;

            this.quotePolicy = quotePolicy;
            this.instrument = instrument;
            if (instrument.ExchangeSystem == ExchangeSystem.Bursa && originQuotation != null)
            {
                this.timestamp = originQuotation.Timestamp;
            }
            else
            {
                this.timestamp = DateTime.Now;
            }
            this.origin = instrument.LastOrigin;
            this.volume = instrument.LastVolume;
            this.totalVolume = instrument.LastTotalVolume;

            //this.dealerID=instrument.DealerID;
            this.dealerID = (originQuotation == null ? instrument.LastOfferDealerID : Guid.Empty);

            //Changed for emperor 2004-12-22
            if (quotePolicy.PriceType == PriceType.OriginEnable)
            {
                if (originQuotation != null) //Dealer not changed
                {
                    Price bidBase = originQuotation.Bid;
                    Price askBase = originQuotation.Ask;

                    if (instrument.OriginQProcessed != null)
                    {
                        if (bidBase == null) bidBase = instrument.OriginQProcessed.Bid;
                        if (askBase == null) askBase = instrument.OriginQProcessed.Ask;
                    }

                    if (bidBase == null)
                    {
                        bidBase = askBase;
                    }
                    else if (askBase == null)
                    {
                        askBase = bidBase;
                    }
                    else if (askBase < bidBase)
                    {
                        askBase = bidBase;
                    }

                    this.bid = bidBase + quotePolicy.AutoAdjustPoints;
                    this.ask = askBase + quotePolicy.AutoAdjustPoints;

                    this.volume = originQuotation.Volume;
                    this.totalVolume = originQuotation.TotalVolume;
                }
                else //Dealer changed
                {
                    this.bid = this.origin + quotePolicy.AutoAdjustPoints;
                    try
                    {
                        this.ask = this.bid + Math.Abs(instrument.OriginQProcessed.Ask - instrument.OriginQProcessed.Bid);
                    }
                    catch (Exception ex)
                    {
                        Manager.Common.Logger.TraceEvent(System.Diagnostics.TraceEventType.Error, "OverridedQuotation.OverridedQuotation Error\r\n{0}", ex.ToString());
                        this.ask = this.bid;
                    }
                }
                this.bid = this.bid - quotePolicy.SpreadPoints;
                this.ask = this.ask + quotePolicy.SpreadPoints;
            }
            else
            {
                this.bid = this.origin + quotePolicy.AutoAdjustPoints;
                this.ask = this.bid + quotePolicy.SpreadPoints;
            }
        }
 public OverridedQuotation(Instrument instrument, QuotePolicyDetail quotePolicy)
     : this(instrument, quotePolicy, (OriginQuotation)null)
 {
 }
        public static OverridedQuotation CreateHistoryQuotation(Guid dealerID, Instrument instrument, QuotePolicyDetail quotePolicy, string timestamp, string origin, bool needApplyAutoAdjustPoints, bool highBid, bool lowBid)
        {
            OverridedQuotation overridedQuotation = new OverridedQuotation();
            overridedQuotation.modifyState = ModifyState.Added;

            overridedQuotation.quotePolicy = quotePolicy;
            overridedQuotation.instrument = instrument;
            overridedQuotation.timestamp = DateTime.Parse(timestamp);
            overridedQuotation.origin = Price.CreateInstance(origin, instrument.NumeratorUnit, instrument.Denominator);

            overridedQuotation.dealerID = dealerID;

            overridedQuotation.bid = needApplyAutoAdjustPoints ? overridedQuotation.origin + quotePolicy.AutoAdjustPoints : overridedQuotation.origin;
            overridedQuotation.ask = overridedQuotation.bid + quotePolicy.SpreadPoints;

            overridedQuotation.CalculateHiLo(highBid, lowBid);

            //overridedQuotation.high = highBid ? overridedQuotation.bid : overridedQuotation.ask;
            //overridedQuotation.low = lowBid ? overridedQuotation.bid : overridedQuotation.ask;

            return overridedQuotation;
        }