示例#1
0
文件: Booker.cs 项目: dreamsql/Outter
 internal void Add(XmlNode xmlTran)
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             foreach (XmlNode xmlOrder in xmlTran.ChildNodes)
             {
                 bool isPhysicalOrder = false;
                 PhysicalTradeSide physicalTradeSide = PhysicalTradeSide.None;
                 if (xmlOrder.Attributes["PhysicalTradeSide"] != null)
                 {
                     physicalTradeSide = (PhysicalTradeSide)(XmlConvert.ToInt32(xmlOrder.Attributes["PhysicalTradeSide"].Value));
                 }
                 isPhysicalOrder = physicalTradeSide != PhysicalTradeSide.None;
                 if (isPhysicalOrder)
                 {
                     return;
                 }
                 Guid orderID = XmlConvert.ToGuid(xmlOrder.Attributes["ID"].Value);
                 _bookWatcher.Add(orderID);
             }
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
     });
 }
示例#2
0
        private bool InternalUpdate(XElement tradePolicyDetailNode)
        {
            foreach (var attribute in tradePolicyDetailNode.Attributes())
            {
                switch (attribute.Name.ToString())
                {
                case "InstrumentID":
                    this.instrumentId = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "IsTradeActive":
                    this.isTradeActive = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "ContractSize":
                    this.contractSize = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MinCommissionOpen":
                    this.minCommissionOpen = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MinCommissionClose":
                    this.minCommissionClose = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "CommissionOpen":
                    this.commissionOpen = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "CommissionCloseD":
                    this.commissionCloseD = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "CommissionCloseO":
                    this.commissionCloseO = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "PairRelationFactor":
                    this.pairRelationFactor = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "LevyOpen":
                    this.levyOpen = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "LevyClose":
                    this.levyClose = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "OtherFeeOpen":
                    this.OtherFeeOpen = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "OtherFeeClose":
                    this.OtherFeeClose = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MarginD":
                    this.marginD = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MarginO":
                    this.marginO = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MarginLockedD":
                    this.marginLockedD = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MarginLockedO":
                    this.marginLockedO = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "RiskCredit":
                    this.riskCredit = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MarginSpot":
                    this.marginSpot = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "MarginSpotSpread":
                    this.marginSpotSpread = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "NecessaryRound":
                    this.necessaryRound = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "AlertLevel1":
                    this.alertLevel1 = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AlertLevel2":
                    this.alertLevel2 = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AlertLevel3":
                    this.alertLevel3 = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AlertLevel4":
                    this.alertLevel4 = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AlertLevel1Lock":
                    this.alertLevel1Lock = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AlertLevel2Lock":
                    this.alertLevel2Lock = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AlertLevel3Lock":
                    this.alertLevel3Lock = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AlertLevel4Lock":
                    this.alertLevel4Lock = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "IsAcceptNewStop":
                    this.isAcceptNewStop = (LimitOption)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "IsAcceptNewMOOMOC":
                    this.isAcceptNewMOOMOC = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "IsAcceptNewLimit":
                    this.isAcceptNewLimit = (LimitOption)XmlConvert.ToInt32(attribute.Value);
                    break;

                case "MultipleCloseAllowed":
                    this.multipleCloseAllowed = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "OIPercent":
                    this.oiPercent = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "AccountMaxOpenLot":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.accountMaxOpenLot = null;
                    }
                    else
                    {
                        this.accountMaxOpenLot = XmlConvert.ToDecimal(attribute.Value);
                    }
                    Logger.InfoFormat("accountMaxOpenLot = {0}, xmlValue = {1}", accountMaxOpenLot, attribute.Value);
                    break;

                case "AllowNewOCO":
                    this.allowNewOCO = XmlConvert.ToBoolean(attribute.Value);
                    break;

                case "VolumeNecessaryId":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.VolumeNecessaryId = null;
                    }
                    else
                    {
                        this.VolumeNecessaryId = XmlConvert.ToGuid(attribute.Value);
                    }
                    break;

                case "InstalmentPolicyId":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.instalmentPolicyId = null;
                    }
                    else
                    {
                        this.instalmentPolicyId = XmlConvert.ToGuid(attribute.Value);
                    }
                    break;

                case "BOPolicyID":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.binaryOptionPolicyId = null;
                    }
                    else
                    {
                        this.binaryOptionPolicyId = XmlConvert.ToGuid(attribute.Value);
                    }
                    break;

                case "PhysicalPaymentDiscountID":
                    if (string.IsNullOrEmpty(attribute.Value))
                    {
                        this.physicalPaymentDiscountId = null;
                    }
                    else
                    {
                        this.physicalPaymentDiscountId = XmlConvert.ToGuid(attribute.Value);
                    }
                    break;

                case "AllowedPhysicalTradeSides":
                    this.allowedPhysicalTradeSides = (PhysicalTradeSide)(XmlConvert.ToInt32(attribute.Value));
                    break;

                case "BuyInterestValueDay":
                    this.buyInterestValueDay = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "SellInterestValueDay":
                    this.sellInterestValueDay = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "PhysicalValueMatureDay":
                    this.frozenFundMatureDay = XmlConvert.ToInt32(attribute.Value);
                    break;

                case "DiscountOfOdd":
                    this.discountOfOdd = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "ValueDiscountAsMargin":
                    this.valueDiscountAsMargin = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "InstalmentPledgeDiscount":
                    this.instalmentPledgeDiscount = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "ShortSellDownPayment":
                    this.shortSellDownPayment = XmlConvert.ToDecimal(attribute.Value);
                    break;

                case "PartPaidPhysicalNecessary":
                    this.partPaidPhysicalNecessary = XmlConvert.ToDecimal(attribute.Value);
                    break;
                }
            }

            return(true);
        }
示例#3
0
        //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"];
        }