コード例 #1
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);
        }
コード例 #2
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);
        }