Files
zszq-trs/YLErpDAL/Modules/SwapModule/InterestLegs/PrepayLeg.cs
T
hjhan aca834d8dc refactor(interest): 新增预付金腿策略 + 策略工厂
新增(零生产改动):
- InterestLegs/PrepayLeg.cs
  mode 5 初始预付金 / mode 6 追加预付金 共用。
  计息基数=InterestPrincipalFix, 平仓本金=Fix×closePercent。
  构造时校验mode合法性(只接受5/6)。
  方向翻转/orginPv重映射等独有逻辑后续单独抽。

- InterestLegs/InterestLegStrategyFactory.cs
  按InterestMode返回对应策略, 收敛switch分发。
  死代码mode 3/4/7/8不注册, 传入会抛ArgumentException。

测试(14个全过):
- 预付金: 部分平仓/全平/非法mode构造
- 工厂: 各活跃mode返回正确类型/未注册mode抛异常/int重载等价

fixing接入尝试(已回退):
- 尝试用Fr007IndexFixer.Instance替换SwapDealService的6处取价
- 发现问题: 静态Instance绕过TryGetFloatRate(virtual)接缝,
  破坏测试stub机制(CI_007/CI_008失败)
- 已回退, 下次改用实例级IIndexFixer(委托TryGetFloatRate)方式接入
2026-08-10 18:40:04 +08:00

34 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using YLErp.DBModels;
namespace YLErp.Modules.SwapModule.InterestLegs;
/// <summary>
/// 预付金(保证金)利息腿。mode 5 初始预付金 / mode 6 追加预付金 共用。
///
/// 业务本质:预付金是客户"存"在券商的钱,券商对其付息(方向与普通利息腿相反)。
/// 计息基数 = InterestPrincipalFix(预付金余额),随平仓递减。
///
/// 本类只封装 CalcNotionalByMode 的计息基数计算部分:
/// closePrincipal = Fix × closePercent
/// posiPrincipal = Fix
///
/// 预付金腿的其它独有逻辑(方向翻转、orginPv 重映射、衡泰路径返还置0)不在此处,
/// 后续分别抽成独立方法,保持每个类/方法最小。
/// </summary>
public sealed class PrepayLeg : IInterestLegStrategy
{
// 预付金两个 mode(初始/追加)共用同一套计息基数公式,构造时指定
private readonly InterestModeEnum _mode;
public InterestModeEnum Mode => _mode;
public PrepayLeg(InterestModeEnum mode)
{
if (mode != InterestModeEnum.初始预付金 && mode != InterestModeEnum.追加预付金)
throw new ArgumentException($"PrepayLeg 仅支持 初始预付金/追加预付金,收到 {mode}", nameof(mode));
_mode = mode;
}
public NotionalResult CalcNotional(decimal fix, decimal posiNotional, decimal posiLong, decimal posiShort, decimal closePercent)
=> new(fix * closePercent, fix, closePercent);
}