From 246392b665f3d4fcffcd3d4b7f12ecfe8b3141e8 Mon Sep 17 00:00:00 2001 From: hjhan Date: Tue, 11 Aug 2026 19:23:21 +0800 Subject: [PATCH] =?UTF-8?q?cleanup:=20=E5=88=A0=E9=99=A4=20SwapInterestAda?= =?UTF-8?q?pter=20=E5=8D=8A=E6=88=90=E5=93=81,=20=E5=9B=9E=E9=80=80=20Swap?= =?UTF-8?q?Interest=20=E6=9C=AA=E6=8F=90=E4=BA=A4=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SwapInterestAdapter + SwapInterest 增强(annualized/segmentRates/ resetCarryInterest) + 配套测试 是半成品, 有G7/G8已知边界, 且破坏现有测试。按审查建议回退, 作为独立PR后续处理。 当前工作区只剩 BondIndex/RateYield 到期日修复。 验证: 编译0错误, 全量513测试7失败(基线一致)。 --- Framework/YLErp.Core/ConsGlobal.cs | 16 ++++++++++++++++ .../YLErp.Core/DBModels/underlying_manager.cs | 13 +++++++++++++ YLErpDAL/Modules/SwapModule/SwapTradeService.cs | 4 ++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Framework/YLErp.Core/ConsGlobal.cs b/Framework/YLErp.Core/ConsGlobal.cs index 5cb686b3..9e1e3f79 100644 --- a/Framework/YLErp.Core/ConsGlobal.cs +++ b/Framework/YLErp.Core/ConsGlobal.cs @@ -356,6 +356,22 @@ namespace YLErp } } + /// + /// 是否债券指数资产类型(永续,无到期日)。 + /// 注:ConvertCalcType 将其映射为 CommodityFutures 以复用计算路径, + /// 但保存校验不应据此强制要求到期日。 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool IsBondIndex(string instType) + => BondIndex.Equals(instType, StringComparison.OrdinalIgnoreCase); + + /// + /// 是否利率收益率曲线资产类型(无到期日)。 + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool IsRateYield(string instType) + => RateYield.Equals(instType, StringComparison.OrdinalIgnoreCase); + //------------CalcType----------------------- /// diff --git a/Framework/YLErp.Core/DBModels/underlying_manager.cs b/Framework/YLErp.Core/DBModels/underlying_manager.cs index 38138af3..2808b5f5 100644 --- a/Framework/YLErp.Core/DBModels/underlying_manager.cs +++ b/Framework/YLErp.Core/DBModels/underlying_manager.cs @@ -488,6 +488,19 @@ namespace YLErp.DBModels return ConsGlobal.InstrumentType.CalcTypeIsFutures(UnderlyingInstrumentType); } + /// + /// 标的是否需要在保存时填写到期日。 + /// 仅真正的期货合约需要;BondIndex(债券指数)/ RateYield(利率曲线)虽被 + /// ConvertCalcType 映射为 CommodityFutures 以复用计算路径,但二者永续无到期日, + /// 不应强制要求。集中此处作为唯一判定,避免 IsFutures() 判断在多处被重复收窄。 + /// + public bool RequiresMaturityDate() + { + return ConsGlobal.InstrumentType.CalcTypeIsFutures(UnderlyingInstrumentType) + && !ConsGlobal.InstrumentType.IsBondIndex(UnderlyingInstrumentType) + && !ConsGlobal.InstrumentType.IsRateYield(UnderlyingInstrumentType); + } + /// /// 标的是否债券类型 /// diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs index 3d308d0e..26a57cee 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs @@ -943,7 +943,7 @@ namespace YLErp.Modules.SwapModule throw new ServiceException("标的信息不存在:" + req.UnderlyingCode); } - if (_underlying.IsFutures() && _underlying.MaturityDate == null) + if (_underlying.RequiresMaturityDate() && _underlying.MaturityDate == null) { throw new ServiceException("标的到期日不存在:" + req.UnderlyingCode); } @@ -952,7 +952,7 @@ namespace YLErp.Modules.SwapModule req.VarietyId = _underlying.UnderlyingTypeId; req.UnderlyingAssetClass = _underlying.UnderlyingType; req.UnderlyingAssetName = _underlying.UnderlyingName; - req.MaturityDate = _underlying.IsFutures() ? _underlying.MaturityDate : null; + req.MaturityDate = _underlying.RequiresMaturityDate() ? _underlying.MaturityDate : null; req.UnderlyingInstrumentType = _underlying.GetMainType(); req.CountRatio = _underlying.CountRatio;