收盘修复&可取修复

This commit is contained in:
吴方海
2025-04-21 10:20:47 +08:00
parent 4095e25997
commit f2466bc7b7
4 changed files with 24 additions and 27 deletions
@@ -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);
}
}
@@ -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;
@@ -135,19 +135,17 @@ namespace YLErp.Modules.SwapModule
{
throw new Exception($"交易【{td.TradeNumber}】到期扔有持仓信息");
}
//实际自动互换数据开头已删除
var longEventTypes = eventTyps;
longEventTypes.Add((int)SwapFlowEventTypeEnum.);
var flowEvents = new List<swap_flow_event>();
Expression<Func<swap_flow_event, bool>> 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<Func<swap_flow_event, bool>> 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<swap_flow_event> autoInterests = new List<swap_flow_event>();//自动互换利息腿信息
@@ -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;
+1 -1
View File
@@ -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"