diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index c9605a21..4183bece 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -10,6 +10,7 @@ using YLErp.Modules.DataProviderModule; using YLErp.Modules.EodModule; using YLErp.Modules.TradeModule; using YLErp.Modules.TradeModule.DealModule; +using YLErp.Modules.SwapModule.InterestLegs; using YLErp.QdpModule; namespace YLErp.Modules.SwapModule @@ -898,20 +899,31 @@ namespace YLErp.Modules.SwapModule } /// - /// 根据计息模式计算名义本金 + /// 根据计息模式计算名义本金。 + /// 融资腿(mode 1/2/9)已委托 InterestLegStrategyFactory;保证金(mode 5/6)和 + /// 半禁用的多空存续(mode 7/8)暂保留原逻辑,待 Margin 上下文接入后再迁出。 /// private (decimal close, decimal posi, decimal closePct) CalcNotionalByMode(swap_position position, decimal closePercent, decimal posiNotional, decimal posiLong, decimal posiShort) { - decimal closePrincipal = posiNotional; // 平仓部分的名义本金 - decimal posiPrincipal = posiNotional; // 持仓部分的名义本金 - decimal newClosePercent = closePercent; // 调整后的平仓比例 + var mode = (InterestModeEnum)position.InterestMode; - switch ((InterestModeEnum)position.InterestMode) + // 融资腿(1/2/9)走策略工厂 + if (mode == InterestModeEnum.固定值 + || mode == InterestModeEnum.合约名义本金规模 + || mode == InterestModeEnum.标的期初全价) + { + var r = InterestLegStrategyFactory.Get(mode) + .CalcNotional(position.InterestPrincipalFix, posiNotional, posiLong, posiShort, closePercent); + return (r.ClosePrincipal, r.PosiPrincipal, r.ClosePercent); + } + + // 以下 mode 尚未迁入新架构,保留原逻辑 + decimal closePrincipal = posiNotional; + decimal posiPrincipal = posiNotional; + decimal newClosePercent = closePercent; + + switch (mode) { - case InterestModeEnum.固定值: - closePrincipal = posiPrincipal = position.InterestPrincipalFix; - newClosePercent = 1m; - break; case InterestModeEnum.多头存续名义本金: closePrincipal = posiLong * closePercent; posiPrincipal = posiLong; @@ -920,12 +932,6 @@ namespace YLErp.Modules.SwapModule closePrincipal = posiShort * closePercent; posiPrincipal = posiShort; break; - case InterestModeEnum.合约名义本金规模: - closePrincipal = posiNotional * closePercent; - break; - case InterestModeEnum.标的期初全价: - closePrincipal = posiNotional * closePercent; - break; case InterestModeEnum.追加预付金: case InterestModeEnum.初始预付金: closePrincipal = position.InterestPrincipalFix * closePercent;