diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index 727a2448..1aa983a4 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -1281,7 +1281,7 @@ namespace YLErp.BLL.Eod var posiQty = eodPosi?.PosiQuantity ?? 0; var flowEvents = swapFlowEvents.Where(x => x.SwapTradeId == item.Key).ToList(); var unwindQty = flowEvents.Sum(s => s.Quantity); - var pnl = lastEodSwap.PostionValue- eodPosi?.VTradingFee+eodPosi?.PosiFeePending; + var pnl = lastEodSwap.PostionValue; decimal unwindPercent = 0; if (unwindQty != 0) { diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs index d0402e7a..e27d8b5a 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs @@ -112,13 +112,6 @@ namespace YLErp.Modules.EodModule.SettlementModule { eodRiskList = eodRiskList.Where(t => reqClientIds.Contains(t.ClientId)).ToList(); } - //获取所有用户当日Eod_pnl - IEnumerable eodpnlList = DbContext.eod_trade_position.Where(t => t.ValueDate == balanceDate && t.TradeType != "收益互换").ToList(); - - if (reqClientIds != null && reqClientIds.Any()) - { - eodpnlList = eodpnlList.Where(t => reqClientIds.Contains(t.ClientId)).ToList(); - } //获取客户导入的所有持仓信息 -- 收益互换(国君) var EodPositionSwapMannual = DbContext.eod_trade_position_swap_mannual.Where(x => x.ValueDate == balanceDate).ToList(); if (reqClientIds != null && reqClientIds.Any()) @@ -728,8 +721,6 @@ namespace YLErp.Modules.EodModule.SettlementModule CopeWithExpirePremium = OptionPremium + OptionPremiumSwap; //应付存续权利金 CopeWithLastPremium = FrozenPremium; - //获取客户持仓交易的pv以及浮动盈亏 - var eodpnlQuery = eodpnlList.Where(t => positionTradeIds.Contains(t.TradeId)); //未了结名义成交金额 todo //持仓的买入 以及卖出是否都统计 TotalNominal = positionTrades == null || positionTrades.Count == 0 ? 0 : positionTrades.Sum(t => t.UnderlyingInstrumentType == "Stock" ? t.StockEqvNotional : (t.Notional * (t.SpotPrice ?? 0.0))); @@ -810,34 +801,6 @@ namespace YLErp.Modules.EodModule.SettlementModule EndPremium = todayFinishedTrades.Sum(t => t.TradeType != "远期" ? -TradeCalcHelper.GetSign(t.BuySell) * (t.TradePrice ?? 0) * finishedTradeNotionalPercentDic[t.id] : (t.TradePrice ?? 0) * finishedTradeNotionalPercentDic[t.id]) * -1; EndPremium = EndPremium + todaySwapFinishedCash.Sum(s => s.Money ?? 0); var eodPnlSum = new EodPnlGridSum(); - - if (eodpnlQuery.Any()) - { - eodPnlSum.LastPvSum = eodpnlQuery.Sum(q => q.LastPv) * (-1);//昨日价值 - eodPnlSum.PvSum = eodpnlQuery.Sum(q => q.Pv) * (-1);//当日价值 - eodPnlSum.SellPvSum = eodpnlQuery.Where(x => x.BuySell == "买入").Sum(q => q.Pv) * (-1);//当日价值 - eodPnlSum.RoundedPvSum = eodpnlQuery.Sum(q => q.RoundedPv) * (-1);//当日四舍五入价值 - if (_context.SystemValue.PotentialSurplusCalcMode == valuedate.PotentialSurplusCalcMode_Pv) - { - PotentialSurpluses = eodPnlSum.PvSum ?? 0; - } - PositionPnl = eodpnlQuery.Sum(q => q.PositionPnL) * (-1); - RoundedPositionPnl = eodpnlQuery.Sum(q => q.RoundedPositionPnL) * (-1); - TotalPnl = eodpnlQuery.Sum(q => q.TotalPnL) * (-1); - - - #region 期权空头浮动盈利=∑max(期权空头持仓*(期权合约成本价-期权合约现价), 0) 从客户角度看的, 结构化交易需要将两条腿的空头Pnl合计 - - var singlePositionPnlTotal = eodpnlQuery.Where(x => x.TradeType != "结构化交易" && x.ParentTradeId == 0).Sum(n => n.BuySell == "买入" ? Math.Max(-n.PositionPnL, 0) : 0); - ClientSellPositionPnl = singlePositionPnlTotal; - - #endregion - } - if (eodpnlList.Where(t => t.ClientId == client.id).Any()) - { - eodPnlSum.DailyPnLSum = eodpnlList.Where(t => t.ClientId == client.id).Sum(q => q.DailyPnL) * (-1);//当日浮动盈亏 - DailyPnl = eodpnlList.Where(t => t.ClientId == client.id).Sum(q => q.DailyPnL) * (-1); - } #region 收益互换V2 var clientEodSwapsLast = clientEodSwaps.ToList(); var clientEodSwapPositionLast = clientEodSwapPosis.ToList(); @@ -848,13 +811,13 @@ namespace YLErp.Modules.EodModule.SettlementModule var eodSwapPosition = clientEodSwapPositionLast.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == balanceDate && t.PosiStartDate <= balanceDate); PotentialSurpluses += Convert.ToDouble(item.PostionValue) * (-1); // WinLoss += Convert.ToDouble(item.TdRealizedPnL) * (-1); - var lastPv = lastEodSwap != null ? Convert.ToDouble(lastEodSwap.PostionValue- lastEodSwapPosition?.VTradingFee+lastEodSwapPosition?.PosiFeePending) * (-1) : 0; + var lastPv = lastEodSwap != null ? Convert.ToDouble(lastEodSwap.PostionValue) * (-1) : 0; eodPnlSum.LastPvSum = eodPnlSum.LastPvSum.HasValue ? eodPnlSum.LastPvSum + lastPv : lastPv; - var pnl = item.PostionValue- eodSwapPosition?.VTradingFee+ eodSwapPosition?.PosiFeePending; - eodPnlSum.PvSum = eodPnlSum.PvSum.HasValue ? eodPnlSum.PvSum - Convert.ToDouble(item.PostionValue) : Convert.ToDouble(item.PostionValue) * (-1); - eodPnlSum.SellPvSum = eodPnlSum.SellPvSum.HasValue ? eodPnlSum.SellPvSum - Convert.ToDouble(item.MarketValueShort) : Convert.ToDouble(item.MarketValueShort) * (-1); - eodPnlSum.RoundedPvSum = eodPnlSum.RoundedPvSum.HasValue ? eodPnlSum.RoundedPvSum - Math.Round(Convert.ToDouble(item.PostionValue), 2) : Math.Round(Convert.ToDouble(item.PostionValue), 2) * (-1); - eodPnlSum.DailyPnLSum = eodPnlSum.DailyPnLSum.HasValue ? eodPnlSum.DailyPnLSum - Convert.ToDouble(item.TdRealizedPnL) : Convert.ToDouble(item.TdRealizedPnL) * (-1); + var pnl = item.PostionValue; + eodPnlSum.PvSum = Convert.ToDouble(item.PostionValue) * (-1); + eodPnlSum.SellPvSum = Convert.ToDouble(item.MarketValueShort) * (-1); + eodPnlSum.RoundedPvSum = Math.Round(Convert.ToDouble(item.PostionValue), 2) * (-1); + eodPnlSum.DailyPnLSum = Convert.ToDouble(item.TdRealizedPnL) * (-1); PositionPnl += Convert.ToDouble(pnl) * (-1); RoundedPositionPnl += Math.Round(Convert.ToDouble(pnl), 2) * (-1); TotalPnl += Convert.ToDouble(item.RealizedPnL) * (-1);