chore: 删除误提交的 TdCarryInCharacterizationTest 占位测试(沙箱漂移产生的无意义文件)
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using YLErp.Derivatives.Interest; // InterestResult, AccrualBoundary, SwapInterest
|
||||
using YLErp.Modules.SwapModule.Accrual; // SimpleInterestAccrual
|
||||
|
||||
namespace UnitTestProject.Modules.SwapModule.Accrual
|
||||
{
|
||||
/// <summary>
|
||||
/// 性格化测试:部分平仓时 TdInterestAmount 的 carry-in 是否被错误缩放。
|
||||
/// 调用真实纯函数 SimpleInterestAccrual.AccruePeriod,参数与线上 SwapDealService.cs:1290 完全一致
|
||||
/// (priorAccrued = InterestProfitSum * closePercent)。先钉死“当前行为”,修复后再改断言。
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TdCarryInCharacterizationTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void 部分平仓_历史累计利息_carryIn被缩放_复现当前行为()
|
||||
{
|
||||
// ── 例子(教学用整数,非市场真实利率)──
|
||||
// 昨日(上一EOD)全腿累计利息 InterestProfitSum = 100(不缩放口径,下游 EOD :1300/:1370 当累计用)
|
||||
// 今日部分平仓 closePercent = 0.3(平 30%)
|
||||
// 计息基数 notional = 1000(全腿)
|
||||
// 单段、年化=false、利率 0.10、区间 1 天 → 今日未缩放增量 = 1000*0.10*1 = 100
|
||||
decimal interestProfitSum = 100m;
|
||||
decimal closePercent = 0.3m;
|
||||
decimal notional = 1000m;
|
||||
|
||||
var segmentRates = new List<(DateTime, decimal)> { (new DateTime(2026, 6, 1), 0.10m) };
|
||||
var startDate = new DateTime(2026, 6, 1);
|
||||
var endDate = new DateTime(2026, 6, 2); // 区间 1 天(StartOnly 边界 → days=1)
|
||||
var priorValueDate = new DateTime(2026, 5, 31);
|
||||
var boundary = AccrualBoundary.StartOnly;
|
||||
|
||||
// 线上真实调用(SwapDealService.cs:1290):priorAccrued = InterestProfitSum * closePercent
|
||||
var result = SimpleInterestAccrual.AccruePeriod(
|
||||
priorAccrued: interestProfitSum * closePercent, // = 30 ← 已缩放
|
||||
notional: notional,
|
||||
unwindFraction: closePercent,
|
||||
segmentRates: segmentRates,
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
priorValueDate: priorValueDate,
|
||||
boundary: boundary,
|
||||
annualDays: 365,
|
||||
isAnnualized: false);
|
||||
|
||||
Console.WriteLine("==== 当前代码(buggy)实际输出 ====");
|
||||
Console.WriteLine($"InterestAmount (Accrued) = {result.Accrued}");
|
||||
Console.WriteLine($"TdInterestAmount (AccruedToday) = {result.AccruedToday}");
|
||||
|
||||
// ── 推演(当前代码)──
|
||||
// InterestAmount = 30 + 300*0.10*1(=30) = 60 (缩放累计,正确)
|
||||
// TdInterestAmount= 30 + 1000*0.10*1(=100) = 130 ← 应为 200
|
||||
// 差距 = 100*(1-0.3) = 70,即历史累计被砍掉的那一截。
|
||||
Assert.AreEqual(60m, result.Accrued);
|
||||
Assert.AreEqual(130m, result.AccruedToday); // 当前 buggy 值,先钉死现状
|
||||
|
||||
// ── 期望值(修复后)──
|
||||
// TdInterestAmount 应为:InterestProfitSum(100, 不缩放) + 今日未缩放增量(100) = 200
|
||||
// 修复 = SwapDealService.cs:1290 改传 InterestProfitSum(去 *closePercent)
|
||||
// + SimpleInterestAccrual.cs:68 accrued = priorAccrued * unwindFraction
|
||||
// 修复后 InterestAmount 仍 = 60(不变,正确),TdInterestAmount = 200。
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user