refactor(return-leg): 新增 ReturnLegSummary 标的端值对象
标的端(Total Return Leg)归档产出的汇总值: 多空名义本金/平仓名义本金/含费全价。 对应原 SwapPositionCompose 里 DealFloatPositions 传给 DealInterests 的4个标量。 命名说明(防歧义): - 用 ReturnLeg(业界标准 Total Return Leg), 不用 FloatLeg - 'float'在金融里首要含义是'浮动利率'(如FR007), 用于标的端会产生歧义 - 标的端 = 标的资产的总回报(价格涨跌+票息分红), 与浮动利率无关 纯新增骨架, 零生产改动。 验证: 编译0错误, 3个单测全过, 全量489测试7失败(基线一致)。
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using YLErp.Modules.SwapModule.ReturnLegs;
|
||||
|
||||
namespace UnitTestProject.Modules.SwapModule.ReturnLegs
|
||||
{
|
||||
/// <summary>
|
||||
/// ReturnLegSummary 值对象测试。
|
||||
/// 验证标的端归档产出的汇总值正确构造、字段语义清晰。
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ReturnLegSummaryTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void 构造_四个字段正确赋值()
|
||||
{
|
||||
var s = new ReturnLegSummary(
|
||||
longNotional: 100_000_000m,
|
||||
shortNotional: 0m,
|
||||
closeNotional: 50_000_000m,
|
||||
grossPrice: 1.02m);
|
||||
|
||||
Assert.AreEqual(100_000_000m, s.LongNotional);
|
||||
Assert.AreEqual(0m, s.ShortNotional);
|
||||
Assert.AreEqual(50_000_000m, s.CloseNotional);
|
||||
Assert.AreEqual(1.02m, s.GrossPrice);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 构造_空头场景()
|
||||
{
|
||||
var s = new ReturnLegSummary(0m, 80_000_000m, 30_000_000m, 0.98m);
|
||||
|
||||
Assert.AreEqual(0m, s.LongNotional, "无多头");
|
||||
Assert.AreEqual(80_000_000m, s.ShortNotional, "空头名义本金");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void 构造_全平场景()
|
||||
{
|
||||
var s = new ReturnLegSummary(0m, 0m, 100_000_000m, 1.00m);
|
||||
|
||||
Assert.AreEqual(100_000_000m, s.CloseNotional, "全平:平仓名义本金=全额");
|
||||
Assert.AreEqual(0m, s.LongNotional, "全平后无多头剩余");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user