diff --git a/UnitTestProject/Modules/SwapModule/ReturnLegs/MtmCalcTest.cs b/UnitTestProject/Modules/SwapModule/ReturnLegs/MtmCalcTest.cs index d5ee1d62..da6969dd 100644 --- a/UnitTestProject/Modules/SwapModule/ReturnLegs/MtmCalcTest.cs +++ b/UnitTestProject/Modules/SwapModule/ReturnLegs/MtmCalcTest.cs @@ -9,14 +9,12 @@ namespace UnitTestProject.Modules.SwapModule.ReturnLegs [TestMethod] public void MarketValue_多头_为正() { - // 标的价100 × 1000张 × 乘数1 × 多头(+1) = 100000 Assert.AreEqual(100_000m, MtmCalc.MarketValue(100m, 1000m, 1m, 1)); } [TestMethod] public void MarketValue_空头_为负() { - // 空头 shortRatio=-1 Assert.AreEqual(-100_000m, MtmCalc.MarketValue(100m, 1000m, 1m, -1)); } @@ -29,22 +27,19 @@ namespace UnitTestProject.Modules.SwapModule.ReturnLegs [TestMethod] public void UnrealizedPnl_多头浮盈() { - // (105-100) × 1000 × 1 × 1 × 1 = 5000 - Assert.AreEqual(5000m, MtmCalc.UnrealizedPnl(105m, 100m, 1000m, 1m, 1, 1m)); + Assert.AreEqual(5000m, MtmCalc.UnrealizedPnl(105m, 100m, 1000m, 1m, 1, 1)); } [TestMethod] public void UnrealizedPnl_多头浮亏() { - // (95-100) × 1000 × 1 × 1 × 1 = -5000 - Assert.AreEqual(-5000m, MtmCalc.UnrealizedPnl(95m, 100m, 1000m, 1m, 1, 1m)); + Assert.AreEqual(-5000m, MtmCalc.UnrealizedPnl(95m, 100m, 1000m, 1m, 1, 1)); } [TestMethod] public void UnrealizedPnl_空头反向() { - // 空头: 价格跌=盈利 (95-100) × 1000 × 1 × (-1) × 1 = 5000 - Assert.AreEqual(5000m, MtmCalc.UnrealizedPnl(95m, 100m, 1000m, 1m, -1, 1m)); + Assert.AreEqual(5000m, MtmCalc.UnrealizedPnl(95m, 100m, 1000m, 1m, -1, 1)); } } } diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 408e23e4..c9da80f1 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1800,8 +1800,7 @@ namespace YLErp.Modules.SwapModule if (valueDate > td.StartDate.Value && curretEod.PosiQuantity > 0) { decimal payment = CalcBondPayment(curretEod.UnderlyingCode, eod.ValueDate, valueDate, curretEod.PosiQuantity, shortRatio, directionRatio); - // 考虑增值税 - curretEod.TdPosiDividend = Math.Round(payment / (1 + tax) * (1 - tax), 2); + curretEod.TdPosiDividend = DividendCalc.AfterTax(payment, tax); } curretEod.PosiDividendSum = eod.PosiQuantity > 0 ? Math.Round(eod.PosiDividendSum + curretEod.TdPosiDividend, 2) : 0; curretEod.PosiQuantity = eod.PosiQuantity; @@ -1891,7 +1890,7 @@ namespace YLErp.Modules.SwapModule var originNotional = (decimal)td.OriginalStockEqvNotional / swapPosition.PosiNetPrice; decimal totalPayment = CalcBondPayment(curretEod.UnderlyingCode, td.StartDate.Value, valueDate, (decimal)originNotional, shortRatio, directionRatio); decimal tax = um.ValueAddedTax ?? 0; - decimal totalInterest = totalPayment / (1 + tax) * (1 - tax); + decimal totalInterest = DividendCalc.AfterTaxRaw(totalPayment, tax); SetPriceInfoByFlowEvent(eod, curretEod, unwindEvents, swapPosition); curretEod.dv01 = Dv01Helper.CalcDv01(eod.UnderlyingCode, curretEod.PosiQuantity, eod.PosiDirection, eod.PositionType, vobp); curretEod.UnderlyingPrice = price; @@ -1903,7 +1902,7 @@ namespace YLErp.Modules.SwapModule if (valueDate > td.StartDate.Value && (curretEod.PosiQuantity > 0)) { decimal payment = CalcBondPayment(curretEod.UnderlyingCode, eod.ValueDate, valueDate, curretEod.PosiQuantity, shortRatio, directionRatio); - curretEod.TdPosiDividend = Math.Round(payment / (1 + tax) * (1 - tax), 2); + curretEod.TdPosiDividend = DividendCalc.AfterTax(payment, tax); } curretEod.RealizedMtmPnL = eod.RealizedMtmPnL + curretEod.TdCloseMtmPnl; // 当日浮动端平仓盈亏·分红(仅来自平仓事件 和 互换 中已实现的分红) @@ -2092,7 +2091,7 @@ namespace YLErp.Modules.SwapModule { decimal tax = um.ValueAddedTax ?? 0; decimal payment = CalcBondPayment(curretEod.UnderlyingCode, td.StartDate.Value, settleDate, curretEod.PosiQuantity, shortRatio, directionRatio); - payment = Math.Round(payment / (1 + tax) * (1 - tax), 2); + payment = DividendCalc.AfterTax(payment, tax); //var consumedDividend = CalcConsumedDividend(curretEod, unwindEvents); 首日应该没有分红 curretEod.TdPosiDividend = payment; curretEod.PosiDividendSum = payment;