fix(swap): 修复预付金腿计息基数计算问题
- 在多个单元测试文件中添加InterestIncomeSum字段以保持数据一致性 - 修改GLMS20260105PartialCloseDividendBugTest测试,改进EOD快照验证逻辑 - 修复SwapDealService中预付金腿的orginPv计算逻辑,使用上一日保证金本金作为基准 - 更新SwapPositionComposeScenarioTest中的测试数据结构和利率设置 - 修正平仓日利息计算精度问题,使用Math.Round确保计算准确性
This commit is contained in:
@@ -85,13 +85,10 @@ namespace YLErp.Modules.SwapModule
|
||||
List<swap_flow_event> closeList = null)
|
||||
{
|
||||
LastInterestCalculationPositions = positions;
|
||||
return positions.Select(position => new swap_flow_event
|
||||
{
|
||||
PositionId = position.id,
|
||||
InterestPrincipal = 1000m,
|
||||
InterestRate = 0.01m,
|
||||
FloatRate = 0.01m
|
||||
}).ToList();
|
||||
return base.CalcSwapInterests(td, tradeExtend, valueDate, unwindDate,
|
||||
eodPositions, positions, posiNotionalValue, posiLongNotionalValue, posiShortNotionalValue,
|
||||
closePosiNotionalValue, closePrecent, eventType, tdClose, needPrice,
|
||||
grossPrice, orginPv, add, settment, newCalcLast, closeList);
|
||||
}
|
||||
|
||||
public void ExecuteSwapPositionCompose(DateTime settleDate, DateTime preSettleDate)
|
||||
@@ -328,7 +325,8 @@ namespace YLErp.Modules.SwapModule
|
||||
id = initialPrepayId, SwapTradeId = SwapTradeId, PosiDirection = 0,
|
||||
InterestDirection = (int)SwapDirectionEnum.收取,
|
||||
InterestMode = (int)InterestModeEnum.初始预付金,
|
||||
InterestPrincipalFix = 1000m, IsInitial = true, Invalid = false,
|
||||
InterestPrincipalFix = 1000m, InterestRateDefault = 0.01m,
|
||||
IsInitial = true, Invalid = false,
|
||||
IsAnnualized = true,
|
||||
PosiStartDate = SettleDate.AddDays(-1), PosiMatuirityDate = td.ExerciseDate.Value,
|
||||
InterestSwapInterval = "[]"
|
||||
@@ -356,7 +354,8 @@ namespace YLErp.Modules.SwapModule
|
||||
EventType = (int)SwapEventTypeEnum.平仓,
|
||||
EventDate = SettleDate, DataState = (int)SwapFlowDateStateEnum.完成,
|
||||
InterestMode = (int)InterestModeEnum.初始预付金,
|
||||
InterestPrincipal = 300m
|
||||
InterestPrincipal = 300m,
|
||||
InterestRate = 0.01m
|
||||
};
|
||||
var service = new TestableSwapEodService(
|
||||
new List<trade> { td },
|
||||
@@ -374,7 +373,9 @@ namespace YLErp.Modules.SwapModule
|
||||
"实时腿已经扣减到700,日终不得再次按平仓比例扣减");
|
||||
Assert.AreEqual(700m, persistedPrepay.TdInterestPrincipal,
|
||||
"平仓日预付金计息本金应立即切换为实时剩余本金");
|
||||
Assert.AreEqual(700m * 0.01m / 365m, persistedPrepay.TdInterestIncome,
|
||||
var expectedDailyInterest = Math.Round(700m * 0.01m / 365m,
|
||||
12, MidpointRounding.AwayFromZero);
|
||||
Assert.AreEqual(expectedDailyInterest, persistedPrepay.TdInterestIncome,
|
||||
"平仓日新增利息应按实时剩余本金计算");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user