internal Instrument(IDBRow instrumentRow) { this._id = (Guid)instrumentRow["ID"]; this._currencyId = (Guid)instrumentRow["CurrencyID"]; this._code = (string)instrumentRow["Code"]; _originCode = instrumentRow.GetColumn <string>("OriginCode"); this._isActive = instrumentRow.GetColumn <bool>("IsActive"); this._lastAcceptTimeSpan = instrumentRow.GetColumn <int>("LastAcceptTimeSpan"); this._orderTypeMask = instrumentRow.GetColumn <int>("OrderTypeMask"); this._mit = instrumentRow.GetColumn <bool>("MIT"); this.AutoAcceptMaxLot = instrumentRow.GetColumn <decimal>("AutoAcceptMaxLot"); this.AutoCancelMaxLot = instrumentRow.GetColumn <decimal>("AutoCancelMaxLot"); this._isAutoFill = instrumentRow.GetColumn <bool>("IsAutoFill"); this._maxMinAdjust = instrumentRow.GetColumn <int>("MaxMinAdjust"); this._interestFormula = (InterestFormula)instrumentRow.GetColumn <byte>("InterestFormula"); this._interestYearDays = instrumentRow.GetColumn <int>("InterestYearDays"); this._useSettlementPriceForInterest = instrumentRow.GetColumn <bool>("UseSettlementPriceForInterest"); this.InactiveTime = instrumentRow.GetColumn <int>("OriginInactiveTime"); this._isBetterPrice = instrumentRow.GetColumn <bool>("IsBetterPrice"); this._hitTimes = instrumentRow.GetColumn <short>("HitTimes"); this._penetrationPoint = instrumentRow.GetColumn <int>("PenetrationPoint"); this._isPriceEnabled = instrumentRow.GetColumn <bool>("IsPriceEnabled"); this.SpotPaymentTime = instrumentRow.GetColumn <DateTime?>("SpotPaymentTime"); this._canPlacePendingOrderAtAnyTime = instrumentRow.GetColumn <bool>("CanPlacePendingOrderAtAnyTime"); this._allowedSpotTradeOrderSides = (AllowedOrderSides)instrumentRow.GetColumn <byte>("AllowedSpotTradeOrderSides"); this.HitPriceVariationForSTP = instrumentRow.GetColumn <int>("HitPriceVariationForSTP"); if (instrumentRow.ExistsColumn("ExternalExchangeCode")) { if (instrumentRow["ExternalExchangeCode"] != DBNull.Value) { this._exchangeSystem = (ExchangeSystem)Enum.Parse(typeof(ExchangeSystem), (string)(instrumentRow["ExternalExchangeCode"]), true); } } this.AutoDQDelay = TimeSpan.FromSeconds(instrumentRow.GetColumn <Int16>("AutoDQDelay")); this._summaryQuantity = instrumentRow.GetColumn <decimal>("SummaryQuantity"); this.PLValueDay = instrumentRow.GetColumn <Int16>("PLValueDay"); if (instrumentRow.ExistsColumn("UseAlertLevel4WhenClosed")) { this.UseAlertLevel4WhenClosed = instrumentRow["UseAlertLevel4WhenClosed"] == DBNull.Value ? false : (bool)instrumentRow["UseAlertLevel4WhenClosed"]; } if (instrumentRow.ExistsColumn("HolidayAlertDayPolicyID")) { Guid policyId = Guid.Empty; if (Guid.TryParse(instrumentRow["HolidayAlertDayPolicyID"].ToString(), out policyId)) { this.HolidayAlertDayPolicyId = policyId; } } if (instrumentRow.ExistsColumn("AcceptIfDoneVariation")) { this._acceptIfDoneVariation = instrumentRow.GetColumn <int>("AcceptIfDoneVariation"); } if (instrumentRow.Contains("PlaceSptMktTimeSpan")) { _placeSptMktTimeSpan = TimeSpan.FromSeconds((int)instrumentRow["PlaceSptMktTimeSpan"]); } if (instrumentRow.Contains("FirstOrderTime")) { _firstOrderTime = (int)instrumentRow["FirstOrderTime"]; } this.Update(instrumentRow); }
internal override void Update(XElement instrumentNode) { base.Update(instrumentNode); foreach (XAttribute attribute in instrumentNode.Attributes()) { switch (attribute.Name.ToString()) { case "ID": this._id = XmlConvert.ToGuid(attribute.Value); break; case "CurrencyID": this._currencyId = XmlConvert.ToGuid(attribute.Value); break; case "Code": this._code = attribute.Value; break; case "OriginCode": _originCode = attribute.Value; break; case "OriginInactiveTime": this.InactiveTime = XmlConvert.ToInt32(attribute.Value); break; case "Category": this._category = (InstrumentCategory)XmlConvert.ToInt32(attribute.Value); break; case "NumeratorUnit": this._numeratorUnit = XmlConvert.ToInt32(attribute.Value); break; case "Denominator": this._denominator = XmlConvert.ToInt32(attribute.Value); break; case "IsActive": this._isActive = XmlConvert.ToBoolean(attribute.Value); break; case "LastAcceptTimeSpan": this._lastAcceptTimeSpan = XmlConvert.ToInt32(attribute.Value); break; case "OrderTypeMask": this._orderTypeMask = XmlConvert.ToInt32(attribute.Value); break; case "MIT": this._mit = XmlConvert.ToBoolean(attribute.Value); break; case "AutoAcceptMaxLot": this.AutoAcceptMaxLot = XmlConvert.ToDecimal(attribute.Value); break; case "AutoCancelMaxLot": this.AutoCancelMaxLot = XmlConvert.ToDecimal(attribute.Value); break; case "IsAutoFill": this._isAutoFill = XmlConvert.ToBoolean(attribute.Value); break; case "MaxMinAdjust": this._maxMinAdjust = XmlConvert.ToInt32(attribute.Value); break; case "DayOpenTime": this.DayOpenTime = Convert.ToDateTime(attribute.Value); break; case "DayCloseTime": this.DayCloseTime = Convert.ToDateTime(attribute.Value); break; case "EndTime": _endTime = Convert.ToDateTime(attribute.Value); break; case "ValueDate": this.ValueDate = Convert.ToDateTime(attribute.Value); break; case "NextDayOpenTime": this.NextDayOpenTime = Convert.ToDateTime(attribute.Value); break; case "CommissionFormula": this._commissionFormula = (FeeFormula)XmlConvert.ToByte(attribute.Value); break; case "LevyFormula": this._levyFormula = (FeeFormula)XmlConvert.ToByte(attribute.Value); break; case "OtherFeeFormula": _otherFeeFormula = (FeeFormula)XmlConvert.ToByte(attribute.Value); break; case "MarginFormula": this._marginFormula = (MarginFormula)XmlConvert.ToByte(attribute.Value); break; case "TradePLFormula": this._tradePLFormula = (TradePLFormula)XmlConvert.ToByte(attribute.Value); break; case "InterestFormula": this._interestFormula = (InterestFormula)XmlConvert.ToByte(attribute.Value); break; case "InterestYearDays": this._interestYearDays = XmlConvert.ToInt32(attribute.Value); break; case "IsNormal": this._isNormal = XmlConvert.ToBoolean(attribute.Value); break; case "HitTimes": this._hitTimes = XmlConvert.ToInt32(attribute.Value); break; case "PenetrationPoint": this._penetrationPoint = XmlConvert.ToInt32(attribute.Value); break; case "UseSettlementPriceForInterest": this._useSettlementPriceForInterest = XmlConvert.ToBoolean(attribute.Value); break; case "CanPlacePendingOrderAtAnyTime": this._canPlacePendingOrderAtAnyTime = XmlConvert.ToBoolean(attribute.Value); break; case "AllowedSpotTradeOrderSides": this._allowedSpotTradeOrderSides = (AllowedOrderSides)XmlConvert.ToInt32(attribute.Value); break; case "PlaceSptMktTimeSpan": _placeSptMktTimeSpan = TimeSpan.FromSeconds(XmlConvert.ToInt32(attribute.Value)); break; case "HitPriceVariationForSTP": this.HitPriceVariationForSTP = XmlConvert.ToInt32(attribute.Value); break; case "AcceptIfDoneVariation": this._acceptIfDoneVariation = XmlConvert.ToInt32(attribute.Value); break; case "FirstOrderTime": _firstOrderTime = XmlConvert.ToInt32(attribute.Value); break; case "IsPriceEnabled": this._isPriceEnabled = XmlConvert.ToBoolean(attribute.Value); _priceEnableTime = DateTime.Now; break; case "AutoDQDelay": this.AutoDQDelay = TimeSpan.FromSeconds(XmlConvert.ToInt16(attribute.Value)); break; case "HolidayAlertDayPolicyID": this.HolidayAlertDayPolicyId = XmlConvert.ToGuid(attribute.Value); break; case "SummaryQuantity": this._summaryQuantity = XmlConvert.ToDecimal(attribute.Value); break; case "SpotPaymentTime": this.SpotPaymentTime = attribute.Value.Get <DateTime?>(); break; } } }