|
|
|
@@ -13,7 +13,7 @@
|
|
|
|
|
-- 说明:结构化 RuleExpr 的固定数值不追加 m;本文件 VariableExpr 为人工维护的 C# 表达式,原有 m 后缀保持不变。
|
|
|
|
|
|
|
|
|
|
-- 插入当前数据库中的 6 条变量,保留原始 ID 以匹配规则 ConditionJson 中的 VariableId
|
|
|
|
|
INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`, `DataType`, `Unit`, `ValueDomain`, `Description`, `VariableExpr`, `Version`, `SortOrder`, `OptId`, `OptName`, `OptDate`, `UpdateOptId`, `UpdateOptName`, `UpdateDate`) VALUES
|
|
|
|
|
INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`, `DataType`, `Unit`, `ValueDomain`, `Description`, `VariableExpr`, `Status`, `Version`, `SortOrder`, `OptId`, `OptName`, `OptDate`, `UpdateOptId`, `UpdateOptName`, `UpdateDate`) VALUES
|
|
|
|
|
(1,
|
|
|
|
|
'合约名义本金',
|
|
|
|
|
1,
|
|
|
|
@@ -22,6 +22,7 @@ INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`
|
|
|
|
|
'≥ 0',
|
|
|
|
|
'',
|
|
|
|
|
'DbContext.trade.First(t => t.id == TradeId).StockEqvNotional',
|
|
|
|
|
1,
|
|
|
|
|
18,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
@@ -38,6 +39,7 @@ INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`
|
|
|
|
|
'≥ 0',
|
|
|
|
|
'当前交易对手方所有存续交易涉及的标的数量(去重)合计(含本笔)',
|
|
|
|
|
'DbContext.swap_position.Where(p => !string.IsNullOrEmpty(p.UnderlyingCode) && !p.IsInitial && p.PosiQuantity > 0 && !p.Invalid && p.PosiDirection > 0 && DbContext.trade.Any(t => t.id == p.SwapTradeId && t.ValidState != "InValid" && t.ClientId == DbContext.trade.First(x => x.id == TradeId).ClientId)).Select(p => p.UnderlyingCode).Distinct().Count()',
|
|
|
|
|
1,
|
|
|
|
|
3,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
@@ -54,6 +56,7 @@ INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`
|
|
|
|
|
'≥ 0',
|
|
|
|
|
'abs(期初标的交割净价% - 上一收盘日中债估值净价)',
|
|
|
|
|
'Math.Abs(DbContext.swap_position.First(p => p.SwapTradeId == TradeId && p.IsInitial && !p.Invalid && p.PosiDirection == 2 && !string.IsNullOrEmpty(p.UnderlyingCode)).PosiNetNoFeePrice.Value * 100 - DbContext.china_bond_valuation.Where(v => v.bond_id == DbContext.swap_position.First(p => p.SwapTradeId == TradeId && p.IsInitial && !p.Invalid && p.PosiDirection == 2 && !string.IsNullOrEmpty(p.UnderlyingCode)).UnderlyingCode && v.valuation_date < DbContext.trade.First(t => t.id == TradeId).TradeDate.Value.Date).OrderByDescending(v => v.valuation_date).First().net_price.Value)',
|
|
|
|
|
1,
|
|
|
|
|
6,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
@@ -70,6 +73,7 @@ INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`
|
|
|
|
|
'≥ 0',
|
|
|
|
|
'abs(期初标的成交收益率% - 上一收盘日中债估值收益率)',
|
|
|
|
|
'Math.Abs(DbContext.swap_position.First(p => p.SwapTradeId == TradeId && p.IsInitial && !p.Invalid && p.PosiDirection == 2 && !string.IsNullOrEmpty(p.UnderlyingCode)).InitYtm.Value * 100 - DbContext.china_bond_valuation.Where(v => v.bond_id == DbContext.swap_position.First(p => p.SwapTradeId == TradeId && p.IsInitial && !p.Invalid && p.PosiDirection == 2 && !string.IsNullOrEmpty(p.UnderlyingCode)).UnderlyingCode && v.valuation_date < DbContext.trade.First(t => t.id == TradeId).TradeDate.Value.Date).OrderBy(v => v.credibility).ThenByDescending(v => v.valuation_date).First().yield.Value)',
|
|
|
|
|
1,
|
|
|
|
|
3,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
@@ -86,6 +90,7 @@ INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`
|
|
|
|
|
'≥ 0',
|
|
|
|
|
'abs(期初标的交割全价% - 上一日标的收盘价)',
|
|
|
|
|
'Math.Abs(DbContext.swap_position.First(p => p.SwapTradeId == TradeId && p.IsInitial && !p.Invalid && p.PosiDirection == 2 && !string.IsNullOrEmpty(p.UnderlyingCode)).PosiGrossPrice * 100 - Convert.ToDecimal(DbContext.eod_commodity_future_price.Where(e => e.UnderlyingCode == DbContext.swap_position.First(p => p.SwapTradeId == TradeId && p.IsInitial && !p.Invalid && p.PosiDirection == 2 && !string.IsNullOrEmpty(p.UnderlyingCode)).UnderlyingCode && e.ValueDate < DbContext.trade.First(t => t.id == TradeId).TradeDate.Value.Date).OrderByDescending(e => e.ValueDate).First().ClosePrice))',
|
|
|
|
|
1,
|
|
|
|
|
4,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
@@ -102,6 +107,7 @@ INSERT INTO `yltrs_ylcms`.`glms_risk_variable` (`id`, `VariableName`, `Category`
|
|
|
|
|
'≥ 0',
|
|
|
|
|
'ABS(利息端利率-FR007)/FR007*100',
|
|
|
|
|
'Math.Abs(DbContext.swap_position.First(p => p.SwapTradeId == TradeId && p.InterestDirection == 1).InterestRateDefault)*100m',
|
|
|
|
|
1,
|
|
|
|
|
2,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|