diff --git a/Framework/YLErp.Core/DBModels/EodSwap.cs b/Framework/YLErp.Core/DBModels/EodSwap.cs index ba06c492..61f2289a 100644 --- a/Framework/YLErp.Core/DBModels/EodSwap.cs +++ b/Framework/YLErp.Core/DBModels/EodSwap.cs @@ -148,29 +148,6 @@ namespace YLErp.DBModels [DataChange] public decimal TdCloseQty { get; set; } /// - /// 是否跳过收盘 - /// - public bool IsSkipEod { get; set; } = false; - /// - /// dv01值 - /// - public decimal? DV01 { get; set; } = 0; - - /// - /// 衡泰合约持仓价值 - /// - public decimal HTPostionValue { get; set; } - - /// - /// 衡泰合约浮动端待实现收益 - /// - public decimal HTFloatingPnL { get; set; } - - /// - /// 虚拟交易费用 - /// - public decimal VTradingFee { get; set; } - /// /// 平仓起始日期 /// [NotMapped] diff --git a/Framework/YLErp.Core/DBModels/EodSwapPosition.cs b/Framework/YLErp.Core/DBModels/EodSwapPosition.cs index a9cf05e8..492f3bf9 100644 --- a/Framework/YLErp.Core/DBModels/EodSwapPosition.cs +++ b/Framework/YLErp.Core/DBModels/EodSwapPosition.cs @@ -404,11 +404,6 @@ namespace YLErp.DBModels /// public string Currency { get; set; } - /// - /// 是否跳过收盘 - /// - public bool IsSkipEod { get; set; }=false; - /// /// 标的资产类型 /// @@ -421,20 +416,6 @@ namespace YLErp.DBModels /// 成交净价不含费 /// public decimal? PosiNetNoFeePrice { get; set; } - /// - /// dv01值 - /// - public decimal? DV01 { get; set; } - - /// - /// 衡泰互换持仓价值 - /// - public decimal HTSwapPositionValue { get; set; } - - /// - /// 衡泰浮动端的所有待实现收益(当前浮动腿的价值) - /// - public decimal HTPosiProfitSum { get; set; } /// /// 虚拟交易费用 diff --git a/Framework/YLErp.Core/DBModels/QuotaMonitor.cs b/Framework/YLErp.Core/DBModels/QuotaMonitor.cs index 6ab6b5ff..25ade440 100644 --- a/Framework/YLErp.Core/DBModels/QuotaMonitor.cs +++ b/Framework/YLErp.Core/DBModels/QuotaMonitor.cs @@ -697,32 +697,6 @@ namespace YLErp.DBModels /// 信用风险敞口 /// public double? CreditExposure { get; set; } - - public double? Quota_DV01 { get; set; } - - /// - /// DV01警告 - /// - [NotMapped] - public double? Quota_DV01_wLower { get; set; } = double.NaN; - - /// - /// DV01限额 - /// - [NotMapped] - public double? Quota_DV01_Upper { get; set; } = double.NaN; - - /// - /// DV01限额 - /// - [NotMapped] - public double? Quota_DV01_Lower { get; set; } = double.NaN; - - /// - /// DV01警告 - /// - [NotMapped] - public double? Quota_DV01_wUpper { get; set; } = double.NaN; } /// @@ -920,30 +894,6 @@ namespace YLErp.DBModels /// CCR /// public double? Quota_CCR { get; set; } = double.NaN; - - /// - /// DV01 - /// - public double? Quota_DV01 { get; set;} = double.NaN; - /// - /// DV01警告 - /// - public double? Quota_DV01_wLower { get; set; } = double.NaN; - - /// - /// DV01限额 - /// - public double? Quota_DV01_Upper { get; set; } = double.NaN; - - /// - /// DV01限额 - /// - public double? Quota_DV01_Lower { get; set; } = double.NaN; - - /// - /// DV01警告 - /// - public double? Quota_DV01_wUpper { get; set; } = double.NaN; } /// @@ -1311,15 +1261,5 @@ namespace YLErp.DBModels public double? Quota_ThisYearTotalPnl_Lower { get; set; } = double.NaN; public double? Quota_ThisYearTotalPnl_wUpper { get; set; } = double.NaN; public double? Quota_ThisYearTotalPnl_wLower { get; set; } = double.NaN; - - public double? Quota_DV01 { get; set; } = double.NaN; - [NotMapped] - public double? Quota_DV01_Upper { get; set; } = double.NaN; - [NotMapped] - public double? Quota_DV01_Lower { get; set; } = double.NaN; - [NotMapped] - public double? Quota_DV01_wUpper { get; set; } = double.NaN; - [NotMapped] - public double? Quota_DV01_wLower { get; set; } = double.NaN; } } diff --git a/Framework/YLErp.Core/Enums/QuotaMonitorEnums.cs b/Framework/YLErp.Core/Enums/QuotaMonitorEnums.cs index 18980071..18486318 100644 --- a/Framework/YLErp.Core/Enums/QuotaMonitorEnums.cs +++ b/Framework/YLErp.Core/Enums/QuotaMonitorEnums.cs @@ -111,7 +111,7 @@ namespace YLErp.Enums { return new List() { - new SelectItem() {Text="全局",Value="16" }, + //new SelectItem() {Text="全局",Value="16" }, //new SelectItem() {Text="场外业务",Value="0" }, //new SelectItem() {Text="场外期权",Value="1" }, new SelectItem() {Text="互换",Value="2" }, diff --git a/Framework/YLErp.Core/Models/ClientSettleBalance.cs b/Framework/YLErp.Core/Models/ClientSettleBalance.cs index 4442ebb6..ed79be8e 100644 --- a/Framework/YLErp.Core/Models/ClientSettleBalance.cs +++ b/Framework/YLErp.Core/Models/ClientSettleBalance.cs @@ -1063,10 +1063,6 @@ namespace YLErp.Models /// [NotMapped] public string LastHTSettlemetTime { get; set; } - /// - /// dv01值汇总 - /// - public double DV01Count { get; set; } public double MaintenanceLine { get; set; } diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index 20cd440a..420b0d81 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -1426,7 +1426,6 @@ namespace YLErp.BLL.Eod balance.RoundedPositionPnl += Math.Round(Convert.ToDouble(pnl), 2); //期权空头浮动盈利=∑max(期权空头持仓*(期权合约成本价-期权合约现价), 0) 从客户角度看的 balance.ClientSellPositionPnl += Convert.ToDouble(eodSwap.FloatingPnL); - balance.DV01Count += Convert.ToDouble(eodSwap.DV01); } } diff --git a/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs b/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs index af1b278e..df7b4f86 100644 --- a/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs +++ b/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs @@ -1351,7 +1351,6 @@ namespace YLErp.BLL.Eod VegaCash = NumberExtensions.Norm(optionValueResult.VegaCash), UnderlyingPrice = optionValueResult.SpotPrice, - DV01 = optionValueResult.DV01 }; result.DeltaInLots = TradeLotsCalc.CalcDeltaInLots(result.Delta ?? 0, variety, udm); diff --git a/YLErpDAL/Model/CheckQuotaMoitorModel.cs b/YLErpDAL/Model/CheckQuotaMoitorModel.cs index 647e1c92..b4c2c4e2 100644 --- a/YLErpDAL/Model/CheckQuotaMoitorModel.cs +++ b/YLErpDAL/Model/CheckQuotaMoitorModel.cs @@ -40,10 +40,6 @@ namespace YLErp.Model public decimal Commision { get; set; } /// - /// dv01 - /// - public decimal DV01 { get; set; } - /// /// 持仓市值 /// public decimal Pv { get; set; } diff --git a/YLErpDAL/Model/RealtimeTradeRisk.cs b/YLErpDAL/Model/RealtimeTradeRisk.cs index 6d0cd5d1..fc379e89 100644 --- a/YLErpDAL/Model/RealtimeTradeRisk.cs +++ b/YLErpDAL/Model/RealtimeTradeRisk.cs @@ -159,10 +159,6 @@ namespace YLErp.DBModels /// [DisplayName("信用风险敞口")] public double CreditExposure { get; set; } - /// - /// DV01值 - /// - public double? DV01 { get; set; } public realtime_trade_risk Clone() { return (realtime_trade_risk)MemberwiseClone(); diff --git a/YLErpDAL/Modules/CalculationModule/Models/TradeValueResult.cs b/YLErpDAL/Modules/CalculationModule/Models/TradeValueResult.cs index 70afbbd5..f28cd464 100644 --- a/YLErpDAL/Modules/CalculationModule/Models/TradeValueResult.cs +++ b/YLErpDAL/Modules/CalculationModule/Models/TradeValueResult.cs @@ -495,11 +495,6 @@ namespace YLErp.Modules.CalculationModule /// Theta(轧差) /// public double ThetaNet { get; set; } - - /// - /// dv01值 - /// - public double DV01 { get; set; } } public class TradeValueResultExtend diff --git a/YLErpDAL/Modules/CalculationModule/PayoffSwapCalcService.cs b/YLErpDAL/Modules/CalculationModule/PayoffSwapCalcService.cs index 95d1ffe9..8dad5329 100644 --- a/YLErpDAL/Modules/CalculationModule/PayoffSwapCalcService.cs +++ b/YLErpDAL/Modules/CalculationModule/PayoffSwapCalcService.cs @@ -136,8 +136,7 @@ namespace YLErp.Modules.CalculationModule Rho = 0, DeltaCash = (lastEodSwap.MarketValueLong > 0 ? spotPrice : -spotPrice) * trade.Notional, GammaCash = 0, - SpotPrice= spotPrice, - DV01= Convert.ToDouble(lastEodSwap.DV01) + SpotPrice= spotPrice }; return OptionValue; @@ -158,7 +157,6 @@ namespace YLErp.Modules.CalculationModule eodSwap.NotionalValueLong = positions.Where(x => x.PositionType == (int)PositionTypeFlag.Long).Sum(s => s.PosiNotionalValue); eodSwap.NotionalValueShort = positions.Where(x => x.PositionType == (int)PositionTypeFlag.Short).Sum(s => s.PosiNotionalValue); eodSwap.NotionalValue = eodSwap.NotionalValueLong + eodSwap.NotionalValueShort; - eodSwap.DV01 = 0; var lastEod = db.eod_swap.Where(x => x.SwapTradeId == trade.id).OrderByDescending(o => o.ValueDate).FirstOrDefault(); eodSwap.RealizedPnL = lastEod?.RealizedPnL ?? 0; eodSwap.InterestPnL = lastEod?.InterestPnL ?? 0; @@ -168,14 +166,12 @@ namespace YLErp.Modules.CalculationModule int directionRatio = item.PosiDirection == (int)SwapDirectionEnum.收取 ? 1 : -1; var pv = item.PosiQuantity * shortRatio * item.ContractSize; var pvNoPrice = item.PosiQuantity * item.ContractSize; - decimal vobp = 0; var data = DataCacheProvider.GetUnderlyingDataSource().GetData(item.UnderlyingCode); if (data != null) { if (data.IsBond()) { var bondPrice = EodPriceQueryService.GetBondPrice(valuedateBLL.ValueDate, data.UnderlyingCode); - vobp = bondPrice?.Vobp ?? 0; var price = Convert.ToDecimal(bondPrice?.ClosePrice??0); eodSwap.FloatingPnL = (price - item.PosiGrossPrice) * item.PosiQuantity * item.ContractSize * shortRatio * directionRatio; } @@ -189,7 +185,6 @@ namespace YLErp.Modules.CalculationModule eodSwap.MarketValueShort += pv; } eodSwap.NotionalValue += pvNoPrice; - eodSwap.DV01 += pvNoPrice * vobp * shortRatio * directionRatio * 0.01m; } eodSwap.PostionValue = eodSwap.InterestPnL + eodSwap.FloatingPnL; return eodSwap; diff --git a/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs b/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs index 8fc1eb00..2b58766e 100644 --- a/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs +++ b/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs @@ -381,11 +381,6 @@ namespace YLErp.Modules.RiskModule O.Quota_HoldingFund_Lower = O.Quota_HoldingFund_Lower.IsNormalize() ? O.Quota_HoldingFund_Lower : null; O.Quota_HoldingFund_wUpper = O.Quota_HoldingFund_wUpper.IsNormalize() ? O.Quota_HoldingFund_wUpper : null; O.Quota_HoldingFund_wLower = O.Quota_HoldingFund_wLower.IsNormalize() ? O.Quota_HoldingFund_wLower : null; - O.Quota_DV01 = O.Quota_DV01.IsNormalize() ? O.Quota_DV01 : null; - O.Quota_DV01_Upper = O.Quota_DV01_Upper.IsNormalize() ? O.Quota_DV01_Upper : null; - O.Quota_DV01_Lower = O.Quota_DV01_Lower.IsNormalize() ? O.Quota_DV01_Lower : null; - O.Quota_DV01_wUpper = O.Quota_DV01_wUpper.IsNormalize() ? O.Quota_DV01_wUpper : null; - O.Quota_DV01_wLower = O.Quota_DV01_wLower.IsNormalize() ? O.Quota_DV01_wLower : null; }); DbContext.QuotaMonitor_Client.AddRange(list); } @@ -435,11 +430,6 @@ namespace YLErp.Modules.RiskModule O.Quota_SwapPercent_Lower = O.Quota_SwapPercent_Lower.IsNormalize() ? O.Quota_SwapPercent_Lower : null; O.Quota_SwapPercent_wUpper = O.Quota_SwapPercent_wUpper.IsNormalize() ? O.Quota_SwapPercent_wUpper : null; O.Quota_SwapPercent_wLower = O.Quota_SwapPercent_wLower.IsNormalize() ? O.Quota_SwapPercent_wLower : null; - O.Quota_DV01 = O.Quota_DV01.IsNormalize() ? O.Quota_DV01 : null; - O.Quota_DV01_Upper = O.Quota_DV01_Upper.IsNormalize() ? O.Quota_DV01_Upper : null; - O.Quota_DV01_Lower = O.Quota_DV01_Lower.IsNormalize() ? O.Quota_DV01_Lower : null; - O.Quota_DV01_wUpper = O.Quota_DV01_wUpper.IsNormalize() ? O.Quota_DV01_wUpper : null; - O.Quota_DV01_wLower = O.Quota_DV01_wLower.IsNormalize() ? O.Quota_DV01_wLower : null; }); DbContext.QuotaMonitor_Trade.AddRange(list); } @@ -706,16 +696,6 @@ namespace YLErp.Modules.RiskModule { //SetDebugSqlLog(); var list = QueryFromDb(req); - var allSetting = QueryCurrentQuotaSetting(QuotaTypeEnum.GLOBAL_ALL); - var dv01Settings = allSetting.Where(O => O.IsValid && O.Status == QuotaSettingApprovalStatus.Valid && O.QuotaRange == 0 && O.QuotaIndex == "DV01").FirstOrDefault()?.Clone(); - var types = new[] { "互换" }; - list.ForEach(O => - { - O.Quota_DV01_Upper = dv01Settings?.QuotaUpperLimit ?? double.NaN; - O.Quota_DV01_Lower = dv01Settings?.QuotaLowerLimit ?? double.NaN; - O.Quota_DV01_wUpper = dv01Settings?.WarningUpperLimit ?? double.NaN; - O.Quota_DV01_wLower = dv01Settings?.WarningLowerLimit ?? double.NaN; - }); list.Reverse(); return list; } @@ -728,28 +708,7 @@ namespace YLErp.Modules.RiskModule public List QueryClientFromDb(QuotaMonitorReq req) { var list = QueryFromDb(req); - var allSetting = QueryCurrentQuotaSetting(QuotaTypeEnum.CLIENT).Where(O => O.IsValid && O.Status == QuotaSettingApprovalStatus.Valid && O.QuotaIndex == "DV01"); - var dv01Settings = allSetting.Where(O => O.QuotaRange == 0).FirstOrDefault()?.Clone(); var types = new[] { "互换" }; - list.ForEach(O => - { - var clientDv01 = allSetting.FirstOrDefault(x => x.QuotaRange == O.ClientId); - if (clientDv01 != null) - { - O.Quota_DV01_Upper = clientDv01.QuotaUpperLimit; - O.Quota_DV01_Lower = clientDv01.QuotaLowerLimit; - O.Quota_DV01_wUpper = clientDv01.WarningUpperLimit; - O.Quota_DV01_wLower = clientDv01.WarningLowerLimit; - } - else - { - O.Quota_DV01_Upper = dv01Settings?.QuotaUpperLimit ?? double.NaN; - O.Quota_DV01_Lower = dv01Settings?.QuotaLowerLimit ?? double.NaN; - O.Quota_DV01_wUpper = dv01Settings?.WarningUpperLimit ?? double.NaN; - O.Quota_DV01_wLower = dv01Settings?.WarningLowerLimit ?? double.NaN; - } - - }); if (req.ClientId > 0) { var clientName = DataCacheProvider.GetClientDataSource().GetData(req.ClientId)?.Name; @@ -947,7 +906,6 @@ namespace YLErp.Modules.RiskModule obj.VegaCash = dict[obj.BusinessType].Sum(O => O.risk.VegaCash.Normalize()); obj.GammaCash = dict[obj.BusinessType].Sum(O => O.risk.GammaCash.Normalize()); obj.Theta = dict[obj.BusinessType].Sum(O => O.risk.Theta.Normalize()); - obj.Quota_DV01 = dict[obj.BusinessType].Sum(O => O.risk.DV01.Normalize()); var equitySettings = settings.Where(O => O.IsValid && O.Status == QuotaSettingApprovalStatus.Valid && O.QuotaRange == 0 && O.QuotaIndex == "权益类业务规模").FirstOrDefault()?.Clone(); obj.Quota_EquityRiskScale_Upper = equitySettings?.QuotaUpperLimit ?? double.NaN; obj.Quota_EquityRiskScale_Lower = equitySettings?.QuotaLowerLimit ?? double.NaN; @@ -1043,18 +1001,10 @@ namespace YLErp.Modules.RiskModule obj.Quota_ThisYearTotalPnl_wUpper = totalPnlSettings?.WarningUpperLimit ?? double.NaN; obj.Quota_ThisYearTotalPnl_wLower = totalPnlSettings?.WarningLowerLimit ?? double.NaN; - var dv01Settings = settings.Where(O => O.IsValid && O.Status == QuotaSettingApprovalStatus.Valid && O.QuotaRange == 0 && O.QuotaIndex == "DV01").FirstOrDefault()?.Clone(); - obj.Quota_DV01_Upper = dv01Settings?.QuotaUpperLimit ?? double.NaN; - obj.Quota_DV01_Lower = dv01Settings?.QuotaLowerLimit ?? double.NaN; - obj.Quota_DV01_wUpper = dv01Settings?.WarningUpperLimit ?? double.NaN; - obj.Quota_DV01_wLower = dv01Settings?.WarningLowerLimit ?? double.NaN; - - }); var allSetting = QueryCurrentQuotaSetting(QuotaTypeEnum.GLOBAL_ALL); allSetting = MargeQuotaSetting(allSetting, 0, 0); - var dv01Settings = allSetting.Where(O => O.IsValid && O.Status == QuotaSettingApprovalStatus.Valid && O.QuotaIndex == "DV01").FirstOrDefault()?.Clone(); var swapSetting = QueryCurrentQuotaSetting(QuotaTypeEnum.GLOBAL_SWAP); swapSetting = MargeQuotaSetting(swapSetting, 0, 0); var swap = new QuotaMonitor_Global() @@ -1065,8 +1015,7 @@ namespace YLErp.Modules.RiskModule setValue(swap, swapSetting); var positionList = new List>(); - double underPnl = 0; - var gloabDv01 = GetTradePositionDv01(ref underPnl); + var gloabPnl = GetTradePositionPnl(); if (dict.ContainsKey("互换")) { var swapPositionList = dict["互换"].Select(O => new KeyValuePair(O.t, O.risk)); @@ -1092,31 +1041,23 @@ namespace YLErp.Modules.RiskModule swap.NonEquityRiskScale = swapNonEquity; var checkPosiList = GetCheckPosiList(); var posiStockEqvNotional = checkPosiList.Sum(s => s.Pv); - var posiDv01 = checkPosiList.Sum(s => s.DV01); var underly = new QuotaMonitor_Global() { ParentKey = "场外", BusinessType = "标的交易", - Quota_DV01 = gloabDv01, - PositionPnl = underPnl + PositionPnl = gloabPnl }; var unTrade = new QuotaMonitor_Global() { ParentKey = "场外", BusinessType = "未簿记合约", - StockEqvNotional = Convert.ToDouble(posiStockEqvNotional) - swap.StockEqvNotional.Normalize(), - Quota_DV01 = Convert.ToDouble(posiDv01) - swap.Quota_DV01.Normalize(), + StockEqvNotional = Convert.ToDouble(posiStockEqvNotional) - swap.StockEqvNotional.Normalize() }; var all = new QuotaMonitor_Global() { BusinessType = "全局", StockEqvNotional = Convert.ToDouble(posiStockEqvNotional), - PositionPnl = underly.PositionPnl + swap.PositionPnl, - Quota_DV01_Upper = dv01Settings?.QuotaUpperLimit ?? double.NaN, - Quota_DV01_Lower = dv01Settings?.QuotaLowerLimit ?? double.NaN, - Quota_DV01_wUpper = dv01Settings?.WarningUpperLimit ?? double.NaN, - Quota_DV01_wLower = dv01Settings?.WarningLowerLimit ?? double.NaN, - Quota_DV01 = swap.Quota_DV01.Normalize() + underly.Quota_DV01.Normalize() + unTrade.Quota_DV01.Normalize(), + PositionPnl = underly.PositionPnl + swap.PositionPnl }; var list = new List { @@ -1198,8 +1139,7 @@ namespace YLErp.Modules.RiskModule StockEqvNotional = t.ParentTradeId > 0 ? 0 : t.StockEqvNotional, t.BuySell, TradePrice = t.TradeType == "结构化交易" ? 0 : t.TradePrice, - InitialMargin = t.TradeType == "结构化交易" ? 0 : t.InitialMargin, - dv01 = risk.DV01 + InitialMargin = t.TradeType == "结构化交易" ? 0 : t.InitialMargin }; if (req.ClientId != 0) { @@ -1240,18 +1180,6 @@ namespace YLErp.Modules.RiskModule obj.Quota_HoldingFund_Lower = holdingFundSettings?.QuotaLowerLimit ?? double.NaN; obj.Quota_HoldingFund_wUpper = holdingFundSettings?.WarningUpperLimit ?? double.NaN; obj.Quota_HoldingFund_wLower = holdingFundSettings?.WarningLowerLimit ?? double.NaN; - - var dv01Settings = temp.Where(O => O.QuotaIndex == "DV01" && O.QuotaRange == 0).FirstOrDefault()?.Clone(); - var dv01SettingsClient = temp.Where(O => O.QuotaIndex == "DV01" && O.QuotaRange == obj.ClientId).FirstOrDefault()?.Clone(); - if (dv01SettingsClient != null) - { - dv01Settings = dv01SettingsClient.Clone(); - } - dv01Settings?.ConvertToAbs(obj.ProductScale.GetValueOrDefault()); - obj.Quota_DV01_Upper = dv01Settings?.QuotaUpperLimit ?? double.NaN; - obj.Quota_DV01_Lower = dv01Settings?.QuotaLowerLimit ?? double.NaN; - obj.Quota_DV01_wUpper = dv01Settings?.WarningUpperLimit ?? double.NaN; - obj.Quota_DV01_wLower = dv01Settings?.WarningLowerLimit ?? double.NaN; }); var list = new List(); @@ -1331,7 +1259,6 @@ namespace YLErp.Modules.RiskModule } } c.CreditExposure = creditExposureDict.ContainsKey(item.ClientId) ? creditExposureDict[item.ClientId] : null; - c.Quota_DV01 = positionDict.ContainsKey(client.id) ? positionDict[client.id].Sum(O => O.dv01) : double.NaN; list.Add(c); } var totalProductScale = list.Sum(O => O.ProductScale) ?? 0; @@ -1351,8 +1278,7 @@ namespace YLErp.Modules.RiskModule PayableFund = list.Sum(O => O.PayableFund), ProductScale = list.Sum(O => O.ProductScale), HoldingFund = list.Sum(O => O.HoldingFund), - ClientId = 0, - Quota_DV01 = list.Sum(O => O.Quota_DV01), + ClientId = 0 }; total.HoldingRate = (total.HoldingFund / total.ProductScale).Normalize(); total.AvailableStockEqvNotional = total.StockEqvNotionalScale - total.StockEqvNotional; @@ -1436,8 +1362,7 @@ namespace YLErp.Modules.RiskModule GammaCash = risk.GammaCash ?? 0, Vega = risk.Vega ?? 0, VegaCash = risk.VegaCash ?? 0, - PnL = (PS.Config.IsPVRounded ? risk.RoundedPositionPnl : risk.PositionPnl) ?? 0 + risk.RealizedPnl, - Quota_DV01 = risk.DV01 + PnL = (PS.Config.IsPVRounded ? risk.RoundedPositionPnl : risk.PositionPnl) ?? 0 + risk.RealizedPnl }; var list = query.ToList(); @@ -1491,12 +1416,6 @@ namespace YLErp.Modules.RiskModule obj.Quota_SwapPercent_Lower = swapPercentSetting?.QuotaLowerLimit ?? double.NaN; obj.Quota_SwapPercent_wUpper = swapPercentSetting?.WarningUpperLimit ?? double.NaN; obj.Quota_SwapPercent_wLower = swapPercentSetting?.WarningLowerLimit ?? double.NaN; - - var dv01Setting = temp.Where(O => O.QuotaIndex == "DV01").FirstOrDefault()?.Clone(); - obj.Quota_DV01_Upper = dv01Setting?.QuotaUpperLimit ?? double.NaN; - obj.Quota_DV01_Lower = dv01Setting?.QuotaLowerLimit ?? double.NaN; - obj.Quota_DV01_wUpper = dv01Setting?.WarningUpperLimit ?? double.NaN; - obj.Quota_DV01_wLower = dv01Setting?.WarningLowerLimit ?? double.NaN; }); var setting = QueryCurrentQuotaSetting(QuotaTypeEnum.TRADE); @@ -1529,8 +1448,7 @@ namespace YLErp.Modules.RiskModule Vega = result.Sum(O => O.Vega), VegaCash = result.Sum(O => O.VegaCash), Quota_CCR = result.Sum(O => O.Quota_CCR), - PnL = result.Sum(O => O.PnL), - Quota_DV01 = result.Sum(O => O.Quota_DV01), + PnL = result.Sum(O => O.PnL) }; result.Add(total); @@ -3462,20 +3380,6 @@ namespace YLErp.Modules.RiskModule singleUnderlyingRate = valuedateBLL.SystemDate.SingleUnderlyingRate; _quotaSettings = new List(); #region 整体业务 - //整体业务-止损金额 - _quotaSettings.Add(new QuotaSetting() - { - QuotaType = QuotaTypeEnum.GLOBAL_ALL, - QuotaRange = 0, - QuotaIndex = "DV01", - QuotaLowerLimit = null, - QuotaUpperLimit = null, - WarningLowerLimit = null, - WarningUpperLimit = null, - Percent = false, - IsValid = true, - Status = QuotaSettingApprovalStatus.Valid, - }); #endregion #region 互换 @@ -3522,20 +3426,7 @@ namespace YLErp.Modules.RiskModule IsValid = true, Status = QuotaSettingApprovalStatus.Valid, }); - //互换-DV01 - _quotaSettings.Add(new QuotaSetting() - { - QuotaType = QuotaTypeEnum.GLOBAL_SWAP, - QuotaRange = 0, - QuotaIndex = "DV01", - QuotaLowerLimit = null, - QuotaUpperLimit = null, - WarningLowerLimit = null, - WarningUpperLimit = null, - Percent = false, - IsValid = true, - Status = QuotaSettingApprovalStatus.Valid, - }); + #endregion #region 标的资产 @@ -3627,20 +3518,7 @@ namespace YLErp.Modules.RiskModule IsValid = true, Status = QuotaSettingApprovalStatus.Valid, }); - //交易-DV01 - _quotaSettings.Add(new QuotaSetting() - { - QuotaType = QuotaTypeEnum.TRADE, - QuotaRange = 0, - QuotaIndex = "DV01", - QuotaLowerLimit = null, - QuotaUpperLimit = null, - WarningLowerLimit = null, - WarningUpperLimit = null, - Percent = false, - IsValid = true, - Status = QuotaSettingApprovalStatus.Valid, - }); + #endregion #region 客户 @@ -3658,20 +3536,7 @@ namespace YLErp.Modules.RiskModule IsValid = true, Status = QuotaSettingApprovalStatus.Valid, }); - //客户-DV01 - _quotaSettings.Add(new QuotaSetting() - { - QuotaType = QuotaTypeEnum.CLIENT, - QuotaRange = 0, - QuotaIndex = "DV01", - QuotaLowerLimit = null, - QuotaUpperLimit = null, - WarningLowerLimit = null, - WarningUpperLimit = null, - Percent = false, - IsValid = true, - Status = QuotaSettingApprovalStatus.Valid, - }); + #endregion if (PS.Config.Company != Configuration.CompanyEnum.天风) { @@ -4396,7 +4261,6 @@ namespace YLErp.Modules.RiskModule { List clientRiskCheckResps = new List(); var allList = QueryPrecheckQuotaSetting(false); - allList = allList.Where(x => x.QuotaIndex != "DV01").ToList(); ; var precheckQuotaSettingList = allList.Where(O => O.Precheck).ToList(); List quotaIndexs = new List() { "名义本金", "轧差集中度", "轧差名义本金" }; if (clientRiskCheckReq.isClient) @@ -4451,7 +4315,6 @@ namespace YLErp.Modules.RiskModule foreach (var item in clientPositions) { var dealDate = DateTime.Parse(clientRiskCheckReq.dealDate); - decimal vobp = 0; double lastPrice = 0; var um = ums.FirstOrDefault(x => x.UnderlyingCode == item.security_id); CheckQuotaMoitorModel checkQuotaMoitorModel = new CheckQuotaMoitorModel(); @@ -4489,17 +4352,14 @@ namespace YLErp.Modules.RiskModule checkQuotaMoitorModel.NowPrice *= ConsGlobal.bondPriceMultiple; var bondPrice = EodPriceQueryService.GetBondPrice(dealDate, item.security_id); lastPrice = bondPrice != null ? bondPrice.ClosePrice : (um.Price ?? 0) * Convert.ToDouble(ConsGlobal.bondPriceMultiple); - vobp = bondPrice != null ? bondPrice.Vobp ?? 0 : 0; var bond = JsonHelper.Deserialize(um.ExJson); checkQuotaMoitorModel.Circulation = (bond.IssueSize * 100000000m) ?? 0; } } var ratio = checkQuotaMoitorModel.Side == 0 ? 1 : -1; var directionRatio = checkQuotaMoitorModel.Direction == (int)SwapDirectionEnum.收取 ? 1 : -1; - vobp = vobp * ratio * directionRatio; checkQuotaMoitorModel.LastPrice = Convert.ToDecimal(lastPrice); checkQuotaMoitorModel.Pnl = (checkQuotaMoitorModel.NowPrice - checkQuotaMoitorModel.Price) * checkQuotaMoitorModel.Qty; - checkQuotaMoitorModel.DV01 = vobp * checkQuotaMoitorModel.Qty * checkQuotaMoitorModel.ContractSize * 0.01m; checkQuotaMoitorModel.Current = checkQuotaMoitorModel.id == 0; checkPoisiList.Add(checkQuotaMoitorModel); } @@ -4567,7 +4427,6 @@ namespace YLErp.Modules.RiskModule vobp = vobp * ratio * directionRatio; checkQuotaMoitorModel.LastPrice = Convert.ToDecimal(lastPrice); checkQuotaMoitorModel.Pnl = (checkQuotaMoitorModel.NowPrice - checkQuotaMoitorModel.Price) * checkQuotaMoitorModel.Qty; - checkQuotaMoitorModel.DV01 = vobp * checkQuotaMoitorModel.Qty * checkQuotaMoitorModel.ContractSize * 0.01m; checkQuotaMoitorModel.Current = checkQuotaMoitorModel.id == 0; checkPoisiList.Add(checkQuotaMoitorModel); } @@ -4725,7 +4584,6 @@ namespace YLErp.Modules.RiskModule vobp = vobp * ratio * directionRatio; checkQuotaMoitorModel.LastPrice = Convert.ToDecimal(lastPrice); checkQuotaMoitorModel.Pnl = (checkQuotaMoitorModel.NowPrice - checkQuotaMoitorModel.Price) * checkQuotaMoitorModel.Qty; - checkQuotaMoitorModel.DV01 = vobp * checkQuotaMoitorModel.Qty * checkQuotaMoitorModel.ContractSize * 0.01m; checkQuotaMoitorModel.Current = checkQuotaMoitorModel.id == 0; checkPoisiList.Add(checkQuotaMoitorModel); } @@ -5083,9 +4941,6 @@ namespace YLErp.Modules.RiskModule { switch (item.Key.QuotaType) { - case QuotaTypeEnum.GLOBAL_ALL: - msgList.AddRange(checkGlobalAll(positionList, posiList, "全局", item.Value, warning)); - break; case QuotaTypeEnum.GLOBAL_SWAP: msgList.AddRange(checkGlobal(positionList, posiList, "场外业务-互换", item.Value, warning)); break; @@ -5150,9 +5005,6 @@ namespace YLErp.Modules.RiskModule var positionListAll = positionList; switch (quotaType) { - case QuotaTypeEnum.GLOBAL_ALL: - checkItem = checkGlobalAll(positionList, checkItem); - break; case QuotaTypeEnum.GLOBAL_SWAP: checkItem = checkGlobal(positionList, "场外业务-互换", checkItem, quotaType); break; @@ -5180,78 +5032,11 @@ namespace YLErp.Modules.RiskModule return checkItem; } - private List checkGlobalAll(List positionList, List posiList, string tag_prefix, QuotaSetting[] settings, bool warning) - { - var messageList = new List(); - double? upperLimit, lowerLimit, currentValue = null; - var dealDate = QdpCalendarHelper.GetNonHolidayDefore(valuedateBLL.ValueDate.AddDays(-1)); - foreach (var settingItem in settings) - { - if (warning) - { - upperLimit = settingItem.WarningUpperLimit; - lowerLimit = settingItem.WarningLowerLimit; - } - else - { - upperLimit = settingItem.QuotaUpperLimit; - lowerLimit = settingItem.QuotaLowerLimit; - } - - if (upperLimit == null && lowerLimit == null) - { - continue; - } - currentValue = null; - var tag = $"{tag_prefix}({settingItem.QuotaIndex})"; - CheckQuotaMoitorModel current = positionList.FirstOrDefault(x => x.Current); - double pnl = 0; - switch (settingItem.QuotaIndex) - { - case "DV01": - var uDv = GetTradePositionDv01(ref pnl); - currentValue = uDv; - var tradePosiVal = posiList.Sum(s => s.DV01); - var posiVal = positionList.Where(x => !x.Current).Sum(s => s.DV01); - var _posiVal = currentValue + Convert.ToDouble(posiVal); - var noPosiVal = posiVal - tradePosiVal; - currentValue += Convert.ToDouble(positionList.Sum(s => s.DV01)); - messageList.Add(SetQuotaMsg(tag, settingItem.QuotaIndex, currentValue, Convert.ToDouble(tradePosiVal), _posiVal, Convert.ToDouble(current.DV01), Convert.ToDouble(noPosiVal), uDv, upperLimit, lowerLimit, settingItem.Percent, warning)); - break; - default: - continue; - } - } - return messageList; - } - - private ClientRiskCheckItem checkGlobalAll(List positionList, ClientRiskCheckItem checkItem) - { - double? currentValue = null; - double tradeValue = 0; - double pnl = 0; - switch (checkItem.quotaType) - { - case "DV01": - tradeValue = GetTradePositionDv01(ref pnl); - currentValue = tradeValue + Convert.ToDouble(positionList.Sum(s => s.DV01)); - var posiVal = positionList.Where(x => !x.Current).Sum(s => s.DV01); - if (!ValidateQuoteResult(checkItem, currentValue, Convert.ToDouble(posiVal) + tradeValue)) - { - return checkItem; - } - break; - default: - return null; - } - return null; - } - /// - /// 算标的交易dv01 + /// 算标的交易盈亏 /// /// - private double GetTradePositionDv01(ref double pnl) + private double GetTradePositionPnl() { double currentValue = 0; List tradetypes = new List { "利率债", "信用债", "其它债券" }; @@ -5261,7 +5046,6 @@ namespace YLErp.Modules.RiskModule foreach (var item in tposis) { double lastPrice = 0; - decimal vobp = 0; var um = ums.FirstOrDefault(x => x.UnderlyingCode == item.UnderlyingCode); double contractSize = 0; if (um != null) @@ -5275,12 +5059,9 @@ namespace YLErp.Modules.RiskModule { var bondPrice = EodPriceQueryService.GetBondPrice(valuedateBLL.ValueDate, item.UnderlyingCode); lastPrice = bondPrice != null ? bondPrice.ClosePrice : (um.Price ?? 0) * Convert.ToDouble(ConsGlobal.bondPriceMultiple); - vobp = bondPrice != null ? bondPrice.Vobp ?? 0 : 0; } } - var DV01 = Convert.ToDouble(vobp) * item.Position * contractSize * 0.01; - currentValue += DV01; - pnl += lastPrice * Math.Abs(item.Position) - Math.Abs(item.PositionCost); + currentValue += lastPrice * Math.Abs(item.Position) - Math.Abs(item.PositionCost); } return currentValue; } @@ -5331,15 +5112,6 @@ namespace YLErp.Modules.RiskModule currentValue = Convert.ToDouble(positionList.Sum(s => s.Pnl)); messageList.Add(SetMsg(tag, currentValue, upperLimit, lowerLimit, settingItem.Percent, warning)); break; - case "DV01": - var clientDv = positionList.Sum(s => s.DV01); - currentValue = Convert.ToDouble(clientDv); - var posiDv = positionList.Where(s => !s.Current).Sum(s => s.DV01); - posiVal = Convert.ToDouble(posiDv); - tradePosiVal = posiList.Sum(s => s.DV01); - noPosiVal = posiDv - tradePosiVal; - messageList.Add(SetQuotaMsg(tag, settingItem.QuotaIndex, currentValue, Convert.ToDouble(tradePosiVal), posiVal, Convert.ToDouble(current.DV01), Convert.ToDouble(noPosiVal), null, upperLimit, lowerLimit, settingItem.Percent, warning)); - break; default: continue; } @@ -5374,16 +5146,6 @@ namespace YLErp.Modules.RiskModule case "浮动盈亏": currentValue = Convert.ToDouble(positionList.Sum(O => O.Pnl)); break; - case "DV01": - var clientDv = positionList.Sum(s => s.DV01); - currentValue = Convert.ToDouble(clientDv); - var posiDv = positionList.Where(s => !s.Current).Sum(s => s.DV01); - posiVal = Convert.ToDouble(posiDv); - if (!ValidateQuoteResult(checkItem, currentValue, posiVal)) - { - return checkItem; - } - return null; default: return null; } @@ -5452,14 +5214,6 @@ namespace YLErp.Modules.RiskModule currentValue = Convert.ToDouble(current.Delta); messageList.Add(SetMsg(tag, currentValue, upperLimit, lowerLimit, settingItem.Percent, warning)); break; - case "DV01": - var clientDv = positionList.Where(s => s.ClientId == current.ClientId && s.UnderlyingCode == current.UnderlyingCode && s.Side != current.Side).Sum(s => s.DV01); - currentValue = Convert.ToDouble(clientDv + current.DV01); - posiVal = Convert.ToDouble(clientDv); - tradePosiVal = posiList.Where(s => s.ClientId == current.ClientId && s.UnderlyingCode == current.UnderlyingCode).Sum(s => s.DV01); - noPosiVal = clientDv - tradePosiVal; - messageList.Add(SetQuotaMsg(tag, settingItem.QuotaIndex, currentValue, Convert.ToDouble(tradePosiVal), posiVal, Convert.ToDouble(current.DV01), Convert.ToDouble(noPosiVal), null, upperLimit, lowerLimit, settingItem.Percent, warning)); - break; default: continue; } @@ -5527,16 +5281,6 @@ namespace YLErp.Modules.RiskModule return checkItem; } return null; - case "DV01": - var clientDv = positionList.Where(s => s.ClientId == current.ClientId && s.UnderlyingCode == current.UnderlyingCode && s.Side != current.Side).Sum(s => s.DV01); - currentValue = Convert.ToDouble(clientDv + current.DV01); - posiVal = Convert.ToDouble(clientDv); - checkItem.currentValue = Math.Round(currentValue ?? 0, 2); - if (!ValidateQuoteResult(checkItem, currentValue, posiVal)) - { - return checkItem; - } - return null; default: return null; } @@ -5730,15 +5474,6 @@ namespace YLErp.Modules.RiskModule noPosiVal = posiPv - tradePosiVal; messageList.Add(SetQuotaMsg(tag, settingItem.QuotaIndex, currentValue, Convert.ToDouble(tradePosiVal), posiVal, Convert.ToDouble(current.Pv), Convert.ToDouble(noPosiVal), null, upperLimit, lowerLimit, settingItem.Percent, warning)); break; - case "DV01": - var clientDv = positionList.Where(s => s.ClientId == current.ClientId).Sum(s => s.DV01); - currentValue = Convert.ToDouble(clientDv); - var posiDv = positionList.Where(s => s.ClientId == current.ClientId && !s.Current).Sum(s => s.DV01); - posiVal = Convert.ToDouble(posiDv); - tradePosiVal = posiList.Where(s => s.ClientId == current.ClientId).Sum(s => s.DV01); - noPosiVal = posiDv - tradePosiVal; - messageList.Add(SetQuotaMsg(tag, settingItem.QuotaIndex, currentValue, Convert.ToDouble(tradePosiVal), posiVal, Convert.ToDouble(current.DV01), Convert.ToDouble(noPosiVal), null, upperLimit, lowerLimit, settingItem.Percent, warning)); - break; default: break; } @@ -5780,16 +5515,6 @@ namespace YLErp.Modules.RiskModule return checkItem; } return null; - case "DV01": - var clientDv = positionList.Where(s => s.ClientId == current.ClientId).Sum(s => s.DV01); - currentValue = Convert.ToDouble(clientDv); - var posiDv = positionList.Where(s => s.ClientId == current.ClientId && !s.Current).Sum(s => s.DV01); - posiVal = Convert.ToDouble(posiDv); - if (!ValidateQuoteResult(checkItem, currentValue, posiVal)) - { - return checkItem; - } - return null; default: return null; } @@ -5909,7 +5634,6 @@ namespace YLErp.Modules.RiskModule quotaMoitorModel.ClientId = item.ClientId ?? 0; quotaMoitorModel.Pv = Math.Abs(Convert.ToDecimal(item.Pv ?? 0)); quotaMoitorModel.UnderlyingCode = item.Exposure; - quotaMoitorModel.DV01 = Convert.ToDecimal(item.DV01 ?? 0); list.Add(quotaMoitorModel); } return list; @@ -5953,10 +5677,6 @@ namespace YLErp.Modules.RiskModule result += $"\r\n本交易({quoteIndex}):{(currVal == 0 ? "0.00" : currVal.ToString(percent ? "#,##0.00%" : "#,##0.00"))};"; result += $"\r\n已簿记交易({quoteIndex}):{(posiedVal == 0 ? "0.00" : posiedVal.ToString(percent ? "#,##0.00%" : "#,##0.00"))};"; result += $"\r\n未簿记交易({quoteIndex}):{(noposi == 0 ? "0.00" : noposi.ToString(percent ? "#,##0.00%" : "#,##0.00"))};"; - if (tag.Contains("全局") && quoteIndex == "DV01") - { - result += $"\r\n标的交易({quoteIndex}):{(uDv == 0 ? "0.00" : uDv?.ToString("#,##0.00"))};"; - } } } return result; @@ -5986,10 +5706,6 @@ namespace YLErp.Modules.RiskModule resultLast += $"\r\n本交易({quoteIndex}):{(currVal == 0 ? "0.00" : currVal?.ToString(percent ? "#,##0.00%" : "#,##0.00"))};"; resultLast += $"\r\n已簿记交易({quoteIndex}):{(posiedVal == 0 ? "0.00" : posiedVal?.ToString(percent ? "#,##0.00%" : "#,##0.00"))};"; resultLast += $"\r\n未簿记交易({quoteIndex}):{(noposi == 0 ? "0.00" : noposi.ToString(percent ? "#,##0.00%" : "#,##0.00"))};"; - if (tag.Contains("全局") && quoteIndex == "DV01") - { - resultLast += $"\r\n标的交易({quoteIndex}):{(uDv == 0 ? "0.00" : uDv?.ToString("#,##0.00"))};"; - } } if (!string.IsNullOrEmpty(result) && posiVal != 0) { diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 4e8abb8c..eb5329cf 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -288,7 +288,7 @@ namespace YLErp.Modules.SwapModule continue; } var eodPosition = eodPositions.FirstOrDefault(x => x.PositionId == interest.id);//上一日日终利息信息 可能不存在 - var tdEodPosition = todyEodPositions.FirstOrDefault(x => x.PositionId == interest.id && x.IsSkipEod);//当前结算日日终利息信息 + var tdEodPosition = todyEodPositions.FirstOrDefault(x => x.PositionId == interest.id);//当前结算日日终利息信息 var insterval = interest.SwapIntervalList.FirstOrDefault(x => x.Date == settleDate && x.Settlement == 1);//自动互换观察日信息 List dealInterests = new List(); dealInterests.AddRange(flowEvents); @@ -376,7 +376,7 @@ namespace YLErp.Modules.SwapModule foreach (var posi in posiList) { var eodPosition = eodPositions.Where(x => x.PositionId == posi.id).FirstOrDefault();//上一日日终持仓信息 - var tdEodPosition = todyEodPositions.FirstOrDefault(x => x.PositionId == posi.id && x.IsSkipEod);//当前结算日日终持仓信息 + var tdEodPosition = todyEodPositions.FirstOrDefault(x => x.PositionId == posi.id);//当前结算日日终持仓信息 var unwindEvents = flowEvents.Where(x => x.PositionId == posi.id).ToList();//当前日平仓信息 var realPosition = realPosiList.FirstOrDefault(s => s.PositionId == posi.id); eod_swap_position eodPosi = new eod_swap_position(); @@ -389,7 +389,6 @@ namespace YLErp.Modules.SwapModule else { tdEodPosition.PosiFeePending = posi.PosiTradingFeePending; - UpdateHTData(tdEodPosition); tdEodPosition.PosiNotionalValue = tdEodPosition.PosiQuantity * tdEodPosition.ContractSize; tdEodPosition.PosiNetFeePrice = posi.PosiNetFeePrice; tdEodPosition.PosiNetNoFeePrice = posi.PosiNetNoFeePrice; @@ -700,12 +699,6 @@ namespace YLErp.Modules.SwapModule newEodPayPosition.PosiStartDate = position.PosiStartDate; eodPayPosition.PosiMatuirityDate = td.ExerciseDate.Value; } - if (newEodPayPosition.IsSkipEod) - { - newEodPayPosition.FloatRate = flowEvents.FirstOrDefault()?.FloatRate ?? 0; - newEodPayPosition.FloatRateUnderlyingCode = position.FloatRateUnderlyingCode; - return; - } newEodPayPosition.ValueDate = valueDate; newEodPayPosition.PositionId = position.id; newEodPayPosition.ClientId = td.ClientId; @@ -793,7 +786,6 @@ namespace YLErp.Modules.SwapModule if (newEodPayPosition == null) { newEodPayPosition = eodPayPosition.Clone(); - newEodPayPosition.IsSkipEod = false; newEodPayPosition.id = 0; } List positions = new List(); @@ -803,12 +795,7 @@ namespace YLErp.Modules.SwapModule var interests = new SwapDealService(this).GetInterests(td, td.trade_extend, valueDate, valueDate, preEodPositions, positions, posiNotionalValue, posiLongNotional, posiShortNational, posiNotionalValue, closePercent, (int)SwapEventTypeEnum.自动互换, false, true, grossPrice, true); decimal InterestAmount = interests.Sum(x => x.InterestAmount); decimal TdInterestAmount = interests.Sum(x => x.TdInterestAmount); - if (newEodPayPosition.IsSkipEod) - { - newEodPayPosition.FloatRate = interests.Count > 0 ? interests.First().FloatRate ?? 0 : 0; - newEodPayPosition.FloatRateUnderlyingCode = position.FloatRateUnderlyingCode; - return new List(); - } + newEodPayPosition.ValueDate = valueDate; newEodPayPosition.PositionId = position.id; UpdateDbOption(newEodPayPosition); @@ -909,12 +896,7 @@ namespace YLErp.Modules.SwapModule preEodPositions.Add(eodPayPosition); var interests = new SwapDealService(this).GetInterests(td, td.trade_extend, valueDate, valueDate, preEodPositions, positions, posiNotionalValue, posiLongNotional, posiShortNational, closeNational, 1, eventType, false, true, grossPrice, true); decimal TdInterestAmount = interests.Sum(x => x.TdInterestAmount); - if (newEodPayPosition.IsSkipEod) - { - newEodPayPosition.FloatRate = interests.Count > 0 ? interests.First().FloatRate ?? 0 : 0; - newEodPayPosition.FloatRateUnderlyingCode = position.FloatRateUnderlyingCode; - return new List(); - } + newEodPayPosition.ValueDate = valueDate; newEodPayPosition.PositionId = position.id; UpdateDbOption(newEodPayPosition); @@ -1020,7 +1002,6 @@ namespace YLErp.Modules.SwapModule newEodPayPosition = eodPayPosition.Clone(); newEodPayPosition.id = 0; newEodPayPosition.PositionId = position.id; - newEodPayPosition.IsSkipEod = false; } bool longShort = td.StructureType == ClientMarginTypeEnum.多空组合.ToString(); @@ -1055,11 +1036,7 @@ namespace YLErp.Modules.SwapModule } var interests = new SwapDealService(this).GetInterests(td, td.trade_extend, valueDate, valueDate, preEodPositions, positions, posiNotionalValue, posiLongNational, posiShortNational, posiNotionalValue, closePercent, 0, false, needPrice, grossPrice); UpdateDbOption(newEodPayPosition); - if (newEodPayPosition.IsSkipEod) - { - newEodPayPosition.FloatRate = interests.Count > 0 ? interests.First().FloatRate ?? 0 : 0; - return; - } + newEodPayPosition.PosiStatus = 0; newEodPayPosition.Invalid = false; newEodPayPosition.ValueDate = valueDate; @@ -1184,7 +1161,6 @@ namespace YLErp.Modules.SwapModule newEodPayPosition.RealizedPnl = newEodPayPosition.TdCloseMtmPnl + newEodPayPosition.TdCloseDividend + newEodPayPosition.TdCloseFee; newEodPayPosition.PosiStatus = payQty == 0 ? 1 : 0; - newEodPayPosition.DV01 = newEodPayPosition.PosiQuantity * newEodPayPosition.ContractSize * vobp * shortRatio * ratio * 0.01m; UpdateDbOption(newEodPayPosition); newEodPayPosition.Invalid = false; var currencyRate = new EodCurrencyRateService(UserInfo).GetCurrencyRate(td.QuoteCurrency, td.SettlementCurrency, eventFlow.EventDate @@ -1221,7 +1197,6 @@ namespace YLErp.Modules.SwapModule curretEod = eod.Clone(); curretEod.id = 0; curretEod.ValueDate = valueDate; - curretEod.IsSkipEod = false; } var um = DataCacheProvider.GetUnderlyingDataSource().GetData(eod.UnderlyingCode); if (um == null) @@ -1237,17 +1212,6 @@ namespace YLErp.Modules.SwapModule { curretEod.PosiNotionalValue = 0; } - if (curretEod.IsSkipEod) - { - curretEod.DV01 = curretEod.PosiQuantity * curretEod.ContractSize * vobp * shortRatio * directionRatio * 0.01m; - curretEod.PosiNotionalValue = curretEod.PosiQuantity * curretEod.ContractSize; - curretEod.PosiNetFeePrice = eod.PosiNetFeePrice; - curretEod.PosiNetNoFeePrice = eod.PosiNetNoFeePrice; - curretEod.PosiFeePending= eod.PosiFeePending; - UpdateHTData(curretEod); - UpdateDbOption(curretEod); - return curretEod; - } curretEod.UnderlyingPrice = price; curretEod.UnderlyingMarketValue = curretEod.UnderlyingPrice * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio; curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; @@ -1267,7 +1231,6 @@ namespace YLErp.Modules.SwapModule curretEod.TdCurrency = Convert.ToDecimal(currencyRate); //持仓价值 curretEod.SwapPositionValue = curretEod.InterestProfitSum + curretEod.PosiProfitSum; - curretEod.DV01 = curretEod.PosiQuantity * curretEod.ContractSize * vobp * shortRatio * directionRatio * 0.01m; UpdateDbOption(curretEod); curretEod.Invalid = false; if (curretEod.id == 0) @@ -1277,16 +1240,6 @@ namespace YLErp.Modules.SwapModule return curretEod; } /// - /// 更新浮动端收益 - /// - /// - private void UpdateHTData(eod_swap_position curretEod) - { - UpdateVTradingFee(curretEod); - curretEod.PosiProfitSum = curretEod.HTPosiProfitSum + curretEod.VTradingFee; - curretEod.SwapPositionValue = curretEod.HTSwapPositionValue + curretEod.VTradingFee; - } - /// /// 更新虚拟交易费用 /// /// @@ -1312,7 +1265,6 @@ namespace YLErp.Modules.SwapModule curretEod = eod.Clone(); curretEod.id = 0; curretEod.ValueDate = valueDate; - curretEod.IsSkipEod = false; } var um = DataCacheProvider.GetUnderlyingDataSource().GetData(eod.UnderlyingCode); @@ -1324,14 +1276,7 @@ namespace YLErp.Modules.SwapModule int shortRatio = eod.PositionType == (int)PositionTypeFlag.Long ? 1 : -1; int directionRatio = eod.PosiDirection == (int)SwapDirectionEnum.收取 ? 1 : -1; var price = UnderlyingCodePrice(eod.UnderlyingCode, dealDate, out decimal vobp); - SetPriceInfoByFlowEvent(eod, curretEod, unwindEvents, swapPosition, !curretEod.IsSkipEod); - if (curretEod.IsSkipEod) - { - curretEod.DV01 = curretEod.PosiQuantity * curretEod.ContractSize * vobp * shortRatio * directionRatio * 0.01m; - UpdateHTData(curretEod); - UpdateDbOption(curretEod); - return curretEod; - } + SetPriceInfoByFlowEvent(eod, curretEod, unwindEvents, swapPosition); curretEod.UnderlyingPrice = price; curretEod.UnderlyingMarketValue = curretEod.UnderlyingPrice * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio; curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; @@ -1351,7 +1296,6 @@ namespace YLErp.Modules.SwapModule curretEod.TdCurrency = Convert.ToDecimal(currencyRate); //持仓价值 curretEod.SwapPositionValue = curretEod.InterestProfitSum + curretEod.PosiProfitSum; - curretEod.DV01 = curretEod.PosiQuantity * curretEod.ContractSize * vobp * shortRatio * directionRatio * 0.01m; UpdateDbOption(curretEod); curretEod.Invalid = false; if (curretEod.id == 0) @@ -1366,7 +1310,7 @@ namespace YLErp.Modules.SwapModule /// /// /// - public void SetPriceInfoByFlowEvent(eod_swap_position eod, eod_swap_position curretEod, List unwindEvents, swap_position position, bool coverageQty=true) + public void SetPriceInfoByFlowEvent(eod_swap_position eod, eod_swap_position curretEod, List unwindEvents, swap_position position) { if (eod.PosiDirection == 0) { @@ -1379,21 +1323,14 @@ namespace YLErp.Modules.SwapModule decimal unwindQty = unwindFlowEvents.Sum(s => s.Quantity); decimal openQty = openFlowEvents.Sum(s => s.Quantity); var qty = eod.PosiQuantity + openQty - unwindQty; - if (coverageQty) - { - curretEod.PosiQuantity = qty < 0 ? 0 : Math.Abs(qty); - } - + curretEod.PosiQuantity = qty < 0 ? 0 : Math.Abs(qty); if (unwindEvents.Count == 0) { curretEod.PosiNetPrice = position.PosiNetPrice; curretEod.PosiGrossPrice = position.PosiGrossPrice; curretEod.PosiNetFeePrice = position.PosiNetFeePrice; curretEod.PosiNetNoFeePrice = position.PosiNetNoFeePrice; - if (coverageQty) - { - curretEod.PosiQuantity = position.PosiQuantity; - } + curretEod.PosiQuantity = position.PosiQuantity; curretEod.PosiTradingFee = position.PosiTradingFee; } else @@ -1496,7 +1433,6 @@ namespace YLErp.Modules.SwapModule } //持仓价值 curretEod.SwapPositionValue = curretEod.InterestProfitSum + curretEod.PosiProfitSum; - curretEod.DV01 = curretEod.PosiQuantity * curretEod.ContractSize * vobp * shortRatio * directionRatio * 0.01m; var currencyRate = new EodCurrencyRateService(UserInfo).GetCurrencyRate(td.QuoteCurrency, td.SettlementCurrency, td.StartDate.Value , seekPreday: true, currencyRateType: curretEod.PosiDirection == (int)SwapDirectionEnum.收取 ? CurrencyRateType.Buy : CurrencyRateType.Sell); curretEod.TdCurrency = Convert.ToDecimal(currencyRate); @@ -1572,17 +1508,6 @@ namespace YLErp.Modules.SwapModule eod_Swap.NotionalValueLong = positions.Where(x => x.PositionType == (int)PositionTypeFlag.Long).Sum(s => s.PosiNotionalValue); eod_Swap.NotionalValueShort = positions.Where(x => x.PositionType == (int)PositionTypeFlag.Short).Sum(s => s.PosiNotionalValue); eod_Swap.NotionalValue = eod_Swap.NotionalValueLong + eod_Swap.NotionalValueShort; - if (eod_Swap.IsSkipEod == true) - { - var vtradingFee = eodSwapPositions.Sum(x => x.VTradingFee); - eod_Swap.VTradingFee = vtradingFee; - eod_Swap.DV01 = positions.Sum(s => s.DV01 ?? 0); - eod_Swap.PostionValue = eod_Swap.HTPostionValue + vtradingFee; - eod_Swap.FloatingPnL = eod_Swap.HTFloatingPnL + vtradingFee; - eod_Swap.TdRealizedPnL = eod_Swap.RealizedPnL - (preEodSwap?.RealizedPnL??0);// 当日已实现-上日已实现 - UpdateDbOption(eod_Swap); - return; - } eod_Swap.SwapTradeId = td.id; eod_Swap.SwapTradeNo = td.TradeNumber; eod_Swap.ClientId = td.ClientId; @@ -1617,7 +1542,6 @@ namespace YLErp.Modules.SwapModule eod_Swap.PostionValue = eodSwapPositions.Sum(s => s.SwapPositionValue); eod_Swap.RealizedPnL = eodSwapPositions.Sum(s => s.RealizedMtmPnL + s.RealizedDividend + s.RealizedFee + s.RealizedInterest + s.RealizedInterestFee); eod_Swap.TdCloseQty = positions.Sum(s => s.TdCloseQty); - eod_Swap.DV01 = positions.Sum(s => s.DV01 ?? 0); var initMargin = Convert.ToDecimal(tradeSpan?.InitialMargin ?? 0); var maintainMargin = Convert.ToDecimal(tradeSpan?.WorstCastClientPayable ?? 0); if (initMargin < 0) @@ -1688,7 +1612,6 @@ namespace YLErp.Modules.SwapModule eod_Swap.PostionValue = eodSwapPositions.Sum(s => s.SwapPositionValue); eod_Swap.RealizedPnL = eodSwapPositions.Sum(s => s.RealizedMtmPnL + s.RealizedDividend + s.RealizedFee + s.RealizedInterest + s.RealizedInterestFee); eod_Swap.TdCloseQty = positions.Sum(s => s.TdCloseQty); - eod_Swap.DV01 = positions.Sum(s => s.DV01 ?? 0); var tradeInitMarginObj = DbContext.trade_initial_margin.FirstOrDefault(x => x.TradeId == td.id); var initMarginList = interestPositions.Where(x => x.InterestMode == (int)InterestModeEnum.初始预付金 && x.HappenDate == settleDate).ToList(); var addMarginList = interestPositions.Where(x => x.InterestMode == (int)InterestModeEnum.追加预付金 && x.HappenDate == settleDate).ToList(); diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs index 9c5e0eb6..96ce7534 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs @@ -424,11 +424,11 @@ namespace YLErp.Modules.SwapModule { var swapEvents = DbContext.swap_event.Where(x => x.SwapTradeId == td.id && x.ValueDate >= valueDate && eventTypes.Contains(x.EventType)); var eventIds = swapEvents.Select(s => s.id).ToList(); - var eodSwaps = DbContext.eod_swap.Where(x => x.SwapTradeId == td.id && x.ValueDate >= valueDate && !x.IsSkipEod).ToList(); + var eodSwaps = DbContext.eod_swap.Where(x => x.SwapTradeId == td.id && x.ValueDate >= valueDate).ToList(); if (delAfter) { var swapFlowEvents = DbContext.swap_flow_event.Where(x => x.SwapTradeId == td.id && x.UnwindDate >= valueDate && x.DataState > (int)SwapFlowDateStateEnum.废弃 && eventTypes.Contains(x.EventType)).ToList(); - var eodSwapPositions = DbContext.eod_swap_position.Where(x => x.SwapTradeId == td.id && x.ValueDate >= valueDate && !x.IsSkipEod).ToList(); + var eodSwapPositions = DbContext.eod_swap_position.Where(x => x.SwapTradeId == td.id && x.ValueDate >= valueDate).ToList(); DbContext.eod_swap_position.RemoveRange(eodSwapPositions); DbContext.swap_flow_event.RemoveRange(swapFlowEvents); } diff --git a/YLErpDAL/Modules/TradeRiskCalcModule/TradeRiskCalcService.cs b/YLErpDAL/Modules/TradeRiskCalcModule/TradeRiskCalcService.cs index 2481f533..22154526 100644 --- a/YLErpDAL/Modules/TradeRiskCalcModule/TradeRiskCalcService.cs +++ b/YLErpDAL/Modules/TradeRiskCalcModule/TradeRiskCalcService.cs @@ -316,7 +316,6 @@ namespace YLErp.Modules.TradeRiskCalcModule result.TradingDayTheta = 0; result.CalendarDayTheta = 0; result.Rho = 0; - result.DV01 = Convert.ToDouble(currentPosition.DV01??0); var resultRisk = SwapTransformOneUnderlying(underlying, trad, new List { result }, currentPosition, position); if (resultRisk != null) { diff --git a/YLErpWeb/wwwroot/Scripts/app/risk/quotaMonitor.js b/YLErpWeb/wwwroot/Scripts/app/risk/quotaMonitor.js index ef012a6b..2e1f4ea2 100644 --- a/YLErpWeb/wwwroot/Scripts/app/risk/quotaMonitor.js +++ b/YLErpWeb/wwwroot/Scripts/app/risk/quotaMonitor.js @@ -1547,30 +1547,6 @@ var colModel_client = [ formatter: function (cellvalue, options, rowObject) { return !cellvalue || cellvalue == "NaN" ? "" : cellvalue.toLocaleString(); } - }, { - name: 'Quota_DV01_Upper', - label: 'DV01限额', - index: 'Quota_DV01_Upper', - width: 120, - align: 'right', - sortable: false, - formatter: function (cellvalue, options, rowObject) { - return formatQuotaAbs(rowObject, 'DV01'); - } - }, { - name: 'Quota_DV01', - label: 'DV01', - index: 'Quota_DV01', - width: 140, - align: 'right', - sortable: false, - formatter: function (cellvalue, options, rowObject) { - return !cellvalue || cellvalue == "NaN" ? "" : cellvalue.toLocaleString(); - }, - cellattr: function (cellvalue, options, rowObject) { - var style = "style='" + checkQuota(rowObject, 'Quota_DV01','DV01') + "'"; - return style; - } } ]; @@ -1663,30 +1639,6 @@ var colModel_trade = [ var style = "style='" + checkQuota(rowObject, 'SwapPercent') + "'"; return style; } - }, { - name: 'Quota_DV01_Upper', - label: 'DV01限额', - index: 'Quota_DV01_Upper', - width: 120, - align: 'right', - sortable: false, - formatter: function (cellvalue, options, rowObject) { - return formatQuotaAbs(rowObject, 'DV01'); - } - }, { - name: 'Quota_DV01', - label: 'DV01', - index: 'Quota_DV01', - width: 140, - align: 'right', - sortable: false, - formatter: function (cellvalue, options, rowObject) { - return !cellvalue || cellvalue == "NaN" ? "" : cellvalue.toLocaleString(); - }, - cellattr: function (cellvalue, options, rowObject) { - var style = "style='" + checkQuota(rowObject, 'Quota_DV01', 'DV01') + "'"; - return style; - } } ]; @@ -1852,30 +1804,6 @@ var colModel_global = [ //} return "style='" + style + "'"; } - }, { - name: 'Quota_DV01_Upper', - label: 'DV01限额', - index: 'Quota_DV01_Upper', - width: 120, - align: 'right', - sortable: false, - formatter: function (cellvalue, options, rowObject) { - return formatQuotaAbs(rowObject, 'DV01'); - } - }, { - name: 'Quota_DV01', - label: 'DV01', - index: 'Quota_DV01', - width: 140, - align: 'right', - sortable: false, - formatter: function (cellvalue, options, rowObject) { - return !cellvalue || cellvalue == "NaN" ? "" : cellvalue.toLocaleString(); - }, - cellattr: function (cellvalue, options, rowObject) { - var style = "style='" + checkQuota(rowObject, 'Quota_DV01', 'DV01') + "'"; - return style; - } } ]; diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/EodPositionRisks.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/EodPositionRisks.js index 1e39f160..c0691b8f 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/EodPositionRisks.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/EodPositionRisks.js @@ -443,13 +443,6 @@ function colModelGridEodPosition() { width: 100, align: 'center', formatter: PosiStatusFormat, - }, { - name: 'eodPosition.DV01', - label: 'DV01', - index: 'eodPosition.DV01', - width: 100, - align: 'center', - formatter: StockEqvNotionalFormat, }, { name: 'SwapTradeTypeStr', label: '互换类型', @@ -617,13 +610,6 @@ function colModelGridEodSwap() { width: 150, align: 'center', formatter: StockEqvNotionalFormat, - }, { - name: 'position.DV01', - label: 'DV01', - index: 'position.DV01', - width: 100, - align: 'center', - formatter: StockEqvNotionalFormat, }, { name: 'SwapTradeTypeStr', label: '互换类型', diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeList.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeList.js index a955aed0..975c55b0 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeList.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeList.js @@ -141,34 +141,6 @@ var getColModelGrid = function () { sortIndex: i++, width: 70, align: 'center' - }, { - name: 'HTStatus', - label: '衡泰状态', - index: 'HTStatus', - sortIndex: i++, - width: 70, - align: 'center', - formatter: function (cellValue, options, rowObject) { - if (cellValue==10) { - return "已平仓"; - } - if (cellValue == 1) { - return "最新审批中"; - } - if (cellValue == 4) { - return "最新审批拒绝"; - } - if (cellValue == 5) { - return "最新审批通过"; - } - if (cellValue == 9) { - return "已删除"; - } - if (cellValue) { - return "确认成交"; - } - return "--"; - } }, { name: 'TradeNumber', label: '交易编号',