From 1e6abb45477bbf7e2be737b73f7685633eed1247 Mon Sep 17 00:00:00 2001 From: hjhan Date: Wed, 19 Aug 2026 09:33:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor(swap):=20=E9=87=8D=E7=BD=AE=E6=97=A5?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E6=94=B6=E5=8F=A3=20IsResetDay=20=E7=A7=81?= =?UTF-8?q?=E6=9C=89=E8=B0=93=E8=AF=8D=EF=BC=88=E9=9B=B6=E8=A1=8C=E4=B8=BA?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EQD-6968 三判定之一的"是否重置日"公式原在 GetFloatRate(days%period) 与 CalcUnwindInterest 当日归周期判定(daysFromStart%rest_days) 各写一遍, 收口为单一谓词;锚点差异(td.StartDate vs position.PosiStartDate, 非初始持仓两锚点可能不同)在注释中显式注记,只收口公式不统一锚点—— 统一锚点属行为变更需业务定调。 验证:内存套件 102/102 全绿 --- YLErpDAL/Modules/SwapModule/SwapDealService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 5199d836..7fd0cc90 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -845,6 +845,15 @@ namespace YLErp.Modules.SwapModule return nextInterval?.Rate ?? position.InterestRateDefault; } + /// + /// 重置日判定:自锚点日起每 period 天一遇,锚点当日即首个重置日((日-锚点)%period==0)。 + /// EQD-6968 取价依赖三判定之一。锚点口径注记:GetFloatRate 传交易起始日 td.StartDate, + /// 分段重放/当日归周期判定传 position.PosiStartDate——非初始持仓(部分平仓剩余仓)两锚点可能不同, + /// 本方法只收口公式、不统一锚点(统一属行为变更,需业务定调)。 + /// + private static bool IsResetDay(DateTime date, DateTime anchorDate, int period) + => (date - anchorDate).Days % period == 0; + /// /// 获取浮动利率 /// @@ -853,7 +862,7 @@ namespace YLErp.Modules.SwapModule if (string.IsNullOrEmpty(position.FloatRateUnderlyingCode)) return position.FloatRate; int days = (endDate - startDate).Days; - bool isResetDay = days % period == 0; + bool isResetDay = IsResetDay(endDate, startDate, period); // 重置日恰为到期日(endDate)时,取价日=endDate;否则=startDate(原逻辑)。 DateTime rateDate = IndexFixerBase.GetFixingDate( isResetDay ? endDate : startDate, position.interest_rule); @@ -1211,12 +1220,12 @@ namespace YLErp.Modules.SwapModule var floateRate = preEodPosition.FloatRate; if (position.InterestType == (int)InterestTypeEnum.复利) { - var daysFromStart = (endDate - position.PosiStartDate).Days; var daysFromPreEod = preEodPosition.id != 0 ? (endDate - preEodPosition.ValueDate).Days : 0; // 不算尾 + 当日即新周期首日 + 未到重置日 ==> 说明这一天应归入下一个计息周期 当天无需单独计息 - if (!calcLast && daysFromPreEod == 1 && daysFromStart % (position.interest_rest_days ?? 1) != 0) + if (!calcLast && daysFromPreEod == 1 + && !IsResetDay(endDate, position.PosiStartDate, position.interest_rest_days ?? 1)) { interest.InterestPrincipal = preEodPosition.TdInterestPrincipal * closePrecent; // 计息基数 interest.FloatRate = preEodPosition.FloatRate;