fix(swap): 修复部分平仓后复利计算问题(算头不算尾合约复利)
- 当calcLast为false时,部分平仓日终新增复利使用剩余本金计算 - 修复最终全平仓时历史终点利息计算逻辑 - 添加测试用例验证部分平仓后复利计算准确性 - 修正日终待实现利息累加时的历史终点处理方式 - 调整复利部分平仓金额计算方式,确保未平仓部分正确参与后续计算
This commit is contained in:
@@ -1415,22 +1415,21 @@ namespace YLErp.Modules.SwapModule
|
||||
? intersetAcmount
|
||||
: TdInterestAmount - lastInterestIncomeSum;
|
||||
if (!autoSwap
|
||||
&& calcLast
|
||||
&& closePercent > 0m && closePercent < 1m
|
||||
&& posiNotionalValue > 0m
|
||||
&& position.InterestType == (int)InterestTypeEnum.复利
|
||||
&& position.InterestMode == (int)InterestModeEnum.合约名义本金规模)
|
||||
{
|
||||
// 算尾的复利部分平仓:平仓金额只结算“上日待实现 * 平仓比例
|
||||
// + 已平本金当日利息”,但日终待实现必须按“上日待实现
|
||||
// + 平仓前全额本金当日利息 - 实际平仓结算”递推。
|
||||
// 通用路径的 intersetAcmount 此时基于已平本金:0007 只得到 30% 的
|
||||
// 4,088.64,会漏记剩余 70% 的 9,540.16;因此改用上日终全额复利本金,
|
||||
// 得到当日总利息 13,628.81,剩余部分才能继续参与后续复利。
|
||||
// 部分平仓日终的当日新增复利要保留未平仓本金的贡献。
|
||||
// 算尾时用平仓前全额本金;不算尾时只保留剩余本金,避免把
|
||||
// 30% 已平仓部分的当日利息再次带入后续日终。
|
||||
var fullPrincipal = lastTdInterestPrincipal > 0m
|
||||
? lastTdInterestPrincipal
|
||||
: oriPosiNotionalValue;
|
||||
newEodPayPosition.TdInterestIncome = fullPrincipal
|
||||
var accrualPrincipal = calcLast
|
||||
? fullPrincipal
|
||||
: fullPrincipal * (1m - closePercent);
|
||||
newEodPayPosition.TdInterestIncome = accrualPrincipal
|
||||
* (newEodPayPosition.TdInterestRate + newEodPayPosition.FloatRate);
|
||||
if (position.IsAnnualized)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user