名义本金算价格
This commit is contained in:
@@ -156,11 +156,7 @@ namespace YLErp.Modules.SwapModule
|
||||
var curEodPosis = DealFloatPositions(posiList, realPosiList, eodPositions, todyEodPositions, settleDate, td, preSettleDate, flowEvents);
|
||||
var posiLongNotional = curEodPosis.Where(s => s.PositionType == (int)PositionTypeFlag.Long).Sum(s => s.PosiNotionalValue);
|
||||
var posiShortNotional = curEodPosis.Where(s => s.PositionType == (int)PositionTypeFlag.Short).Sum(s => s.PosiNotionalValue);
|
||||
var closePosiNotional = curEodPosis.Where(s => s.TdCloseQty > 0).Sum(s => s.TdCloseQty * s.ContractSize);
|
||||
if (longShort)
|
||||
{
|
||||
closePosiNotional = curEodPosis.Where(s => s.TdCloseQty > 0).Sum(s => s.TdCloseQty * s.ContractSize * s.PosiNetPrice);
|
||||
}
|
||||
var closePosiNotional = curEodPosis.Where(s => s.TdCloseQty > 0).Sum(s => s.TdCloseQty * s.ContractSize * s.PosiNetPrice);
|
||||
var grossPrice = curEodPosis.Where(x => x.PosiDirection > 0).FirstOrDefault()?.PosiGrossPrice ?? 0;
|
||||
//处理利息腿
|
||||
DealInterests(interestList, eodPositions, todyEodPositions, settleDate, td, flowEvents, autoInterests, lastEodSwap, posiLongNotional, posiShortNotional, closePosiNotional, grossPrice, orginPv);
|
||||
@@ -314,20 +310,9 @@ namespace YLErp.Modules.SwapModule
|
||||
var unwindEvents = flowEvents.Where(x => x.PositionId == posi.id).ToList();//当前日平仓信息
|
||||
var realPosition = realPosiList.FirstOrDefault(s => s.PositionId == posi.id);
|
||||
eod_swap_position eodPosi = new eod_swap_position();
|
||||
if (eodPosition == null || td.StartDate == settleDate)
|
||||
if (eodPosition == null || td.TradeDate == settleDate)
|
||||
{
|
||||
if (tdEodPosition == null)//第一次生成归档信息
|
||||
{
|
||||
eodPosi = SaveCurrentEodInitalPosi(posi, td, settleDate, preSettleDate, unwindEvents);
|
||||
}
|
||||
else
|
||||
{
|
||||
tdEodPosition.PosiFeePending = posi.PosiTradingFeePending;
|
||||
tdEodPosition.PosiNotionalValue = tdEodPosition.PosiQuantity * tdEodPosition.ContractSize;
|
||||
tdEodPosition.PosiNetFeePrice = posi.PosiNetFeePrice;
|
||||
tdEodPosition.PosiNetNoFeePrice = posi.PosiNetNoFeePrice;
|
||||
}
|
||||
|
||||
eodPosi = SaveCurrentEodInitalPosi(posi, td, settleDate, preSettleDate, unwindEvents);
|
||||
}
|
||||
else if (unwindEvents.Count() == 0)
|
||||
{
|
||||
@@ -1276,12 +1261,12 @@ namespace YLErp.Modules.SwapModule
|
||||
curretEod.PosiNetFeePrice = position.PosiNetFeePrice;
|
||||
curretEod.PosiNetNoFeePrice = position.PosiNetNoFeePrice;
|
||||
curretEod.PosiQuantity = position.PosiQuantity;
|
||||
curretEod.PosiTradingFee = position.PosiTradingFee;
|
||||
curretEod.PosiTradingFee = -position.PosiTradingFee * directionRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
var eventTradingFee = unwindEvents.Where(x => x.EventType == (int)SwapFlowEventTypeEnum.开仓 || x.EventType == (int)SwapFlowEventTypeEnum.平仓).Sum(s => s.TradingFeePending * (s.EventType == (int)SwapFlowEventTypeEnum.开仓 ? 1 : -1));
|
||||
curretEod.PosiFeePending = eod.PosiFeePending + eventTradingFee;
|
||||
var eventTradingFee = openFlowEvents.Sum(s => s.TradingFee);
|
||||
curretEod.PosiTradingFee = eod.PosiTradingFee - eventTradingFee * directionRatio;
|
||||
if (openFlowEvents.Count() == 0)
|
||||
{
|
||||
curretEod.PosiNetPrice = eod.PosiNetPrice;
|
||||
@@ -1297,12 +1282,16 @@ namespace YLErp.Modules.SwapModule
|
||||
{
|
||||
posiQty = 0;
|
||||
}
|
||||
curretEod.PosiGrossPrice = (eod.PosiGrossPrice * posiQty + openFlowEvents.Sum(a => a.Quantity * a.TradingAmountAvg)) / (eod.PosiQuantity + openQty);
|
||||
curretEod.PosiNetNoFeePrice = (eod.PosiNetNoFeePrice * posiQty + openFlowEvents.Sum(a => a.Quantity * a.TradingAmountNetAvg)) / (eod.PosiQuantity + openQty);
|
||||
curretEod.PosiNetFeePrice = curretEod.PosiQuantity == 0 ? eod.PosiNetFeePrice : curretEod.PosiNetNoFeePrice + curretEod.PosiFeePending / curretEod.PosiQuantity * shortRatio;
|
||||
curretEod.PosiNetPrice = curretEod.PosiQuantity == 0 ? eod.PosiNetPrice : curretEod.PosiGrossPrice + curretEod.PosiFeePending / curretEod.PosiQuantity * shortRatio;
|
||||
curretEod.PosiGrossPrice = (eod.PosiGrossPrice * eod.PosiQuantity + openFlowEvents.Sum(a => a.Quantity * a.TradingAmountAvg)) / (eod.PosiQuantity + openQty);
|
||||
curretEod.PosiGrossPrice = Math.Round(curretEod.PosiGrossPrice, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
curretEod.PosiNetPrice = (eod.PosiNetPrice * eod.PosiQuantity + openFlowEvents.Sum(a => a.Quantity * a.TradingAmountFeeAvg)) / (eod.PosiQuantity + openQty);
|
||||
curretEod.PosiNetPrice = Math.Round(curretEod.PosiNetPrice, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
curretEod.PosiNetNoFeePrice = (eod.PosiNetNoFeePrice * eod.PosiQuantity + openFlowEvents.Sum(a => a.Quantity * a.TradingAmountNetAvg)) / (eod.PosiQuantity + openQty);
|
||||
curretEod.PosiNetNoFeePrice = Math.Round(curretEod.PosiNetNoFeePrice ?? 0, 10, MidpointRounding.AwayFromZero);
|
||||
curretEod.PosiNetFeePrice = (eod.PosiNetFeePrice * eod.PosiQuantity + openFlowEvents.Sum(a => a.Quantity * a.TradingAmountNetFeeAvg)) / (eod.PosiQuantity + openQty);
|
||||
curretEod.PosiNetFeePrice = Math.Round(curretEod.PosiNetFeePrice ?? 0, 10, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
curretEod.PosiNotionalValue = curretEod.PosiQuantity * curretEod.ContractSize;
|
||||
curretEod.PosiNotionalValue = curretEod.PosiGrossPrice * curretEod.PosiQuantity * curretEod.ContractSize;
|
||||
curretEod.TdPosiDividend = unwindEvents.Sum(x => x.DividendIn) * directionRatio;
|
||||
//curretEod.TdCloseFee = unwindEvents.Sum(x => x.TradingFee);
|
||||
curretEod.TdCloseQty = unwindQty;
|
||||
|
||||
Reference in New Issue
Block a user