修复 SP_002 冒烟测试两处取数偏差
- 样本 join underlying_manager:取数链路 InnerGetEodPrice 从标的表出发 join 价格表, 未登记为标的的代码取数必返回 null,冒烟样本须限定在已登记标的上 - 查询日期经 GetNonHolidayDefore 回退到最近交易日:dev 库 eod_stock_price 混有 非交易日/未来日期脏行(如 2026-08-30 周日),取数链路按交易日历向后滚到下一交易日 后无数据导致假失败
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using YLErp.DBModels;
|
using YLErp.DBModels;
|
||||||
using YLErp.Modules.DataProviderModule;
|
using YLErp.Modules.DataProviderModule;
|
||||||
|
using YLErp.QdpModule;
|
||||||
|
|
||||||
namespace YLErp.Modules.SwapModule
|
namespace YLErp.Modules.SwapModule
|
||||||
{
|
{
|
||||||
@@ -40,17 +41,22 @@ namespace YLErp.Modules.SwapModule
|
|||||||
public void SP_002_ETF收盘价源_可取()
|
public void SP_002_ETF收盘价源_可取()
|
||||||
{
|
{
|
||||||
using var db = DbContextFactory.GetYLDbContext();
|
using var db = DbContextFactory.GetYLDbContext();
|
||||||
var latest = db.eod_stock_price
|
//join underlying_manager:取数链路 InnerGetEodPrice 从标的表出发 join 价格表,
|
||||||
.Where(x => x.ClosePrice > 0)
|
//价格表里未登记为标的的代码(同步进来的非管理标的)取数必返回 null,冒烟样本须限定在已登记标的上
|
||||||
.OrderByDescending(x => x.ValueDate)
|
var latest = (from ep in db.eod_stock_price
|
||||||
.Select(x => new { x.ValueDate, x.UnderlyingCode })
|
where ep.ClosePrice > 0
|
||||||
.FirstOrDefault();
|
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)
|
if (latest == null)
|
||||||
{
|
{
|
||||||
Assert.Inconclusive("dev 库无股票/ETF日终价格数据,跳过");
|
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);
|
Assert.IsTrue(price.GetPrice(SettlementTypeEnum.ClosePrice) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user