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); }
//Replace has no key change, used for get settings in the past internal void Update(IDBRow tradePolicyDetailRow) { this.instrumentId = tradePolicyDetailRow.GetColumn <Guid>("InstrumentID"); this.multipleCloseAllowed = tradePolicyDetailRow.GetColumn <bool>("MultipleCloseAllowed"); //this.changePlacedOrderAllowed = (bool)tradePolicyDetailRow["ChangePlacedOrderAllowed"]; this.isTradeActive = tradePolicyDetailRow.GetColumn <bool>("IsTradeActive"); this.contractSize = tradePolicyDetailRow.GetColumn <decimal>("ContractSize"); this.minCommissionOpen = tradePolicyDetailRow.GetColumn <decimal>("MinCommissionOpen"); this.minCommissionClose = tradePolicyDetailRow.GetColumn <decimal>("MinCommissionClose"); this.commissionOpen = tradePolicyDetailRow.GetColumn <decimal>("CommissionOpen"); this.commissionCloseD = tradePolicyDetailRow.GetColumn <decimal>("CommissionCloseD"); this.commissionCloseO = tradePolicyDetailRow.GetColumn <decimal>("CommissionCloseO"); this.pairRelationFactor = tradePolicyDetailRow.GetColumn <decimal>("PairRelationFactor"); this.levyOpen = tradePolicyDetailRow.GetColumn <decimal>("LevyOpen"); this.levyClose = tradePolicyDetailRow.GetColumn <decimal>("LevyClose"); this.marginD = tradePolicyDetailRow.GetColumn <decimal>("MarginD"); this.marginO = tradePolicyDetailRow.GetColumn <decimal>("MarginO"); this.marginLockedD = tradePolicyDetailRow.GetColumn <decimal>("MarginLockedD"); this.marginLockedO = tradePolicyDetailRow.GetColumn <decimal>("MarginLockedO"); this.marginSpot = tradePolicyDetailRow.GetColumn <decimal>("MarginSpot"); this.marginSpotSpread = tradePolicyDetailRow.GetColumn <decimal>("MarginSpotSpread"); this.riskCredit = tradePolicyDetailRow.GetColumn <decimal>("RiskCredit"); this.necessaryRound = tradePolicyDetailRow.GetColumn <int>("NecessaryRound"); this.alertLevel1 = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel1"); this.alertLevel2 = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel2"); this.alertLevel3 = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel3"); this.alertLevel4 = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel4"); this.alertLevel1Lock = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel1Lock"); this.alertLevel2Lock = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel2Lock"); this.alertLevel3Lock = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel3Lock"); this.alertLevel4Lock = tradePolicyDetailRow.GetColumn <decimal>("AlertLevel4Lock"); this.isAcceptNewStop = (LimitOption)tradePolicyDetailRow.GetColumn <int>("IsAcceptNewStop"); this.isAcceptNewMOOMOC = tradePolicyDetailRow.GetColumn <bool>("IsAcceptNewMOOMOC"); this.isAcceptNewLimit = (LimitOption)tradePolicyDetailRow.GetColumn <int>("IsAcceptNewLimit"); this.oiPercent = tradePolicyDetailRow.GetColumn <decimal>("OIPercent"); if (!tradePolicyDetailRow.ExistsColumn("AccountMaxOpenLot") || tradePolicyDetailRow["AccountMaxOpenLot"] == DBNull.Value) { this.accountMaxOpenLot = null; } else { this.accountMaxOpenLot = (decimal)tradePolicyDetailRow["AccountMaxOpenLot"]; } if (tradePolicyDetailRow.ExistsColumn("AllowNewOCO")) { this.allowNewOCO = tradePolicyDetailRow.GetColumn <bool>("AllowNewOCO"); } else { this.allowNewOCO = false; } this.VolumeNecessaryId = tradePolicyDetailRow.GetColumn <Guid?>("VolumeNecessaryId"); this.instalmentPolicyId = tradePolicyDetailRow.GetColumn <Guid?>("InstalmentPolicyId"); this.physicalPaymentDiscountId = tradePolicyDetailRow["PhysicalPaymentDiscountId"] == DBNull.Value ? null : (Guid?)tradePolicyDetailRow["PhysicalPaymentDiscountId"]; if (tradePolicyDetailRow.ExistsColumn("BOPolicyID") && tradePolicyDetailRow["BOPolicyID"] != DBNull.Value) { this.binaryOptionPolicyId = (Guid?)tradePolicyDetailRow["BOPolicyID"]; } else { this.binaryOptionPolicyId = null; } this.allowedPhysicalTradeSides = (PhysicalTradeSide)tradePolicyDetailRow.GetColumn <int>("AllowedPhysicalTradeSides"); this.buyInterestValueDay = tradePolicyDetailRow.GetColumn <int>("BuyInterestValueDay"); this.sellInterestValueDay = tradePolicyDetailRow.GetColumn <int>("SellInterestValueDay"); this.frozenFundMatureDay = tradePolicyDetailRow.GetColumn <int>("PhysicalValueMatureDay"); this.discountOfOdd = tradePolicyDetailRow.GetColumn <decimal>("DiscountOfOdd"); this.valueDiscountAsMargin = tradePolicyDetailRow.GetColumn <decimal>("ValueDiscountAsMargin"); this.instalmentPledgeDiscount = tradePolicyDetailRow.GetColumn <decimal>("InstalmentPledgeDiscount"); this.shortSellDownPayment = tradePolicyDetailRow.GetColumn <decimal>("ShortSellDownPayment"); this.partPaidPhysicalNecessary = tradePolicyDetailRow.GetColumn <decimal>("PartPaidPhysicalNecessary"); this.OtherFeeClose = (decimal)tradePolicyDetailRow["OtherFeeClose"]; this.OtherFeeOpen = (decimal)tradePolicyDetailRow["OtherFeeOpen"]; this.InterestCut = (byte)tradePolicyDetailRow["InterestCut"]; }