fix(swap): 修复复利平仓时已结利息扣除计算问题

- 修改 CalcCompoundUnwind 方法添加 closePercent 参数用于部分平仓场景
- 更新复利平仓逻辑,将已结利息按平仓比例进行缩放扣除
- 添加部分平仓测试用例验证已结利息按比例扣除的正确性
- 修复了全部已结利息在部分平仓时被全额扣除的问题
This commit is contained in:
张名锐
2026-08-07 18:36:32 +08:00
parent 6b301e1ac5
commit a0be0eb003
2 changed files with 19 additions and 5 deletions
@@ -1294,9 +1294,9 @@ namespace YLErp.Modules.SwapModule
}
// 复利从头重放得到的是"假设从未结出"的整段总利息,需扣除历史已通过互换结出的利息,
// 否则已结部分会重复计息(类比分红 PosiDividendSum = totalToDate RealizedDividend)。
// consumedInterest 为绝对值口径(swap_flow_event.InterestAmount 之和),与 interest 口径一致。
interest -= consumedInterest;
tdinterest -= consumedInterest;
// consumedInterest is full-position absolute interest; scale it to this close portion.
interest -= consumedInterest * closePercent;
tdinterest -= consumedInterest * closePercent;
InterestAmount = Math.Round(interest, InterestCalculationPrecision, MidpointRounding.AwayFromZero);
TdInterestAmount = Math.Round(tdinterest, InterestCalculationPrecision, MidpointRounding.AwayFromZero);
}