From dc1df57dcf98473251396bfd97151cc56dd138a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Mon, 30 Jun 2025 10:20:50 +0800 Subject: [PATCH] =?UTF-8?q?TRS-ZS-560=20=E8=B4=B9=E7=94=A8=E4=BF=9D?= =?UTF-8?q?=E7=95=992=E4=BD=8D=E8=90=BD=E5=BA=93=EF=BC=8C=E5=B9=B3?= =?UTF-8?q?=E4=BB=93=E5=88=A9=E6=81=AF=E4=BF=9D=E7=95=992=E4=BD=8D?= =?UTF-8?q?=EF=BC=8C=E4=BC=B0=E5=80=BC=E4=BF=9D=E7=95=992=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EodSettlement/RealTimeClientBanlanceService.cs | 1 + .../SettlementModule/EodClientBalanceCalc.cs | 1 + .../SettlementReportFotShanXiService.cs | 2 +- YLErpDAL/Modules/SwapModule/SwapConsumerService.cs | 2 +- YLErpDAL/Modules/SwapModule/SwapDealService.cs | 8 +++++++- .../Modules/SwapModule/SwapEodPositionService.cs | 2 +- YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs | 12 ++++++------ YLErpDAL/Modules/SwapModule/SwapTradeService.cs | 2 ++ YLErpWeb/Controllers/SwapTrade2Controller.cs | 6 ++++++ 9 files changed, 26 insertions(+), 10 deletions(-) diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index 1aa983a4..3d160c44 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -1282,6 +1282,7 @@ namespace YLErp.BLL.Eod var flowEvents = swapFlowEvents.Where(x => x.SwapTradeId == item.Key).ToList(); var unwindQty = flowEvents.Sum(s => s.Quantity); var pnl = lastEodSwap.PostionValue; + pnl=Math.Round(pnl, ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero); decimal unwindPercent = 0; if (unwindQty != 0) { diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs index e27d8b5a..3cbd5394 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs @@ -809,6 +809,7 @@ namespace YLErp.Modules.EodModule.SettlementModule var lastEodSwap = eodSwaps.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == preBalanceDate); var lastEodSwapPosition = eodSwapPosis.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == preBalanceDate&&t.PosiStartDate<= preBalanceDate); var eodSwapPosition = clientEodSwapPositionLast.FirstOrDefault(t => t.SwapTradeId == item.SwapTradeId && t.ValueDate == balanceDate && t.PosiStartDate <= balanceDate); + item.PostionValue=Math.Round(item.PostionValue, ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero); PotentialSurpluses += Convert.ToDouble(item.PostionValue) * (-1); // WinLoss += Convert.ToDouble(item.TdRealizedPnL) * (-1); var lastPv = lastEodSwap != null ? Convert.ToDouble(lastEodSwap.PostionValue) * (-1) : 0; diff --git a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs index f057be3c..35430716 100644 --- a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs +++ b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs @@ -334,7 +334,7 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule PositionPremiumNetCash = clientBalance?.PositionPremiumNetCash ?? 0, SellTradePrice = clientBalance?.SellTradePrice, LastDayPositionPremiumNetCash = clientBalance?.LastDayPositionPremiumNetCash ?? 0, - WinLoss = clientBalance?.WinLoss ?? 0, + WinLoss =Math.Round( clientBalance?.WinLoss ?? 0,ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero), ClosedTradeFundGap = clientBalance?.ClosedTradeFundGap ?? 0, ClosedTradePayableFund = clientBalance?.ClosedTradePayableFundTotal ?? 0, PositionTradePayableFund = clientBalance?.MarginByPayableMarginTotal ?? 0, diff --git a/YLErpDAL/Modules/SwapModule/SwapConsumerService.cs b/YLErpDAL/Modules/SwapModule/SwapConsumerService.cs index 24a8e6fd..c51deba7 100644 --- a/YLErpDAL/Modules/SwapModule/SwapConsumerService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapConsumerService.cs @@ -141,7 +141,7 @@ namespace YLErp.Modules.SwapModule swapFlow.TradingAmountFeeAvg = result.TradingAmountFeeAvg; swapFlow.TradingAmountNet = result.TradingAmountNet; swapFlow.TradingAmountNetFee = result.TradingAmountNetFee; - swapFlow.TradingFee = result.TradingFee; + swapFlow.TradingFee =Math.Round( result.TradingFee, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); swapFlow.TradingQty = result.TradingQty; swapFlow.trs_deal_id = result.trs_deal_id; swapFlow.UnderlyingCode = result.UnderlyingCode; diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 4db24dfa..33023148 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -878,7 +878,7 @@ namespace YLErp.Modules.SwapModule floatEvent.TradingAmountNetFeeAvg = unwindNetFee; floatEvent.TradingAmountNetAvg = unwindNet; floatEvent.TradingFeePending = position.PosiTradingFeePending * unwindData.ClosePercent; - floatEvent.TradingFeePending = Math.Round(floatEvent.TradingFeePending, 4, MidpointRounding.AwayFromZero); + floatEvent.TradingFeePending = Math.Round(floatEvent.TradingFeePending, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); floatEvent.TradingFee = closeFee; floatEvent.MarkClosePnl = (unwindPrice - position.PosiGrossPrice) * unwindQty * floatRatio * longRatio; floatEvent.MarkClosePnl = Math.Round(floatEvent.MarkClosePnl + ((floatEvent.TradingFeePending+ closeFee) * floatRatio * -1), ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); @@ -894,6 +894,12 @@ namespace YLErp.Modules.SwapModule { item.OptLog = "流水自动"; }); + foreach (var item in interestPositions) + { + item.TdInterestAmount=Math.Round(item.TdInterestAmount, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); + item.InterestAmount=Math.Round(item.InterestAmount, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); + item.InterestClosePnL = Math.Round(item.InterestClosePnL, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); + } unwindData.FlowEvents.AddRange(interestPositions); CalcCloseAmount(unwindData); DealUnwind(unwindData, td); diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index a7e59072..bb65c7be 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1915,7 +1915,7 @@ namespace YLErp.Modules.SwapModule item.InterestAmount = eodInterests.Sum(s => s.InterestIncomeSum * (s.InterestDirection == (int)SwapDirectionEnum.收取 ? -1 : 1)); item.InterestRate = eodInterests.Sum(s => s.InterestRateDefault); item.NetSettmentAmount += item.InterestAmount + item.MarginInterestAmount + eodMargins.Sum(s => s.InterestPrincipalFix * (s.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1)); - item.NetSettmentAmount = decimal.Parse(item.NetSettmentAmount.ToString("0.00")); + item.NetSettmentAmount = Math.Round(item.NetSettmentAmount, ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero); if (item.position.PosiNotionalValue != 0 && item.position.PosiNetPrice != 0) { item.FloatRateAbs = item.position.PosiNotionalValue == 0 ? 0 : item.InterestAmount / item.position.PosiNotionalValue; diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs index 4ef7cb44..75b9f2ff 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs @@ -71,6 +71,7 @@ namespace YLErp.Modules.SwapModule swapFlow.UnderlyingCode = item.security_id; swapFlow.TradingQty = (item.last_shares ?? 0) * 10000; swapFlow.TradingFee = (item.commission ?? 0); + swapFlow.TradingFee = Math.Round(swapFlow.TradingFee, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); if (swapFlow.id == 0 || reset) { swapFlow.SwapTradeId = null; @@ -358,6 +359,7 @@ namespace YLErp.Modules.SwapModule TradingAmount = gourpItem.Sum(s => s.TradingAmount), }; int tradeSide = swap_flow_summary.BsType == (int)EnumDirection.Long ? 1 : -1; + swap_flow_summary.TradingFeePending = Math.Round(swap_flow_summary.TradingFeePending, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); swap_flow_summary.FirstFlowTime = swapflow.OptTime; swap_flow_summary.SettleDate = gourpItem.Max(s => s.SettleDate); swap_flow_summary.TradingAmountAvg = swap_flow_summary.TradingQty == 0 ? 0 : gourpItem.Sum(s => s.TradingAmountAvg * s.TradingQty) / swap_flow_summary.TradingQty; @@ -1144,7 +1146,8 @@ namespace YLErp.Modules.SwapModule var newOpenQty = currentPosiQty - flowQty; var unwindQty = newOpenQty > 0 ? flowQty : currentPosiQty; var unwindFee = flowSameClone.TradingFeePending * unwindQty / currentPosiQty; - + unwindFee=Math.Round(unwindFee,ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero); + flowSameClone.TradingFeePending= flowSameClone.TradingFeePending - unwindFee; flowQty = flowQty - unwindQty; // 平仓 new SwapDealService(UserInfo).AuotoSwapUnwind(trade.id, @@ -1157,11 +1160,8 @@ namespace YLErp.Modules.SwapModule unwindFee); if (flowQty>0) { - var unwindPercent = 1 - (flowQty / flowSameClone.TradingQty); - var fee = (1 - unwindPercent) * flowSameClone.TradingFeePending; flowSameClone.TradingQty = flowQty; flowSameClone.TradingAmount = flowSameClone.TradingQty; - flowSameClone.TradingFeePending = fee; NewSwapTrade(flowSameClone, client, asset, underlying, floatRate, clientMarginTemplate, clearingAgency); } } @@ -1208,8 +1208,8 @@ namespace YLErp.Modules.SwapModule var newOpenQty = posiQty - flowQty; var unwindQty = newOpenQty > 0 ? flowQty : posiQty; var unwindFee = swapFlow.TradingFeePending* unwindQty / flowQty; - - flowQty = flowQty - unwindQty; + unwindFee=Math.Round(unwindFee, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); + flowQty = flowQty - unwindQty; swapFlow.TradingFeePending = swapFlow.TradingFeePending - unwindFee; // 平仓 new SwapDealService(UserInfo).AuotoSwapUnwind(td.id, diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs index 47e63a76..771c0dd8 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs @@ -1343,8 +1343,10 @@ namespace YLErp.Modules.SwapModule position.id = swap.id; position.PositionType = swap.PositionType; position.PosiTradingFee = swap.PosiTradingFee; + position.PosiTradingFee=Math.Round(position.PosiTradingFee, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); position.PosiTradingFeeUnit = swap.PosiTradingFeeUnit; position.PosiTradingFeePending = swap.PosiTradingFeePending; + position.PosiTradingFeePending = Math.Round(position.PosiTradingFeePending, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); position.UnderlyingCode = swap.UnderlyingCode; position.UnderlyingInstrumentType = swap.UnderlyingInstrumentType; position.PosiDirection = swap.PosiDirection; diff --git a/YLErpWeb/Controllers/SwapTrade2Controller.cs b/YLErpWeb/Controllers/SwapTrade2Controller.cs index 0a3b05f8..d2d53680 100644 --- a/YLErpWeb/Controllers/SwapTrade2Controller.cs +++ b/YLErpWeb/Controllers/SwapTrade2Controller.cs @@ -265,6 +265,12 @@ namespace YLErp.Web.Controllers public JsonResult GetUnwindInterestList(DateTime valueDate,DateTime unwindDate, int tradeId, decimal closePercent, int eventType) { var interests = new SwapDealService(CurUser).GetUnwindInterests(valueDate, unwindDate, tradeId, closePercent, eventType); + foreach (var interest in interests) + { + interest.TdInterestAmount=Math.Round(interest.TdInterestAmount, ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero); + interest.InterestAmount=Math.Round(interest.InterestAmount, ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero); + interest.InterestClosePnL=Math.Round(interest.InterestClosePnL, ConsGlobal.MoneyRound,MidpointRounding.AwayFromZero); + } return JsonSuccess("", interests); } ///