采纳命名审查建议(优先级最高的2项): 1. UnderlyingFullPriceLeg → UnderlyingEntryFullPriceLeg 补齐'期初(Entry)'——建仓时点全价, 非当前全价, 金融上是不同计息口径 2. FixedNotionalLeg → FixedAmountLeg 去掉误导性的Notional——'固定值'是合同写死的数额, 不一定是名义本金, 避免与ContractNotionalLeg的Notional概念撞车 3. DividendCalc 补充注释: 业务含义(债券票息+股票分红统一用Dividend)、 税务口径(还原不含税再扣税)、命名保持理由 验证: 编译0错误, 全量507测试7失败(基线一致)。
36 lines
1.6 KiB
C#
36 lines
1.6 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using YLErp.DBModels;
|
||
|
||
namespace YLErp.Modules.SwapModule.FundingLegs;
|
||
|
||
/// <summary>
|
||
/// 融资腿策略工厂。按 InterestMode 返回对应策略实例。
|
||
/// 替换原 SwapDealService.CalcNotionalByMode 的 switch,收敛 mode 分发逻辑到一处。
|
||
///
|
||
/// 只管融资腿(funding leg),不管保证金——保证金是独立的资金管理体系,
|
||
/// 不应该出现在融资腿策略里。mode 5/6(预付金)属于保证金,不在此注册。
|
||
/// 死代码 mode 3/4 不注册;半死 mode 7/8 不注册(界面已注释)。
|
||
/// 传入未注册的 mode 会抛异常,防止静默走默认分支。
|
||
/// </summary>
|
||
public static class FundingLegStrategyFactory
|
||
{
|
||
private static readonly Dictionary<InterestModeEnum, IFundingLegStrategy> _strategies = new()
|
||
{
|
||
[InterestModeEnum.固定值] = new FixedAmountLeg(),
|
||
[InterestModeEnum.合约名义本金规模] = new ContractNotionalLeg(),
|
||
[InterestModeEnum.标的期初全价] = new UnderlyingEntryFullPriceLeg(),
|
||
};
|
||
|
||
/// <summary>按 mode 返回对应策略。未注册的 mode 抛 ArgumentException。</summary>
|
||
public static IFundingLegStrategy Get(InterestModeEnum mode)
|
||
{
|
||
if (_strategies.TryGetValue(mode, out var strategy))
|
||
return strategy;
|
||
throw new ArgumentException($"未注册的计息模式: {mode}(mode 3/4/7/8 当前未启用)", nameof(mode));
|
||
}
|
||
|
||
/// <summary>按 mode 值返回对应策略,便于调用方直接传 int。</summary>
|
||
public static IFundingLegStrategy Get(int mode) => Get((InterestModeEnum)mode);
|
||
}
|