命名: InterestLeg→FundingLeg, 消除'interest'与通用'利息'歧义。 Funding精确表达'融资成本'(客户付券商的杠杆成本 spread+FR007)。 改名清单: - IInterestLegStrategy → IFundingLegStrategy - InterestLegStrategyFactory → FundingLegStrategyFactory - InterestLegStrategyTest → FundingLegStrategyTest - 命名空间 InterestLegs → FundingLegs - 目录 InterestLegs/ → FundingLegs/ - SwapDealService 引用同步更新 验证: 编译0错误, 全量503测试7失败(基线一致)。
51 lines
2.4 KiB
C#
51 lines
2.4 KiB
C#
using YLErp.DBModels;
|
||
|
||
namespace YLErp.Modules.SwapModule.FundingLegs;
|
||
|
||
/// <summary>
|
||
/// 融资腿(Funding Leg)计息基数策略。每个 InterestMode 一个实现。
|
||
///
|
||
/// 命名说明:用 FundingLeg(业界标准 Financing/Funding Leg),不用 InterestLeg——
|
||
/// "interest"易和通用"利息"混淆;funding 精确表达"融资成本"。
|
||
/// 融资腿 = 客户付给券商的杠杆成本(spread + FR007),与保证金(Margin)、标的端(ReturnLeg)各自独立。
|
||
///
|
||
/// 职责单一:给定持仓参数与平仓比例,算出"平仓本金 / 存续本金 / 有效比例"。
|
||
/// 不做计息(计息由 SwapInterest 纯函数完成),不取价(取价由 IIndexFixer 完成)。
|
||
/// </summary>
|
||
public interface IFundingLegStrategy
|
||
{
|
||
/// <summary>该策略对应的计息模式。</summary>
|
||
InterestModeEnum Mode { get; }
|
||
|
||
/// <summary>
|
||
/// 根据持仓参数与平仓比例计算计息本金三元组。
|
||
/// </summary>
|
||
/// <param name="fix">合约固定本金(固定值/预付金腿用;其余腿忽略)。</param>
|
||
/// <param name="posiNotional">当前剩余名义本金(数量 × 全价)。</param>
|
||
/// <param name="posiLong">多头剩余名义本金(多空存续腿用,当前界面已禁用)。</param>
|
||
/// <param name="posiShort">空头剩余名义本金。</param>
|
||
/// <param name="closePercent">平仓比例(占剩余,0~1)。</param>
|
||
NotionalResult CalcNotional(decimal fix, decimal posiNotional, decimal posiLong, decimal posiShort, decimal closePercent);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 融资腿策略的计算结果。对应原 CalcNotionalByMode 返回的三元组,用自描述名。
|
||
/// </summary>
|
||
public readonly struct NotionalResult
|
||
{
|
||
/// <summary>本次平仓部分的计息本金。</summary>
|
||
public decimal ClosePrincipal { get; }
|
||
|
||
/// <summary>存续持仓部分的计息本金(全额,不缩放)。</summary>
|
||
public decimal PosiPrincipal { get; }
|
||
|
||
/// <summary>有效平仓比例。固定值腿恒为 1(计息基数不随比例变);其余沿用入参。</summary>
|
||
public decimal ClosePercent { get; }
|
||
|
||
public NotionalResult(decimal closePrincipal, decimal posiPrincipal, decimal closePercent)
|
||
=> (ClosePrincipal, PosiPrincipal, ClosePercent) = (closePrincipal, posiPrincipal, closePercent);
|
||
|
||
public void Deconstruct(out decimal close, out decimal posi, out decimal pct)
|
||
=> (close, posi, pct) = (ClosePrincipal, PosiPrincipal, ClosePercent);
|
||
}
|