Example #1
0
        internal void CalculateFee(ExecuteContext context)
        {
            var     setting                  = this.GetHistorySetting(context);
            var     instrument               = setting.Item1;
            var     closeTran                = this.CloseOrder.Owner;
            var     openTran                 = this.OpenOrder.Owner;
            var     currencyRate             = setting.Item5;
            var     tradePolicyDetail        = setting.Item3;
            var     specialTradePolicyDetail = setting.Item4;
            decimal contractSize             = !context.ShouldUseHistorySettings ? this.OpenOrder.Owner.ContractSize(context.TradeDay) : tradePolicyDetail.ContractSize;
            var     account                  = setting.Item2;
            decimal pairRelationFactor       = OrderRelation.PairRelationFactor;

            if (this.CloseOrder.Owner.Type == TransactionType.Pair)
            {
                pairRelationFactor = tradePolicyDetail.PairRelationFactor;
            }

            decimal commission = 0, levy = 0, otherFee = 0;

            if (this.CloseOrder.Owner.OrderType != OrderType.BinaryOption)
            {
                if (instrument.CommissionFormula.IsDependOnPL() || instrument.LevyFormula.IsDependOnPL())
                {
                    this.CalculatePL(context);
                }
                var feeParameter = new FeeParameter
                {
                    Account                  = account,
                    TradePolicyDetail        = tradePolicyDetail,
                    SpecialTradePolicyDetail = specialTradePolicyDetail,
                    Instrument               = instrument,
                    CurrencyRate             = currencyRate,
                    ContractSize             = contractSize,
                    OpenOrderExecuteTime     = openTran.ExecuteTime.Value,
                    ClosedLot                = this.ClosedLot,
                    ExecutePrice             = this.CloseOrder.ExecutePrice,
                    TradePL                  = this.TradePL,
                    Context                  = context,
                    PairRelationFactor       = pairRelationFactor
                };
                OrderRelation.CalculateFee(feeParameter, out commission, out levy, out otherFee);
            }
            this.Commission = commission;
            this.Levy       = levy;
            this.OtherFee   = otherFee;
        }
Example #2
0
 internal void AddOrderRelation(OrderRelation item, OperationType operationType)
 {
     _orderRelations.AddItem(item, operationType);
 }