Files
2024-05-09 14:06:26 +08:00

56 lines
2.1 KiB
C#

namespace YLErp.Modules.EodModule.SettlementModule
{
/// <summary>
/// 日终结算检查
/// </summary>
class EodCheckVolService : EodSettleServiceBase
{
public const string Step = "日终结算检查";
public EodCheckVolService(EodSettlementContextBase context) : base(context)
{
ResetDbContext();
}
public void Execute()
{
var clienIds = _context.Request.ClientIds;
//光大光子需要检查场内期权是否设置了波动率
if (PS.Config.Company == Configuration.CompanyEnum.光大光子)
{
var preDate = _context.PreSettleDate;
var query1 = from a in DbContext.ExchangeTrade
where a.TradeDate == _context.SettleDate && a.IsValid && a.TradeType == "场内期权"
group a by a.OptionCode into aa
select new { OptionCode = aa.Key };
var eodPosition = DbContext.eod_trade_position.AsEnumerable();
#region 新增客户筛选 tw
if (clienIds != null)
{
eodPosition = eodPosition.Where(l => clienIds.Contains(l.ClientId));
}
#endregion
var query2 = from b in eodPosition
where b.ValueDate == preDate && b.TradeType == "场内期权"
group b by b.ExchangeOptionCode into bb
select new { OptionCode = bb.Key };
var query = from a in query1.ToList().Union(query2.ToList())
where !DbContext.exchange_option_vol.Any(n => n.OptionCode == a.OptionCode && n.UseFlag == DBModels.ExchangeOptionVolUseFlag.FixedValue)
select a.OptionCode;
var codes = query.ToHashSet();
if (codes.Any())
{
var str = string.Join("、", codes);
_context.RaiseError(Step, $"请设置场内期权{str}的对冲波动率!");
}
}
}
}
}