refactor(swap): 误导布尔 swap 改名 interestWindowEmpty——按"计息窗口为空"本质命名
InitInterestDate 返回 true 的语义是"计息窗口为空→不计利息"(利率与金额归零), 判定只看日期窗口(interestStart>interestEnd)、与事件类型无关;旧名 swap 把 典型原因(互换当日已结息)当成了效果的名字,读者会误读为事件类型判断。 - SwapDealService: GetInterests 局部变量 + GetFloatRate/CalcUnwindInterest/ InitSwapDealInterest/CalcMarginInterest 四个签名参数及分支/日志/注释同步 - SwapTradeBaseService.InitInterestDate 返回值语义补入 XML 文档 - MarginInterestGoldenReplay/Shadow 测试命名参数同步 零行为变更。 验证:相关套件 51/51;全量 978 例 145 败与基线 diff=0
This commit is contained in:
@@ -128,7 +128,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
|
||||
newEvt = svc.CalcMarginInterest(td, valueDate, valueDate, posClone, rate,
|
||||
pos.InterestPrincipalFix, pos.InterestPrincipalFix, 1.0m,
|
||||
annualDays, calcFirst, calcLast, preEod,
|
||||
(int)SwapEventTypeEnum.自动互换, add: false, settment: true, swap: false);
|
||||
(int)SwapEventTypeEnum.自动互换, add: false, settment: true, interestWindowEmpty: false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
|
||||
// 新方法(独立 preEod,相同初始值)
|
||||
var newEvt = svc.CalcMarginInterest(td, valueDate, valueDate, position, Rate, Principal, Principal, 1m,
|
||||
AnnualDays, calcFirst: true, calcLast: true,
|
||||
CreatePreEod(StartDate.AddDays(4), profitSum), 0, add: false, settment: true, swap: false);
|
||||
CreatePreEod(StartDate.AddDays(4), profitSum), 0, add: false, settment: true, interestWindowEmpty: false);
|
||||
|
||||
Console.WriteLine($"旧: I={oldI} Td={oldTd}");
|
||||
Console.WriteLine($"新: I={newEvt.InterestAmount} Td={newEvt.TdInterestAmount} ClosePnL={newEvt.InterestClosePnL}");
|
||||
@@ -114,7 +114,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
|
||||
|
||||
var newEvt = svc.CalcMarginInterest(td, valueDate, valueDate, position, Rate, Principal, Principal, 1m,
|
||||
AnnualDays, calcFirst: true, calcLast: true,
|
||||
new eod_swap_position { id = 0 }, 0, add: false, settment: true, swap: false);
|
||||
new eod_swap_position { id = 0 }, 0, add: false, settment: true, interestWindowEmpty: false);
|
||||
|
||||
Assert.AreEqual(oldI, newEvt.InterestAmount, "InterestAmount 一致");
|
||||
Assert.AreEqual(oldTd, newEvt.TdInterestAmount, "TdInterestAmount 一致");
|
||||
@@ -143,7 +143,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
|
||||
// 新方法:notional = posiPrincipal(无差分、无 orginPv)
|
||||
var newEvt = svc.CalcMarginInterest(td, valueDate, valueDate, position, Rate, Principal, Principal, 1m,
|
||||
AnnualDays, calcFirst: true, calcLast: false,
|
||||
CreatePreEod(StartDate.AddDays(4), profitSum), 0, add: false, settment: false, swap: false);
|
||||
CreatePreEod(StartDate.AddDays(4), profitSum), 0, add: false, settment: false, interestWindowEmpty: false);
|
||||
|
||||
Console.WriteLine($"旧: I={oldI} Td={oldTd}");
|
||||
Console.WriteLine($"新: I={newEvt.InterestAmount} Td={newEvt.TdInterestAmount}");
|
||||
@@ -172,7 +172,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
|
||||
var newEvt = svc.CalcMarginInterest(td, valueDate, valueDate, position, Rate,
|
||||
Principal * closePct, Principal, closePct,
|
||||
AnnualDays, calcFirst: true, calcLast: false,
|
||||
CreatePreEod(StartDate.AddDays(4), profitSum), 0, add: false, settment: false, swap: false);
|
||||
CreatePreEod(StartDate.AddDays(4), profitSum), 0, add: false, settment: false, interestWindowEmpty: false);
|
||||
|
||||
Console.WriteLine($"旧: I={oldI} Td={oldTd}");
|
||||
Console.WriteLine($"新: I={newEvt.InterestAmount} Td={newEvt.TdInterestAmount}");
|
||||
@@ -191,7 +191,7 @@ namespace UnitTestProject.Modules.SwapModule.Margin
|
||||
var svc = new StubSvc();
|
||||
var newEvt = svc.CalcMarginInterest(td, valueDate, valueDate, position, Rate, Principal, Principal, 1m,
|
||||
AnnualDays, calcFirst: true, calcLast: false,
|
||||
CreatePreEod(StartDate.AddDays(4), 820m), 0, add: false, settment: false, swap: true);
|
||||
CreatePreEod(StartDate.AddDays(4), 820m), 0, add: false, settment: false, interestWindowEmpty: true);
|
||||
|
||||
Assert.AreEqual(0m, newEvt.InterestAmount, "互换利息归零");
|
||||
Assert.AreEqual(0m, newEvt.TdInterestAmount, "互换 TdInterestAmount 归零");
|
||||
|
||||
Reference in New Issue
Block a user