From 6d17e95197340846ab6d0090de0dfad845957e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E9=BA=9F=20=E7=8E=8B?= Date: Thu, 25 Jun 2026 14:33:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E7=9B=98=20=E5=88=86=E7=BA=A2?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=E4=B8=AD=E7=AE=97=E4=B8=8A?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E7=9A=84=E5=B7=B2=E5=AE=9E=E7=8E=B0=E7=9A=84?= =?UTF-8?q?=E5=88=86=E7=BA=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SwapModule/SwapEodPositionService.cs | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 98691d38..54d26754 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1,6 +1,7 @@ using BaseOUDAL; using Newtonsoft.Json; using System.Linq.Expressions; +using YLErp.DBModels; using YLErp.DBModels.Consts; using YLErp.DBModels.Enums; using YLErp.Helpers; @@ -1484,12 +1485,16 @@ namespace YLErp.Modules.SwapModule curretEod.RealizedDividend = curretEod.RealizedDividend + curretEod.TdCloseDividend; // 分红与互换解耦:持仓>0时从起始日重算待实现分红,不再受互换事件影响 + // 修改,互换事件会影响待实现的分红的,现在要算上 if (curretEod.PosiQuantity > 0) { - decimal tax = um.ValueAddedTax ?? 0; - BondPaymentService bondPaymentService = new BondPaymentService(UserInfo); - decimal totalPayment = bondPaymentService.CalcPayment(curretEod.UnderlyingCode, td.StartDate.Value, valueDate, curretEod.PosiQuantity, shortRatio, directionRatio); - curretEod.PosiDividendSum = Math.Round(totalPayment / (1 + tax) * (1 - tax), 2); + //decimal tax = um.ValueAddedTax ?? 0; + //BondPaymentService bondPaymentService = new BondPaymentService(UserInfo); + //decimal totalPayment = bondPaymentService.CalcPayment(curretEod.UnderlyingCode, td.StartDate.Value, valueDate, td.., shortRatio, directionRatio); + //var totalInterest = totalPayment / (1 + tax) * (1 - tax); + var consumedDividend = CalcConsumedDividend(curretEod, unwindEvents); + + curretEod.PosiDividendSum = eod.PosiDividendSum - consumedDividend - curretEod.TdCloseDividend; } else { @@ -1513,6 +1518,21 @@ namespace YLErp.Modules.SwapModule } return curretEod; } + + private decimal CalcConsumedDividend(eod_swap_position curretEod, List events) + { + decimal consumedDividend = 0; + + List swapEventTypes = new List() { (int)SwapEventTypeEnum.互换, (int)SwapEventTypeEnum.自动互换 }; + //这里要剔除掉平仓产生的分红 + consumedDividend = events + .Where(x => x.SwapTradeId == curretEod.SwapTradeId + && swapEventTypes.Contains(x.EventType) + && x.DataState == (int)SwapFlowDateStateEnum.完成) + .Sum(s => s.DividendIn); + return consumedDividend; + } + /// /// 根据开平仓事件算价格及后付费用 /// @@ -1645,6 +1665,7 @@ namespace YLErp.Modules.SwapModule BondPaymentService bondPaymentService = new BondPaymentService(UserInfo); decimal payment = bondPaymentService.CalcPayment(curretEod.UnderlyingCode, td.StartDate.Value, settleDate, curretEod.PosiQuantity, shortRatio, directionRatio); payment = Math.Round(payment / (1 + tax) * (1 - tax), 2); + //var consumedDividend = CalcConsumedDividend(curretEod, unwindEvents); 首日应该没有分红 curretEod.TdPosiDividend = payment; curretEod.PosiDividendSum = payment; }