diff --git a/UnitTestProject/Modules/CalcModules/CalculationTest.cs b/UnitTestProject/Modules/CalcModules/CalculationTest.cs index 5a153d49..013454d1 100644 --- a/UnitTestProject/Modules/CalcModules/CalculationTest.cs +++ b/UnitTestProject/Modules/CalcModules/CalculationTest.cs @@ -135,7 +135,16 @@ namespace YLErp.Modules.CalcModules Assert.AreEqual(date20190708, QdpCalendarHelper.GetNonHolidayDefore(date20190708)); #endregion } - + [TestMethod] + public void CalendarBLLGetNonHolidayDeforeTest() + { + var date20250421 = new DateTime(2025, 04, 21); + var date20250418 = new DateTime(2025, 04, 18); + var cudate = QdpCalendarHelper.GetNonHolidayDefore(date20250421.AddDays(0)); + var preDate = QdpCalendarHelper.GetNonHolidayDefore(date20250421.AddDays(-1)); + Assert.AreEqual(date20250421, cudate); + Assert.AreEqual(date20250418, preDate); + } [TestMethod] public void GetObservationDateStringTest() { diff --git a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs index 87f8f5ef..f224b024 100644 --- a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs +++ b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs @@ -582,14 +582,7 @@ namespace YLErp.BLL.EodSettlement DicTotal.TotalMarginTotal = DicTotal.TotalMargin; DicTotal.RoundedTotalAmountTotal = DicTotal.RoundedTotalAmount; DicTotal.TotalAmountTotal = DicTotal.TotalAmount; - if (PS.Config.Is湘财) - { - DicTotal.MarginByPayableMarginTotal = Math.Max(-DicTotal.AvailableAmount, 0); - } - else - { - DicTotal.MarginByPayableMarginTotal = DicTotal.MarginByPayableMargin; - } + DicTotal.MarginByPayableMarginTotal = DicTotal.MarginByPayableMarginTotal; //if (PS.Config.Is广期资本) //{ // DicTotal.MarginByPayableMarginTotal = Math.Max(-DicTotal.AvailableAmount, 0); @@ -637,18 +630,7 @@ namespace YLErp.BLL.EodSettlement DicTotal.RoundedTotalAmountTotal += dc.Value.RoundedTotalAmount; DicTotal.TotalAmountTotal += dc.Value.TotalAmount; - if (PS.Config.Is湘财) - { - DicTotal.MarginByPayableMarginTotal += Math.Max(-dc.Value.AvailableAmount, 0); - } - else - { - DicTotal.MarginByPayableMarginTotal += dc.Value.MarginByPayableMargin; - } - //if (PS.Config.Is广期资本) - //{ - // DicTotal.MarginByPayableMarginTotal = Math.Max(-DicTotal.AvailableAmount, 0); - //} + DicTotal.MarginByPayableMarginTotal += dc.Value.MarginByPayableMarginTotal; DicTotal.ClosedTradePayableFundTotal += dc.Value.ClosedTradePayableFund; DicTotal.PositionTradePayableFundTotal += dc.Value.PositionTradePayableFund; diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index 4e13fb6b..be1ac174 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -280,7 +280,7 @@ namespace YLErp.BLL.Eod // 追保金额=初始保证金金额-盯市金额 item.MarginByPayableMarginTotal = item.NeedAddMargin ? (item.MySideMargin - item.SwapMarketAmount) : 0; // 可取资金=max(期末结存+min(持仓盈亏,0)-初始保证金,0) - item.DesirableFund =Math.Max( item.MarginBalance + Math.Min(item.RoundedPositionPnl, 0),0); + item.DesirableFund =Math.Max( item.MarginBalance - item.FrozenMarginMoney + Math.Min(item.RoundedPositionPnl, 0),0); } return _clientBalanceDic.Values; @@ -1314,8 +1314,8 @@ namespace YLErp.BLL.Eod balance.UpdateDate = balance.UpdateDate > lastEodSwap.OptTime ? balance.UpdateDate : lastEodSwap.OptTime; } balance.WinLoss += Convert.ToDouble(tdRealizedPnL) * -1; - balance.PositionPnl += Convert.ToDouble(pnl); - balance.RoundedPositionPnl += Math.Round(Convert.ToDouble(pnl), 2); + balance.PositionPnl += Convert.ToDouble(pnl) * -1; + balance.RoundedPositionPnl += Math.Round(Convert.ToDouble(pnl), 2) * -1; //期权空头浮动盈利=∑max(期权空头持仓*(期权合约成本价-期权合约现价), 0) 从客户角度看的 balance.ClientSellPositionPnl += Convert.ToDouble(lastEodSwap.FloatingPnL) * -1; } diff --git a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs index 5946909d..2298e3fb 100644 --- a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs +++ b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs @@ -317,7 +317,7 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule WinLoss = clientBalance?.WinLoss ?? 0, ClosedTradeFundGap = clientBalance?.ClosedTradeFundGap ?? 0, ClosedTradePayableFund = clientBalance?.ClosedTradePayableFundTotal ?? 0, - PositionTradePayableFund = clientBalance?.PositionTradePayableFundTotal ?? 0, + PositionTradePayableFund = clientBalance?.MarginByPayableMarginTotal ?? 0, DesirableFund = clientBalance?.DesirableFundTotal ?? 0, PayableFund = emailData.PayableFund >= 0 ? emailData.PayableFund : (clientBalance?.PayableFundTotal ?? 0), PositionPv = PS.Config.IsPVRounded ? (clientBalance?.RoundedPositionPv ?? 0) : (clientBalance?.PositionPv ?? 0), diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs index 10845c4e..51f308c6 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs @@ -1350,8 +1350,11 @@ namespace YLErp.Modules.SwapModule position.UnderlyingInstrumentType = swap.UnderlyingInstrumentType; position.PosiDirection = swap.PosiDirection; position.PosiGrossPrice = swap.PosiGrossPrice; - position.PosiNetPrice = swap.PosiQuantity == 0 ? 0 : (swap.PosiGrossPrice + (position.PosiTradingFee / swap.PosiQuantity) * ratio); + position.PosiNetPrice = swap.PosiQuantity == 0 ? 0 : (swap.PosiGrossPrice + (position.PosiTradingFeePending / swap.PosiQuantity) * ratio); position.PosiNetPrice = Math.Round(position.PosiNetPrice, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero); + position.PosiNetNoFeePrice = swap.PosiNetNoFeePrice; + position.PosiNetFeePrice = swap.PosiQuantity == 0 ? 0 : (swap.PosiNetNoFeePrice + (position.PosiTradingFeePending / swap.PosiQuantity) * ratio); + position.PosiNetFeePrice = Math.Round(position.PosiNetFeePrice??0, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero); position.PosiNotionalValue = position.PosiGrossPrice * swap.PosiQuantity * swap.ContractSize; position.PosiQuantity = swap.PosiQuantity; position.InterestDirection = swap.InterestDirection; diff --git a/YLErpWeb/Controllers/clientController.cs b/YLErpWeb/Controllers/clientController.cs index 85a8f946..c770f1d9 100644 --- a/YLErpWeb/Controllers/clientController.cs +++ b/YLErpWeb/Controllers/clientController.cs @@ -625,7 +625,7 @@ namespace YLErp.Web.Controllers x.HoldingDepositB = -clientBalance.PayableMarginB; x.SwapPayableMargin = -clientBalance.SwapPayableMargin; x.AvailableAmount = clientBalance.AvailableAmount; - x.InsuredAmount = clientBalance.PositionTradePayableFundTotal; + x.InsuredAmount = clientBalance.MarginByPayableMarginTotal; x.MarginMonitoringTime = clientBalance.UpdateDate ?? DateTime.Now; x.FreezePremium = clientBalance.FreezePremium; x.ReceivablesPremium = clientBalance.ReceivablesPremium; diff --git a/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml b/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml index b7b6b937..7778d0b9 100644 --- a/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml +++ b/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml @@ -130,7 +130,7 @@