```
fix(swap): 修复复利模式下部分平仓后EOD本金计算问题 - 在复利模式部分平仓场景中确保使用计算得出的复利本金 - 添加了针对复利重置日期部分平仓的单元测试验证 - 修复了EOD本金重置逻辑,避免复利计算被错误覆盖 - 确保CloseInterestPosition执行后保留正确的复利本金值 ```
This commit is contained in:
@@ -782,6 +782,40 @@ namespace YLErp.Modules.SwapModule
|
||||
"The previous EOD identity must not be reset to a new position");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DI_COMPOUND_RESET_PARTIAL_CLOSE_UsesCalculatedPrincipal()
|
||||
{
|
||||
const decimal remainingNotional = 500m;
|
||||
const decimal compoundPrincipalAfterSevenDays = 500.958904m;
|
||||
var closeDate = StartDate.AddDays(7);
|
||||
var service = new StubEodPositionService
|
||||
{
|
||||
AutoInterests = new List<swap_flow_event>
|
||||
{
|
||||
new swap_flow_event
|
||||
{
|
||||
InterestPrincipal = compoundPrincipalAfterSevenDays,
|
||||
InterestRate = FixedRate,
|
||||
InterestAmount = 0m,
|
||||
TdInterestAmount = 0m
|
||||
}
|
||||
}
|
||||
};
|
||||
var td = CreateTrade();
|
||||
var position = CreateInterestPosition();
|
||||
position.InterestType = (int)InterestTypeEnum.复利;
|
||||
position.interest_rest_days = 7;
|
||||
var closeFlow = CreateSwapFlowEvent(closeDate, 0m);
|
||||
closeFlow.EventType = (int)SwapFlowEventTypeEnum.平仓;
|
||||
|
||||
var result = service.ExecuteSaveAutoEodWithCloseInterestPosition(
|
||||
CreatePreEod(closeDate.AddDays(-1), 0m), position, td, closeDate, null,
|
||||
remainingNotional, 0m, new List<swap_flow_event> { closeFlow }, remainingNotional, false);
|
||||
|
||||
AssertDecimal(compoundPrincipalAfterSevenDays, result.TdInterestPrincipal,
|
||||
"复利重置日部分平仓后,EOD 本金必须保留 CalcSwapInterests 计算的 7 天复利本金");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DI_MANUAL_PREPAY_PARTIAL_CLOSE_UsesHistoryPlusRemainingDailyInterest()
|
||||
{
|
||||
|
||||
@@ -1381,6 +1381,7 @@ namespace YLErp.Modules.SwapModule
|
||||
newEodPayPosition.TdInterestPrincipal = interestModes.Contains(position.InterestMode)
|
||||
? position.InterestPrincipalFix
|
||||
: position.InterestMode == (int)InterestModeEnum.标的期初全价
|
||||
&& position.InterestType != (int)InterestTypeEnum.复利
|
||||
? posiNotionalValue
|
||||
: interests.Count > 0 ? interests.First().InterestPrincipal : 0;
|
||||
if (interval != null)
|
||||
|
||||
Reference in New Issue
Block a user