fix: 实时持仓计算成交净价

This commit is contained in:
gongpei
2025-11-04 14:31:02 +08:00
parent c7e13fceb4
commit 374182de62
@@ -571,12 +571,13 @@ namespace YLErp.BLL.Eod
: s.PosiGrossPrice;
return s.PosiQuantity * price;
}) / posiQty;
// 使用标的期初价格不含费计算
var weightedNetPrice = posiQty == 0 ? 0 : positionGroupItems
.Sum(s =>
{
decimal price = ConsGlobal.InstrumentType.IsBond(lastPosi.UnderlyingInstrumentType)
? s.PosiNetPrice * ConsGlobal.bondShowPriceMultiple
: s.PosiNetPrice;
? s.PosiNetNoFeePrice ?? 0 * ConsGlobal.bondShowPriceMultiple
: s.PosiNetNoFeePrice ?? 0;
return s.PosiQuantity * price;
}) / posiQty;
// 替换原代码中的 price 和 netPrice
@@ -597,7 +598,7 @@ namespace YLErp.BLL.Eod
}
clientPosition.update_user = 0;
SetClientPositionPrice(clientPosition);
clientPosition.swap_market_value = clientPosition.full_price_now * clientPosition.position_qty * (clientPosition.side == 0 ? 1 : -1);
clientPosition.swap_market_value = clientPosition.full_price_now * clientPosition.position_qty * (clientPosition.side == 0 ? 1 : -1) * 100;
clientPosition.position_profit_loss = (clientPosition.full_price_now - clientPosition.deal_full_price_avg) * 0.01m * (clientPosition.position_qty * 10000) * (clientPosition.side == 0 ? 1 : -1) - clientPosition.commission;
clientPosition.position_profit_loss = Math.Round(clientPosition.position_profit_loss ?? 0, 2, MidpointRounding.AwayFromZero);
clientPosition.today_profit_loss = clientPosition.swap_market_value - lastPv;