From f2466bc7b7cd035a8a4b37faef913f84e02f22ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Mon, 21 Apr 2025 10:20:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E7=9B=98=E4=BF=AE=E5=A4=8D&=E5=8F=AF?= =?UTF-8?q?=E5=8F=96=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BLL/EodSettlement/ClientBalanceUtility.cs | 4 +- .../RealTimeClientBanlanceService.cs | 4 +- .../SwapModule/SwapEodPositionService.cs | 41 +++++++++---------- YLErpWeb/appsettings.local.json | 2 +- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs index 4d27ed92..87f8f5ef 100644 --- a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs +++ b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs @@ -357,8 +357,8 @@ namespace YLErp.BLL.EodSettlement balance.NeedAddMargin = balance.SwapMarketAmount < balance.MaintenanceMargin; // 追保金额=初始保证金金额-盯市金额 balance.MarginByPayableMarginTotal = balance.NeedAddMargin ? (balance.MySideMargin - balance.SwapMarketAmount):0; - // 可取资金=期末结存-min(持仓盈亏,0)-初始保证金 - balance.DesirableFund = balance.MarginBalance + Math.Min(balance.RoundedPositionPnl, 0); + // 可取资金=Math.Max(期末结存-min(持仓盈亏,0)-初始保证金,0) + balance.DesirableFund = Math.Max(balance.MarginBalance + Math.Min(balance.RoundedPositionPnl, 0),0); } } diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index 63b18f1a..4e13fb6b 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -279,8 +279,8 @@ namespace YLErp.BLL.Eod item.NeedAddMargin = item.SwapMarketAmount < item.MaintenanceMargin; // 追保金额=初始保证金金额-盯市金额 item.MarginByPayableMarginTotal = item.NeedAddMargin ? (item.MySideMargin - item.SwapMarketAmount) : 0; - // 可取资金=期末结存-min(持仓盈亏,0)-初始保证金 - item.DesirableFund = item.MarginBalance + Math.Min(item.RoundedPositionPnl, 0); + // 可取资金=max(期末结存+min(持仓盈亏,0)-初始保证金,0) + item.DesirableFund =Math.Max( item.MarginBalance + Math.Min(item.RoundedPositionPnl, 0),0); } return _clientBalanceDic.Values; diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 34ac96d9..6a7f52aa 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -135,19 +135,17 @@ namespace YLErp.Modules.SwapModule { throw new Exception($"交易【{td.TradeNumber}】到期扔有持仓信息"); } - //实际自动互换数据开头已删除 - var longEventTypes = eventTyps; - longEventTypes.Add((int)SwapFlowEventTypeEnum.开仓); var flowEvents = new List(); - Expression> eventExpression = x => x.SwapTradeId == td.id && x.DataState == (int)SwapFlowDateStateEnum.完成 && longEventTypes.Contains(x.EventType); - if (settleDate == td.TradeDate) - { - eventExpression = eventExpression.And(x => x.EventDate == settleDate); - } - else - { - eventExpression = eventExpression.And(x => x.UnwindDate == settleDate); - } + Expression> eventExpression = x => x.SwapTradeId == td.id && x.DataState == (int)SwapFlowDateStateEnum.完成; + eventExpression = eventExpression.And(x => (x.EventDate == settleDate && x.EventType == (int)SwapFlowEventTypeEnum.开仓) || (x.UnwindDate == settleDate && eventTyps.Contains(x.EventType))); + //if (settleDate == td.TradeDate) + //{ + // eventExpression = eventExpression.And(x => x.EventDate == settleDate); + //} + //else + //{ + // eventExpression = eventExpression.And(x => x.UnwindDate == settleDate); + //} flowEvents = DbContext.swap_flow_event.Where(eventExpression).ToList(); var preDealDate = GetPreDealDate(td.id, settleDate, eventTyps);//上一次平仓/互换/自动互换处理日期 List autoInterests = new List();//自动互换利息腿信息 @@ -1153,7 +1151,7 @@ namespace YLErp.Modules.SwapModule curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; curretEod.TdPosiDividend = 0; curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend; - curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum+ curretEod.VTradingFee; + curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum+ curretEod.PosiFeePending; curretEod.TdCloseFee = 0; curretEod.TdCloseQty = 0; curretEod.TdCloseMtmPnl = 0; @@ -1217,7 +1215,7 @@ namespace YLErp.Modules.SwapModule curretEod.UnderlyingMarketValue = curretEod.UnderlyingPrice * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio; curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend; - curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.VTradingFee; + curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.PosiFeePending; curretEod.RealizedMtmPnL = eod.RealizedMtmPnL + curretEod.TdCloseMtmPnl; curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend; curretEod.RealizedFee = eod.RealizedFee + curretEod.TdCloseFee; @@ -1349,17 +1347,16 @@ namespace YLErp.Modules.SwapModule curretEod.PosiTradingFee = position.PosiTradingFee; curretEod.UnderlyingPrice = UnderlyingCodePrice(position.UnderlyingCode, dealDate, out decimal vobp); SetPriceInfoByFlowEvent(eod, curretEod, unwindEvents, position); + if (settleDate == td.TradeDate) + { + curretEod.UnderlyingPrice = curretEod.PosiGrossPrice; + curretEod.TdCloseMtmPnl = 0; + curretEod.TdCloseFee = 0; + } curretEod.TdCloseDividend = curretEod.TdPosiDividend; curretEod.UnderlyingMarketValue = curretEod.UnderlyingPrice * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio; curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio; - if (settleDate == td.TradeDate) - { - curretEod.PosiMtmPnL = 0; - //curretEod.TdCloseMtmPnl = 0; - //curretEod.TdCloseFee = 0; - } - curretEod.PosiDividendSum = curretEod.TdPosiDividend; - curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.VTradingFee; + curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.PosiFeePending; curretEod.RealizedMtmPnL = curretEod.TdCloseMtmPnl; curretEod.RealizedDividend = curretEod.TdCloseDividend; curretEod.RealizedFee = curretEod.TdCloseFee; diff --git a/YLErpWeb/appsettings.local.json b/YLErpWeb/appsettings.local.json index 8da1e8bb..308bb4f5 100644 --- a/YLErpWeb/appsettings.local.json +++ b/YLErpWeb/appsettings.local.json @@ -67,7 +67,7 @@ "YiLian_SwapFlowGroup": "YiLian_SwapFlowGroup1" //交易端同步流水消费组 }, "BondOmsInterface": { - "BaseUrl": "http://git.yiliantech.com:8887" + "BaseUrl": "http://trs.yiliantech.com:8080/trs_hub_api" }, "OrcaleDatabaseConfig": { "Schema": "APEX_040000"