#EQD-6948 国联民生-实现保证金规则(2)追保金额的产生与收盘计算 收盘计算和授信占用
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using YLErp.DBModels;
|
||||
using YLErp.Modules.DataProviderModule;
|
||||
|
||||
namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
/// <summary>
|
||||
/// R2 阶段三 §3.1 收盘价取数链路冒烟测试(只读 dev 库,不构造数据):
|
||||
/// 债券净价源(china_bond_valuation,GetBondPrice 口径 SettlePrice=净价、ClosePrice=全价,≤计算日 取最近——盘中/非交易日回退到最近已有估值);
|
||||
/// 指数/ETF收盘价源(eod_stock_price)。
|
||||
/// 两个源在"价格同步作业跑完前"决定引擎行为:取不到 → 追加按0、维持=初始(见 SwapSpanMarginEngineTest.SE_004)。
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class SwapSpanPriceSourceTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void SP_001_债券估值净价源_可取且净价为正()
|
||||
{
|
||||
using var db = DbContextFactory.GetYLDbContext();
|
||||
var latest = db.china_bond_valuation
|
||||
.Where(x => x.net_price > 0 && x.dirty_price_close > 0)
|
||||
.OrderByDescending(x => x.valuation_date)
|
||||
.Select(x => new { x.valuation_date, x.bond_id })
|
||||
.FirstOrDefault();
|
||||
if (latest == null)
|
||||
{
|
||||
Assert.Inconclusive("dev 库无中债估值数据,跳过");
|
||||
}
|
||||
|
||||
//当日可取
|
||||
Assert.IsTrue(EodPriceQueryService.TryGetBondEodPrice(latest.valuation_date, latest.bond_id, out var price));
|
||||
Assert.IsTrue(price.SettlePrice > 0, "净价(SettlePrice)应为正");
|
||||
Assert.IsTrue(price.ClosePrice > 0, "全价(ClosePrice)应为正");
|
||||
|
||||
//≤计算日 取最近:往未来多取几天仍回退到最近一条估值(盘中跑引擎即此语义)
|
||||
Assert.IsTrue(EodPriceQueryService.TryGetBondEodPrice(latest.valuation_date.AddDays(5), latest.bond_id, out var fallback));
|
||||
Assert.AreEqual(price.SettlePrice, fallback.SettlePrice, 1e-9);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
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();
|
||||
if (latest == null)
|
||||
{
|
||||
Assert.Inconclusive("dev 库无股票/ETF日终价格数据,跳过");
|
||||
}
|
||||
|
||||
Assert.IsTrue(EodPriceQueryService.TryGetEodPrice(latest.ValueDate, latest.UnderlyingCode, out var price));
|
||||
Assert.IsTrue(price.GetPrice(SettlementTypeEnum.ClosePrice) > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user