cleanup: 删除死代码枚举 mode 3/4/7/8 及相关引用
mode 3(持仓名义本金)/4(持仓市值): 零引用死代码 mode 7/8(多空存续名义本金): 界面已禁用, 无历史数据(用户确认) 删除: - InterestModeEnum: 移除 持仓名义本金/持仓市值/多头存续名义本金/空头存续名义本金 枚举值保持显式(1/2/5/6/9), DB契约不变 - CalcNotionalByMode: 移除 mode 7/8 的 case - ConsTrade.InterestModels/InterestNotionalModels: 移除 mode 7/8 - 删除3个 mode 7/8 相关测试方法(场景已不存在) CalcNotionalByMode 现在只剩 mode 5/6(保证金)的 case, 待 Margin 独立计息入口建成后整体删除。 验证: 编译0错误, 全量508测试7失败(基线一致)。
This commit is contained in:
@@ -131,11 +131,11 @@ namespace YLErp.DBModels
|
||||
/// <summary>
|
||||
/// 互换利率端计息方式
|
||||
/// </summary>
|
||||
public static readonly List<int> InterestModels = new List<int>() { (int)InterestModeEnum.固定值, (int)InterestModeEnum.合约名义本金规模, (int)InterestModeEnum.空头存续名义本金,(int)InterestModeEnum.多头存续名义本金, (int)InterestModeEnum.标的期初全价 };
|
||||
public static readonly List<int> InterestModels = new List<int>() { (int)InterestModeEnum.固定值, (int)InterestModeEnum.合约名义本金规模, (int)InterestModeEnum.标的期初全价 };
|
||||
/// <summary>
|
||||
/// 互换利率端计息方式-名义本金相关
|
||||
/// </summary>
|
||||
public static readonly List<int> InterestNotionalModels = new List<int>() {(int)InterestModeEnum.合约名义本金规模, (int)InterestModeEnum.空头存续名义本金, (int)InterestModeEnum.多头存续名义本金, (int)InterestModeEnum.标的期初全价 };
|
||||
public static readonly List<int> InterestNotionalModels = new List<int>() {(int)InterestModeEnum.合约名义本金规模, (int)InterestModeEnum.标的期初全价 };
|
||||
/// <summary>
|
||||
/// 互换利率计息方式 预付金
|
||||
/// </summary>
|
||||
|
||||
@@ -14,12 +14,8 @@ namespace YLErp.DBModels
|
||||
Unknown = 0,
|
||||
固定值 = 1,
|
||||
合约名义本金规模 = 2,
|
||||
持仓名义本金 = 3,
|
||||
持仓市值 = 4,
|
||||
初始预付金 = 5,
|
||||
追加预付金 = 6,
|
||||
多头存续名义本金 = 7,
|
||||
空头存续名义本金 = 8,
|
||||
标的期初全价 = 9
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -121,10 +121,9 @@ namespace UnitTestProject.Modules.SwapModule.FundingLegs
|
||||
[TestMethod]
|
||||
public void 工厂_未注册mode抛异常()
|
||||
{
|
||||
// mode 3/4/7/8 已从枚举删除,用 Unknown(0)验证未注册抛异常
|
||||
Assert.ThrowsException<ArgumentException>(() =>
|
||||
FundingLegStrategyFactory.Get(InterestModeEnum.持仓名义本金));
|
||||
Assert.ThrowsException<ArgumentException>(() =>
|
||||
FundingLegStrategyFactory.Get(InterestModeEnum.持仓市值));
|
||||
FundingLegStrategyFactory.Get(InterestModeEnum.Unknown));
|
||||
Assert.ThrowsException<ArgumentException>(() =>
|
||||
FundingLegStrategyFactory.Get(InterestModeEnum.初始预付金));
|
||||
Assert.ThrowsException<ArgumentException>(() =>
|
||||
|
||||
@@ -94,19 +94,5 @@ namespace YLErp.Modules.SwapModule
|
||||
Assert.AreEqual(RealFix * ClosePct, close, "mode5 应 = 实时腿剩余本金(real Fix) * closePct,与 posiLong(orig 100M) 无关");
|
||||
Assert.AreNotEqual(OrigFix * ClosePct, close, "务必不是期初 99,000 * closePct(证明后端修复生效)");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 诊断_若将来有_多头存续名义本金_腿_posiLong用orig才出错_本deal无此腿_故不影响()
|
||||
{
|
||||
// 构造一个「多头存续名义本金」腿,证明此时 posiLong 取值(orig vs real)会直接决定结果——
|
||||
// 说明本 deal 没有这种腿,所以 fpositions 用 orig 100M 不影响;但普通收益互换若有此腿则会踩坑。
|
||||
var longLeg = new swap_position { id = 35799, InterestMode = (int)InterestModeEnum.多头存续名义本金 };
|
||||
var byOrig = CallCalcNotionalByMode(longLeg, ClosePct, RealLong * ClosePct, OrigLong, 0m); // 当前代码:posiLong=orig 100M
|
||||
var byReal = CallCalcNotionalByMode(longLeg, ClosePct, RealLong * ClosePct, RealLong, 0m); // 若修正为 real 75.6M
|
||||
Console.WriteLine($"[多头存续名义本金] orig100M→close={byOrig.close} ; real75.6M→close={byReal.close}");
|
||||
Assert.AreEqual(OrigLong * ClosePct, byOrig.close, "现状:多头存续名义本金用 orig 100M → 多次部分平仓后会偏大");
|
||||
Assert.AreEqual(RealLong * ClosePct, byReal.close, "正确应:用 real 剩余本金 75.6M");
|
||||
Assert.AreNotEqual(byOrig.close, byReal.close, "★ 潜在同类 bug:普通收益互换(含多头/空头存续名义本金腿)在多次部分平仓后,posiLong/posiShort 用 orig 会算错——本 deal 无此腿故不触发,属本轮修复范围外");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,27 +505,6 @@ namespace YLErp.Modules.SwapModule
|
||||
Assert.AreEqual(918_000m, fe1.InterestPrincipal, "追加预付金 10% 应=Fix×0.1");
|
||||
}
|
||||
|
||||
// ---- 多头/空头存续名义本金(7/8):经同一 CalcDailySimpleInterest,需证明修复通用 ----
|
||||
[TestMethod]
|
||||
public void 多头存续名义本金腿_盘中_部分平仓重置周期7天_应线性缩放()
|
||||
{
|
||||
const decimal baseP = 2_000_000m;
|
||||
var fe = CalcByMode((int)InterestModeEnum.多头存续名义本金, baseP, 0.5m);
|
||||
Assert.AreEqual(1_000_000m, fe.InterestPrincipal, "多头存续 50% 应=posiLong×0.5");
|
||||
var fe1 = CalcByMode((int)InterestModeEnum.多头存续名义本金, baseP, 0.1m);
|
||||
Assert.AreEqual(200_000m, fe1.InterestPrincipal, "多头存续 10% 应=posiLong×0.1");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 空头存续名义本金腿_盘中_部分平仓重置周期7天_应线性缩放()
|
||||
{
|
||||
const decimal baseP = 2_000_000m;
|
||||
var fe = CalcByMode((int)InterestModeEnum.空头存续名义本金, baseP, 0.5m);
|
||||
Assert.AreEqual(1_000_000m, fe.InterestPrincipal, "空头存续 50% 应=posiShort×0.5");
|
||||
var fe1 = CalcByMode((int)InterestModeEnum.空头存续名义本金, baseP, 0.1m);
|
||||
Assert.AreEqual(200_000m, fe1.InterestPrincipal, "空头存续 10% 应=posiShort×0.1");
|
||||
}
|
||||
|
||||
// ---- 合约名义本金规模(2):CalcNotionalByMode 默认分支(posiNotional×cp) ----
|
||||
[TestMethod]
|
||||
public void 合约名义本金规模腿_盘中_部分平仓重置周期7天_应线性缩放()
|
||||
|
||||
@@ -937,14 +937,6 @@ namespace YLErp.Modules.SwapModule
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case InterestModeEnum.多头存续名义本金:
|
||||
closePrincipal = posiLong * closePercent;
|
||||
posiPrincipal = posiLong;
|
||||
break;
|
||||
case InterestModeEnum.空头存续名义本金:
|
||||
closePrincipal = posiShort * closePercent;
|
||||
posiPrincipal = posiShort;
|
||||
break;
|
||||
case InterestModeEnum.追加预付金:
|
||||
case InterestModeEnum.初始预付金:
|
||||
closePrincipal = position.InterestPrincipalFix * closePercent;
|
||||
|
||||
Reference in New Issue
Block a user