fix(swap): 单利路径扣除历史已结利息consumedInterest
复利路径已由c6adb3bb修复(加consumedInterest扣除),单利路径 CalcDailySimpleInterest未同步。互换结清后再平仓默认值偏大。 改动(SwapDealService.cs 3处): - cs:437 去掉InterestType==复利条件,单利也取GetConsumedInterest - cs:707 单利调用传入consumedInterest参数 - cs:802/856 CalcDailySimpleInterest签名加consumedInterest+末尾扣除 验证(Step1_SimpleInterestRedTest): 1813单利样本 34203偏大量8271→0✅, 34204预付金偏大量58→0✅(修正测试口径漏乘ratio) 复利回归(1889): 6-30默认值仍6.44✅无退化
This commit is contained in:
@@ -433,10 +433,8 @@ namespace YLErp.Modules.SwapModule
|
||||
else
|
||||
{
|
||||
// 盘中互换场景,使用 CalcUnwindInterest
|
||||
// 取历史已结利息(事件级,互换当时落库),供复利重算扣除(仅复利需要;单利基于日终快照自带状态)
|
||||
var consumedInterest = position.InterestType == (int)InterestTypeEnum.复利
|
||||
? GetConsumedInterest(td.id, position.id, endDate)
|
||||
: 0m;
|
||||
// 取历史已结利息(事件级,互换当时落库),供单利/复利重算时扣除已通过互换结出的利息,避免重复计入
|
||||
var consumedInterest = GetConsumedInterest(td.id, position.id, endDate);
|
||||
interests.Add(CalcUnwindInterest(td, valueDate, endDate, positionClone, rate, floatRate, posiPrincipal, closePrincipal, newClosePercent, annualDays, preEodPosition, eventType, add, swap, orginPv, calcFirst, calcLast||newCalcLast, consumedInterest));
|
||||
}
|
||||
}
|
||||
@@ -704,7 +702,7 @@ namespace YLErp.Modules.SwapModule
|
||||
}
|
||||
else
|
||||
{
|
||||
CalcDailySimpleInterest(preEodPosition, endDate, position, posiNotionalValue, interest, annualDays, needPrice, floateRate, closePrecent, orginPv, calcFirst, calcLast, ref InterestAmount, ref TdInterestAmount);
|
||||
CalcDailySimpleInterest(preEodPosition, endDate, position, posiNotionalValue, interest, annualDays, needPrice, floateRate, closePrecent, orginPv, calcFirst, calcLast, ref InterestAmount, ref TdInterestAmount, consumedInterest);
|
||||
}
|
||||
|
||||
interest.InterestAmount = Math.Round(InterestAmount, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
@@ -799,7 +797,7 @@ namespace YLErp.Modules.SwapModule
|
||||
/// <summary>
|
||||
/// 计算单利 盘中(按重置天数分段,每段使用对应浮动利率)
|
||||
/// </summary>
|
||||
public void CalcDailySimpleInterest(eod_swap_position preEodPosition, DateTime endDate, swap_position position, decimal posiPrincipal, swap_flow_event flowEvent, int annualDays, bool needPrice, decimal floateRate, decimal closePercent, decimal orginPv, bool calcFirst, bool calcLast, ref decimal InterestAmount, ref decimal TdInterestAmount)
|
||||
public void CalcDailySimpleInterest(eod_swap_position preEodPosition, DateTime endDate, swap_position position, decimal posiPrincipal, swap_flow_event flowEvent, int annualDays, bool needPrice, decimal floateRate, decimal closePercent, decimal orginPv, bool calcFirst, bool calcLast, ref decimal InterestAmount, ref decimal TdInterestAmount, decimal consumedInterest = 0m)
|
||||
{
|
||||
var startDate = position.PosiStartDate;
|
||||
decimal interestProfitSum = preEodPosition.InterestProfitSum;
|
||||
@@ -855,6 +853,10 @@ namespace YLErp.Modules.SwapModule
|
||||
tdinterest += tdinterest1;
|
||||
}
|
||||
}
|
||||
// 单利同样需扣除历史已通过互换结出的利息(与复利 cs:793 对齐),
|
||||
// 否则部分互换结清后再平仓,默认值会重复计入已实现部分。
|
||||
interest -= consumedInterest;
|
||||
tdinterest -= consumedInterest;
|
||||
InterestAmount = Math.Round(interest, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
TdInterestAmount = Math.Round(tdinterest, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user