Files
zszq-trs/YLErpDAL/Modules/SwapModule/FundingLegs/IFundingLegStrategy.cs
T
hjhan 70550af29a refactor(funding-leg): 清理CalcNotional死参数posiLong/posiShort+修正过时InterestMode注释
- 删除 IFundingLegStrategy.CalcNotional 的 posiLong/posiShort 死参数(多空存续腿界面已禁用,三个实现均不读取),同步三个实现签名、SwapDealService 唯一调用点、FundingLegStrategyTest 7 处调用
- 修正 SwapPosition/SwapFlowEvent/EodSwapPosition 的 InterestMode 字段注释(去掉已删的 3/4,补全 5/6/9)
- 重写 SwapUnwindFloatingLegDiagnosticTdd 过时类注释

零行为变化;编译 0 错误;FundingLegStrategyTest 11/11 通过。
2026-08-13 08:51:21 +08:00

49 lines
2.2 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.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="closePercent">平仓比例(占剩余,0~1)。</param>
NotionalResult CalcNotional(decimal fix, decimal posiNotional, 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);
}