|
|
|
@@ -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;
|
|
|
|
|