From 84b5a362e89bc61c7f5627a69bf20f1c64050724 Mon Sep 17 00:00:00 2001 From: hjhan Date: Thu, 27 Aug 2026 18:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20SP=5F002=20=E5=86=92?= =?UTF-8?q?=E7=83=9F=E6=B5=8B=E8=AF=95=E4=B8=A4=E5=A4=84=E5=8F=96=E6=95=B0?= =?UTF-8?q?=E5=81=8F=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 样本 join underlying_manager:取数链路 InnerGetEodPrice 从标的表出发 join 价格表, 未登记为标的的代码取数必返回 null,冒烟样本须限定在已登记标的上 - 查询日期经 GetNonHolidayDefore 回退到最近交易日:dev 库 eod_stock_price 混有 非交易日/未来日期脏行(如 2026-08-30 周日),取数链路按交易日历向后滚到下一交易日 后无数据导致假失败 --- .../SwapModule/SwapSpanPriceSourceTest.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/UnitTestProject/Modules/SwapModule/SwapSpanPriceSourceTest.cs b/UnitTestProject/Modules/SwapModule/SwapSpanPriceSourceTest.cs index 17cd942e..94faf26b 100644 --- a/UnitTestProject/Modules/SwapModule/SwapSpanPriceSourceTest.cs +++ b/UnitTestProject/Modules/SwapModule/SwapSpanPriceSourceTest.cs @@ -1,5 +1,6 @@ using YLErp.DBModels; using YLErp.Modules.DataProviderModule; +using YLErp.QdpModule; namespace YLErp.Modules.SwapModule { @@ -40,17 +41,22 @@ namespace YLErp.Modules.SwapModule public void SP_002_ETF收盘价源_可取() { using var db = DbContextFactory.GetYLDbContext(); - var latest = db.eod_stock_price - .Where(x => x.ClosePrice > 0) - .OrderByDescending(x => x.ValueDate) - .Select(x => new { x.ValueDate, x.UnderlyingCode }) - .FirstOrDefault(); + //join underlying_manager:取数链路 InnerGetEodPrice 从标的表出发 join 价格表, + //价格表里未登记为标的的代码(同步进来的非管理标的)取数必返回 null,冒烟样本须限定在已登记标的上 + var latest = (from ep in db.eod_stock_price + where ep.ClosePrice > 0 + join um in db.underlying_manager on ep.UnderlyingCode equals um.UnderlyingCode + orderby ep.ValueDate descending + select new { ep.ValueDate, ep.UnderlyingCode }).FirstOrDefault(); if (latest == null) { Assert.Inconclusive("dev 库无股票/ETF日终价格数据,跳过"); } - Assert.IsTrue(EodPriceQueryService.TryGetEodPrice(latest.ValueDate, latest.UnderlyingCode, out var price)); + //价格表可能混有非交易日/未来日期的脏行(如 2026-08-30 周日),而取数链路会按交易日历调整日期 + //(非国君环境向后滚到下一交易日,脏行日期之后无数据 → 取不到);查询日期回退到最近交易日再验 + var queryDate = QdpCalendarHelper.GetNonHolidayDefore(latest.ValueDate.Date); + Assert.IsTrue(EodPriceQueryService.TryGetEodPrice(queryDate, latest.UnderlyingCode, out var price)); Assert.IsTrue(price.GetPrice(SettlementTypeEnum.ClosePrice) > 0); } }