using YLErp.DBModels; namespace YLErp.Modules.SwapModule.FundingLegs; /// /// 融资腿(Funding Leg)计息基数策略。每个 InterestMode 一个实现。 /// /// 命名说明:用 FundingLeg(业界标准 Financing/Funding Leg),不用 InterestLeg—— /// "interest"易和通用"利息"混淆;funding 精确表达"融资成本"。 /// 融资腿 = 客户付给券商的杠杆成本(spread + FR007),与保证金(Margin)、标的端(ReturnLeg)各自独立。 /// /// 职责单一:给定持仓参数与平仓比例,算出"平仓本金 / 存续本金 / 有效比例"。 /// 不做计息(计息由 SwapInterest 纯函数完成),不取价(取价由 IIndexFixer 完成)。 /// public interface IFundingLegStrategy { /// 该策略对应的计息模式。 InterestModeEnum Mode { get; } /// /// 根据持仓参数与平仓比例计算计息本金三元组。 /// /// 合约固定本金(固定值/预付金腿用;其余腿忽略)。 /// 当前剩余名义本金(数量 × 全价)。 /// 平仓比例(占剩余,0~1)。 NotionalResult CalcNotional(decimal fix, decimal posiNotional, decimal closePercent); } /// /// 融资腿策略的计算结果。对应原 CalcNotionalByMode 返回的三元组,用自描述名。 /// public readonly struct NotionalResult { /// 本次平仓部分的计息本金。 public decimal ClosePrincipal { get; } /// 存续持仓部分的计息本金(全额,不缩放)。 public decimal PosiPrincipal { get; } /// 有效平仓比例。固定值腿恒为 1(计息基数不随比例变);其余沿用入参。 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); }