Esempio n. 1
0
        public Instrument(XmlNode instrument)
        {
            this.id = XmlConvert.ToGuid(instrument.Attributes["ID"].Value);
            this.originCode = instrument.Attributes["OriginCode"].Value;
            this.code = instrument.Attributes["Code"].Value;
            this.numeratorUnit = XmlConvert.ToInt32(instrument.Attributes["NumeratorUnit"].Value);
            this.denominator = XmlConvert.ToInt32(instrument.Attributes["Denominator"].Value);
            this.isSinglePrice = XmlConvert.ToBoolean(instrument.Attributes["IsSinglePrice"].Value);
            this.originType = (OriginType)XmlConvert.ToByte(instrument.Attributes["OriginType"].Value);
            this.alertVariation = XmlConvert.ToInt32(instrument.Attributes["AlertVariation"].Value);
            this.normalWaitTime = XmlConvert.ToInt32(instrument.Attributes["NormalWaitTime"].Value);
            this.alertWaitTime = XmlConvert.ToInt32(instrument.Attributes["AlertWaitTime"].Value);
            this.isActive = XmlConvert.ToBoolean(instrument.Attributes["IsActive"].Value);

            this.originInactiveTime = XmlConvert.ToInt32(instrument.Attributes["OriginInactiveTime"].Value);
            this.isPriceEnabled = XmlConvert.ToBoolean(instrument.Attributes["IsPriceEnabled"].Value);
            this.isAutoEnablePrice = XmlConvert.ToBoolean(instrument.Attributes["IsAutoEnablePrice"].Value);
            if (instrument.Attributes["ExternalExchangeCode"] != null)
            {
                this.exchangeSystem = (ExchangeSystem)Enum.Parse(typeof(ExchangeSystem), instrument.Attributes["ExternalExchangeCode"].Value);
            }
            this.lastPriceEnabledTime = this.isPriceEnabled ? DateTime.Now : DateTime.MinValue;

            this.originQReceived = null;
            this.originQProcessed = null;
            this.quotePolicyDetails = new ArrayList();
            this.isTrading = false;
            this.scheduleID = null;
            this.lastOrigin = null;
        }
Esempio n. 2
0
        public Instrument(DataRow instrumentRow)
        {
            this.id = (Guid)instrumentRow["ID"];
            this.code = (string)instrumentRow["Code"];
            this.originCode = (string)instrumentRow["OriginCode"];
            this.numeratorUnit = (int)instrumentRow["NumeratorUnit"];
            this.denominator = (int)instrumentRow["Denominator"];
            this.isSinglePrice = (bool)instrumentRow["IsSinglePrice"];
            this.originType = (OriginType)(byte)instrumentRow["OriginType"];
            this.alertVariation = (int)instrumentRow["AlertVariation"];
            this.normalWaitTime = (int)instrumentRow["NormalWaitTime"];
            this.alertWaitTime = (int)instrumentRow["AlertWaitTime"];
            this.isActive = (bool)instrumentRow["IsActive"];

            this.originInactiveTime = (int)instrumentRow["OriginInactiveTime"];
            this.isPriceEnabled = (bool)instrumentRow["IsPriceEnabled"];
            this.isAutoEnablePrice = (bool)instrumentRow["IsAutoEnablePrice"];
            if (instrumentRow["ExternalExchangeCode"] != DBNull.Value)
            {
                this.exchangeSystem = (ExchangeSystem)Enum.Parse(typeof(ExchangeSystem), (string)(instrumentRow["ExternalExchangeCode"]), true);
            }
            else
            {
                this.exchangeSystem = ExchangeSystem.Local;
            }
            this.lastPriceEnabledTime = this.isPriceEnabled ? DateTime.Now : DateTime.MinValue;

            this.originQReceived = null;
            this.originQProcessed = null;
            this.quotePolicyDetails = new ArrayList();
            this.isTrading = false;
            this.scheduleID = null;
            this.lastOrigin = null;
        }
        //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;
            }
        }