예제 #1
0
        private void Update(IDBRow tradePolicyDetailRow, SpecialTradePolicy specialTradePolicy)
        {
            this.instrumentId       = (Guid)tradePolicyDetailRow["InstrumentID"];
            this.autoLimitBase      = (OrderLevelRiskBase)tradePolicyDetailRow["AutoLimitBase"];
            this.autoLimitThreshold = (decimal)tradePolicyDetailRow["AutoLimitThreshold"];
            this.autoStopBase       = (OrderLevelRiskBase)tradePolicyDetailRow["AutoStopBase"];
            this.autoStopThreshold  = (decimal)tradePolicyDetailRow["AutoStopThreshold"];

            this.isFractionCommissionOn = (bool)tradePolicyDetailRow["IsFractionCommissionOn"];
            this.commissionOpen         = (decimal)tradePolicyDetailRow["CommissionOpen"];
            this.commissionCloseD       = (decimal)tradePolicyDetailRow["CommissionCloseD"];
            this.commissionCloseO       = (decimal)tradePolicyDetailRow["CommissionCloseO"];

            this.isFractionLevyOn = (bool)tradePolicyDetailRow["IsFractionLevyOn"];
            this.levyOpen         = (decimal)tradePolicyDetailRow["LevyOpen"];
            this.levyClose        = (decimal)tradePolicyDetailRow["LevyClose"];

            this.cgseNewLevyMultipler   = (decimal)tradePolicyDetailRow["CGSENewLevyMultipler"];
            this.cgseCloseLevyMultipler = (decimal)tradePolicyDetailRow["CGSECloseLevyMultipler"];
            this.cgseNewLevyRemainder   = (decimal)tradePolicyDetailRow["CGSENewLevyRemainder"];
            this.cgseCloseLevyRemainder = (decimal)tradePolicyDetailRow["CGSECloseLevyRemainder"];
            this.cgseLevyCurrecyType    = (CGSELevyCurrecyType)Enum.ToObject(CGSELevyCurrecyType.GetType(), tradePolicyDetailRow["CGSELevyCurrecyType"]);

            specialTradePolicy.Add(this);
        }
예제 #2
0
        private static Price CalculateAutoClosePrice(Order order, PriceType priceType)
        {
            Debug.Assert(order.IsOpen);
            SpecialTradePolicyDetail policy = order.Owner.SpecialTradePolicyDetail();

            Settings.Instrument instrument = order.Owner.SettingInstrument();

            OrderLevelRiskBase autoCloseBase      = priceType == PriceType.Limit ? policy.AutoLimitBase : policy.AutoStopBase;
            decimal            autoCloseThreshold = priceType == PriceType.Limit ? policy.AutoLimitThreshold : policy.AutoStopThreshold;

            if (autoCloseBase == OrderLevelRiskBase.None)
            {
                return(null);
            }
            else if (autoCloseBase == OrderLevelRiskBase.Necessary)
            {
                return(CalculateForOrderLevelRiskNecessay(order, autoCloseThreshold, instrument, priceType));
            }
            else
            {
                Price basePrice = order.ExecutePrice;
                if (autoCloseBase == OrderLevelRiskBase.SettlementPrice)
                {
                    TradeDay tradeDay = Settings.Setting.Default.GetTradeDay();
                    if (order.Owner.ExecuteTime > tradeDay.BeginTime)
                    {
                        return(null);
                    }
                    else
                    {
                        basePrice = (order.IsBuy ? instrument.DayQuotation.Buy : instrument.DayQuotation.Sell);
                    }
                }
                int autoClosePips = (int)autoCloseThreshold;
                if (order.SetPriceMaxMovePips > 0 && order.SetPriceMaxMovePips < autoClosePips)
                {
                    autoClosePips = order.SetPriceMaxMovePips;
                }

                if (order.IsBuy == (priceType == PriceType.Limit))
                {
                    return(Price.Add(basePrice, autoClosePips, !instrument.IsNormal));
                }
                else
                {
                    return(Price.Subtract(basePrice, autoClosePips, !instrument.IsNormal));
                }
            }
        }
예제 #3
0
        internal static Price CalculateAutoClosePrice(this Order order, PriceType priceType)
        {
            Debug.Assert(order.IsOpen);
            SpecialTradePolicyDetail policy = order.Owner.SpecialTradePolicyDetail;

            Settings.Instrument instrument = order.Owner.SettingInstrument;

            OrderLevelRiskBase autoCloseBase      = priceType == PriceType.Limit ? policy.AutoLimitBase : policy.AutoStopBase;
            decimal            autoCloseThreshold = priceType == PriceType.Limit ? policy.AutoLimitThreshold : policy.AutoStopThreshold;

            if (autoCloseBase == OrderLevelRiskBase.Necessary)
            {
                return(CalculateForOrderLevelRiskNecessay(order, autoCloseThreshold, instrument, priceType));
            }
            else if (autoCloseBase == OrderLevelRiskBase.OpenPrice)
            {
                return(CalculateForOrderLevelOpenPrice(order, autoCloseThreshold, instrument, priceType));
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        private void InternalUpdate(XElement tradePolicyDetailNode, SpecialTradePolicy specialTradePolicy)
        {
            foreach (XAttribute attribute in tradePolicyDetailNode.Attributes())
            {
                switch (attribute.Name.ToString())
                {
                case "InstrumentID":
                    this.instrumentId = XmlConvert.ToGuid(attribute.Value);
                    break;

                case "AutoLimitBase":
                    this.autoLimitBase = (OrderLevelRiskBase)XmlConvert.ToInt32(attribute.Value);
                    break;

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

                case "AutoStopBase":
                    this.autoStopBase = (OrderLevelRiskBase)XmlConvert.ToInt32(attribute.Value);
                    break;

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

                case "IsFractionCommissionOn":
                    this.isFractionCommissionOn = XmlConvert.ToBoolean(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 "IsFractionLevyOn":
                    this.isFractionLevyOn = XmlConvert.ToBoolean(attribute.Value);
                    break;

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

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

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

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

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

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

                case "CGSELevyCurrecyType":
                    this.cgseLevyCurrecyType = (CGSELevyCurrecyType)XmlConvert.ToInt32(attribute.Value);
                    break;
                }
            }
        }