TRS-ZS-460 每日估值报告,单边费用

This commit is contained in:
吴方海
2025-05-29 13:47:49 +08:00
parent b7b5b0d648
commit 787368a171
6 changed files with 19 additions and 9 deletions
@@ -129,7 +129,10 @@ namespace YLErp.Modules.EodModule.SettlementModule
var eodSwapQuery = from eod in DbContext.eod_swap.Where(x => x.ValueDate <= balanceDate && x.ValueDate >= preBalanceDate)
join t in DbContext.trade.Where(x => x.TradeType == "收益互换" && x.ValidState != ConsGlobal.InValid && ConsTrade.TradeStatusAfterConfirmed.Contains(x.TradeStatus)) on eod.SwapTradeId equals t.id
select eod;
// 互换合约估值持仓信息
var eodSwapPosiQuery = from eod in DbContext.eod_swap_position.Where(x => x.ValueDate <= balanceDate && x.ValueDate >= preBalanceDate&&x.PosiDirection>0)
join t in DbContext.trade.Where(x => x.TradeType == "收益互换" && x.ValidState != ConsGlobal.InValid && ConsTrade.TradeStatusAfterConfirmed.Contains(x.TradeStatus)) on eod.SwapTradeId equals t.id
select eod;
var positionList = DbContext.trade.Where(t => (ConsTrade.TradeStatusAfterConfirmed.Contains(t.TradeStatus)||t.UnWindDate> balanceDate) && t.ValidState != "InValid"&&t.TradeType=="收益互换");
var marignQuery = from t in positionList
join s in DbContext.eod_swap_position on t.id equals s.SwapTradeId
@@ -142,9 +145,11 @@ namespace YLErp.Modules.EodModule.SettlementModule
};
var eodSwaps = eodSwapQuery.ToList();
var eodSwapPosis = eodSwapPosiQuery.ToList();
if (reqClientIds != null && reqClientIds.Any())
{
eodSwaps = eodSwaps.Where(t => reqClientIds.Contains(t.ClientId)).ToList();
eodSwapPosis= eodSwapPosis.Where(t => reqClientIds.Contains(t.ClientId)).ToList();
marignQuery = marignQuery.Where(t => reqClientIds.Contains(t.ClientId));
}
var swapIds = eodSwaps.Select(s => s.SwapTradeId);
@@ -701,6 +706,7 @@ namespace YLErp.Modules.EodModule.SettlementModule
//持仓交易
var positionTrades = trades.Where(t => t.TradeStatus.Equals(ConsTrade.) && t.ClientId == client.id && t.TradeType != "收益互换").ToList();
var clientEodSwaps = eodSwaps.Where(t => t.ClientId == client.id && t.ValueDate == balanceDate).ToList();
var clientEodSwapPosis= eodSwapPosis.Where(t => t.ClientId == client.id && t.ValueDate == balanceDate).ToList();
//var tradeIds = clientTrades.Where(t => t.ClientId == client.id).Select(t => t.id).ToList();
//获取所有持仓交易ids
var positionTradeIds = positionTrades == null || positionTrades.Count == 0 ? new List<int>() : positionTrades.Select(t => t.id).ToList();
@@ -837,14 +843,17 @@ namespace YLErp.Modules.EodModule.SettlementModule
}
#region V2
var clientEodSwapsLast = clientEodSwaps.ToList();
var clientEodSwapPositionLast = clientEodSwapPosis.ToList();
foreach (var item in clientEodSwapsLast)
{
var lastEodSwap = eodSwaps.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == preBalanceDate);
var lastEodSwapPosition = eodSwapPosis.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == preBalanceDate);
var eodSwapPosition = clientEodSwapPositionLast.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == balanceDate);
PotentialSurpluses += Convert.ToDouble(item.PostionValue) * (-1);
WinLoss += Convert.ToDouble(item.TdRealizedPnL) * (-1);
var lastPv = lastEodSwap != null ? Convert.ToDouble(lastEodSwap.PostionValue) * (-1) : 0;
var lastPv = lastEodSwap != null ? Convert.ToDouble(lastEodSwap.PostionValue- lastEodSwapPosition?.VTradingFee+lastEodSwapPosition?.PosiFeePending) * (-1) : 0;
eodPnlSum.LastPvSum = eodPnlSum.LastPvSum.HasValue ? eodPnlSum.LastPvSum + lastPv : lastPv;
var pnl = item.PostionValue;
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);