refactor(interest): CalcNotionalByMode 融资腿委托策略工厂
融资腿(mode 1固定值/2合约名义本金/9标的期初全价)改由 InterestLegStrategyFactory.Get(mode).CalcNotional(...) 计算, 不再走原 switch 的 case。 保证金(mode 5/6)和多空存续(mode 7/8)暂保留原 switch 逻辑, 待 Margin 上下文接入后再迁出。 行为等价: 全量480测试, 改动前后失败数一致(7个, 全为无库环境问题), 零回归。
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据计息模式计算名义本金
|
||||
/// 根据计息模式计算名义本金。
|
||||
/// 融资腿(mode 1/2/9)已委托 InterestLegStrategyFactory;保证金(mode 5/6)和
|
||||
/// 半禁用的多空存续(mode 7/8)暂保留原逻辑,待 Margin 上下文接入后再迁出。
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user