revert: 撤销单利consumedInterest扣除(双重扣减导致1天利息变0)
单利起点InterestProfitSum已含历史累计(eod快照), 再减consumedInterest会双重扣减。复利起点是0(从头算), 减consumedInterest正确。两者计算结构不同不能套用。 正确方向:让InterestProfitSum在互换结清后归零(eod层方案B), 而非在计算时减consumedInterest。待重新设计单利修复方案。 测试还原为红灯(Assert redCount>0),注释更新说明正确方向。
This commit is contained in:
@@ -433,8 +433,10 @@ namespace YLErp.Modules.SwapModule
|
||||
else
|
||||
{
|
||||
// 盘中互换场景,使用 CalcUnwindInterest
|
||||
// 取历史已结利息(事件级,互换当时落库),供单利/复利重算时扣除已通过互换结出的利息,避免重复计入
|
||||
var consumedInterest = GetConsumedInterest(td.id, position.id, endDate);
|
||||
// 取历史已结利息(事件级,互换当时落库),供复利重算扣除(仅复利需要;单利基于日终快照自带状态)
|
||||
var consumedInterest = position.InterestType == (int)InterestTypeEnum.复利
|
||||
? GetConsumedInterest(td.id, position.id, endDate)
|
||||
: 0m;
|
||||
interests.Add(CalcUnwindInterest(td, valueDate, endDate, positionClone, rate, floatRate, posiPrincipal, closePrincipal, newClosePercent, annualDays, preEodPosition, eventType, add, swap, orginPv, calcFirst, calcLast||newCalcLast, consumedInterest));
|
||||
}
|
||||
}
|
||||
@@ -702,7 +704,7 @@ namespace YLErp.Modules.SwapModule
|
||||
}
|
||||
else
|
||||
{
|
||||
CalcDailySimpleInterest(preEodPosition, endDate, position, posiNotionalValue, interest, annualDays, needPrice, floateRate, closePrecent, orginPv, calcFirst, calcLast, ref InterestAmount, ref TdInterestAmount, consumedInterest);
|
||||
CalcDailySimpleInterest(preEodPosition, endDate, position, posiNotionalValue, interest, annualDays, needPrice, floateRate, closePrecent, orginPv, calcFirst, calcLast, ref InterestAmount, ref TdInterestAmount);
|
||||
}
|
||||
|
||||
interest.InterestAmount = Math.Round(InterestAmount, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
@@ -853,10 +855,6 @@ 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