예제 #1
0
        internal static void CalculateFee(TradePolicyDetail tradePolicyDetail, SpecialTradePolicyDetail specialTradePolicyDetail,
                                          CurrencyRate currencyRate, DateTime tradeDayBeginTime, Settings.Account account, Settings.Instrument instrument,
                                          decimal contractSize, decimal pairRelationFactor, DateTime openOrderExecuteTime, decimal closedLot, Price executePrice,
                                          out decimal commission, out decimal levy)
        {
            bool isDayCloseRelation = openOrderExecuteTime >= tradeDayBeginTime;

            commission = pairRelationFactor * tradePolicyDetail.GetCommissionClose(isDayCloseRelation);
            levy       = tradePolicyDetail.LevyClose;

            if (specialTradePolicyDetail != null && specialTradePolicyDetail.IsFractionCommissionOn)
            {
                decimal fractionCommission = pairRelationFactor * specialTradePolicyDetail.GetCommissionClose(isDayCloseRelation);

                commission = FeeCalculator.CalculateCommission(instrument.CommissionFormula, instrument.TradePLFormula, account.RateCommission * commission, (int)closedLot, contractSize, executePrice, currencyRate)
                             + FeeCalculator.CalculateCommission(instrument.CommissionFormula, instrument.TradePLFormula, account.RateCommission * fractionCommission, closedLot - (int)closedLot, contractSize, executePrice, currencyRate);
            }
            else
            {
                commission = FeeCalculator.CalculateCommission(instrument.CommissionFormula, instrument.TradePLFormula, account.RateCommission * commission, closedLot, contractSize, executePrice, currencyRate);
            }

            if (specialTradePolicyDetail != null && specialTradePolicyDetail.IsFractionLevyOn)
            {
                decimal fractionLevy = specialTradePolicyDetail.LevyClose;

                levy = FeeCalculator.CalculateLevy(instrument.LevyFormula, instrument.TradePLFormula, account.RateLevy * levy, (int)closedLot, contractSize, executePrice, currencyRate)
                       + FeeCalculator.CalculateLevy(instrument.LevyFormula, instrument.TradePLFormula, account.RateLevy * fractionLevy, closedLot - (int)closedLot, contractSize, executePrice, currencyRate);
            }
            else
            {
                levy = FeeCalculator.CalculateLevy(instrument.LevyFormula, instrument.TradePLFormula, account.RateLevy * levy, closedLot, contractSize, executePrice, currencyRate);
            }
        }
예제 #2
0
        internal static decimal CalculateCommission(TradePolicyDetail tradePolicyDetail, SpecialTradePolicyDetail specialTradePolicyDetail,
                                                    CurrencyRate currencyRate, DateTime tradeDayBeginTime, Settings.Account account, Settings.Instrument instrument,
                                                    decimal contractSize, decimal pairRelationFactor, DateTime openOrderExecuteTime, decimal closeLot, Price closePrice)
        {
            bool    isDayCloseRelation = openOrderExecuteTime >= tradeDayBeginTime;
            decimal commission         = pairRelationFactor * tradePolicyDetail.GetCommissionClose(isDayCloseRelation);

            if (specialTradePolicyDetail != null && specialTradePolicyDetail.IsFractionCommissionOn)
            {
                decimal fractionCommission = pairRelationFactor * specialTradePolicyDetail.GetCommissionClose(isDayCloseRelation);

                commission = FeeCalculator.CalculateCommission(instrument.CommissionFormula, instrument.TradePLFormula, account.RateCommission * commission, (int)closeLot, contractSize, closePrice, currencyRate)
                             + FeeCalculator.CalculateCommission(instrument.CommissionFormula, instrument.TradePLFormula, account.RateCommission * fractionCommission, closeLot - (int)closeLot, contractSize, closePrice, currencyRate);
            }
            else
            {
                commission = FeeCalculator.CalculateCommission(instrument.CommissionFormula, instrument.TradePLFormula, account.RateCommission * commission, closeLot, contractSize, closePrice, currencyRate);
            }

            return(commission);
        }