山证bug修复及功能 迁移
This commit is contained in:
@@ -13,12 +13,12 @@ namespace YLErp.Modules.DataProviderModule
|
||||
/// <summary>
|
||||
/// 检查数据库是否有数据
|
||||
/// </summary>
|
||||
public static bool CheckDbExists(DateTime valueDate,DateTime preSettleDate)
|
||||
public static bool CheckDbExists(DateTime valueDate)
|
||||
{
|
||||
using var db = DbContextFactory.GetYLDbContext();
|
||||
return db.eod_commodity_future_price.Any(n => n.ValueDate == valueDate)
|
||||
|| db.eod_stock_price.Any(n => n.ValueDate == valueDate)
|
||||
|| db.china_bond_valuation.Any(n=>n.valuation_date== preSettleDate && n.dirty_price_close>0);
|
||||
|| db.china_bond_valuation.Any(n => n.valuation_date == valueDate && n.dirty_price_close > 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,7 +41,7 @@ namespace YLErp.Modules.DataProviderModule
|
||||
//日终估值全价必须有值才算
|
||||
var query = from e in db.china_bond_valuation
|
||||
where e.bond_id == underlyingCode
|
||||
&& e.valuation_date >= startDate && e.valuation_date <= valueDate &&e.dirty_price_close>0
|
||||
&& e.valuation_date >= startDate && e.valuation_date <= valueDate && e.dirty_price_close > 0
|
||||
select e;
|
||||
|
||||
return query.Any();
|
||||
@@ -110,7 +110,30 @@ namespace YLErp.Modules.DataProviderModule
|
||||
{
|
||||
return (eodPrice = GetEodPrice(valueDate, underlyingId)) != null;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取某日之前最新价格
|
||||
/// </summary>
|
||||
/// <param name="valueDate"></param>
|
||||
/// <param name="underlyingCode"></param>
|
||||
/// <param name="price"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetPrice(DateTime valueDate, string underlyingCode, out double price)
|
||||
{
|
||||
price = 0;
|
||||
|
||||
valueDate = valueDate.Date;
|
||||
using var db = DbContextFactory.GetYLDbContext();
|
||||
var data = db.eod_commodity_future_price.Where(x => x.ValueDate <= valueDate && x.UnderlyingCode == underlyingCode).OrderByDescending(o => o.ValueDate).FirstOrDefault();
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
price = data.ReferencePrice ?? 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 尝试获取标的某日的日终价
|
||||
/// </summary>
|
||||
@@ -147,14 +170,14 @@ namespace YLErp.Modules.DataProviderModule
|
||||
{
|
||||
rp1 = epCommodity.ReferencePrice,
|
||||
rp2 = epStock.ReferencePrice,
|
||||
rp3= epBond.dirty_price_close
|
||||
rp3 = epBond.dirty_price_close
|
||||
};
|
||||
|
||||
var data = eodQuery.FirstOrDefault();
|
||||
|
||||
if (data != null && (data.rp1 != null || data.rp2 != null||data.rp3 != null))
|
||||
if (data != null && (data.rp1 != null || data.rp2 != null || data.rp3 != null))
|
||||
{
|
||||
price = data.rp1 ?? data.rp2 ?? Convert.ToDouble((data.rp3??0)*ConsGlobal.bondPriceMultiple);
|
||||
price = data.rp1 ?? data.rp2 ?? Convert.ToDouble((data.rp3 ?? 0) * ConsGlobal.bondPriceMultiple);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -186,17 +209,17 @@ namespace YLErp.Modules.DataProviderModule
|
||||
public static EodPrice GetBondPrice(DateTime valueDate, string underlyingCode)
|
||||
{
|
||||
using var db = DbContextFactory.GetYLDbContext();
|
||||
var bondPrice = db.china_bond_valuation.Where(x=>x.bond_id== underlyingCode&&x.valuation_date<=valueDate).OrderByDescending(o=>o.credibility).ThenByDescending(o=>o.valuation_date).FirstOrDefault();
|
||||
if (bondPrice==null)
|
||||
var bondPrice = db.china_bond_valuation.Where(x => x.bond_id == underlyingCode && x.valuation_date <= valueDate).OrderByDescending(o => o.credibility).ThenByDescending(o => o.valuation_date).FirstOrDefault();
|
||||
if (bondPrice == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EodPrice
|
||||
{
|
||||
Vobp= bondPrice.vobp,
|
||||
Vobp = bondPrice.vobp,
|
||||
ValueDate = valueDate,
|
||||
UnderlyingCode = underlyingCode,
|
||||
ClosePrice = Convert.ToDouble(bondPrice.dirty_price_close*ConsGlobal.bondPriceMultiple),
|
||||
ClosePrice = Convert.ToDouble(bondPrice.dirty_price_close * ConsGlobal.bondPriceMultiple),
|
||||
SettlePrice = Convert.ToDouble(bondPrice.net_price * ConsGlobal.bondPriceMultiple),
|
||||
ReferencePrice = Convert.ToDouble(bondPrice.yield * ConsGlobal.bondPriceMultiple)
|
||||
};
|
||||
@@ -216,9 +239,8 @@ namespace YLErp.Modules.DataProviderModule
|
||||
}
|
||||
if (data.IsBond())
|
||||
{
|
||||
var valuedate = QdpCalendarHelper.GetNonHolidayDefore(settleDate.AddDays(-1));
|
||||
var eodBondPrice = GetBondPrice(valuedate, code);
|
||||
return eodBondPrice?.ClosePrice??0;
|
||||
var eodBondPrice = GetBondPrice(settleDate, code);
|
||||
return eodBondPrice?.ClosePrice ?? 0;
|
||||
}
|
||||
var price = data.Price ?? 0;
|
||||
if (TryGetEodPrice(settleDate, code, out var eodPrice))
|
||||
|
||||
Reference in New Issue
Block a user