feat(swap): 统一【期初、期末交割价格】精度处理

- 在ConsGlobal中新增SwapDeliveryPriceRound常量定义为9位小数
- 更新incomeSwapTrade.js中交割价格计算逻辑,添加getStorageDeliveryPrice方法
- 修改SwapConsumerService中TradingAmountAvg字段的精度处理
- 添加ValidateDeliveryPrices和NormalizeDeliveryPrices方法进行交割价格验证和标准化
- 在SwapEodPositionService中对PosiGrossPrice和UnderlyingPrice进行精度处理
- 更新SwapFlowEventService中TradingAmountAvg字段的精度处理
- 在SwapFlowImportService中添加交割价格精度处理
- 更新前端界面中的输入格式配置,使用新的交割价格精度设置
- 修改SwapflowList.js中交割价格精度处理逻辑
- 在SwapFlowService中添加交割价格验证和精度处理
- 更新SwapTradeAutoService中交割价格精度处理
- 修改SwapTradeService中PosiGrossPrice字段的精度处理
- 更新unwindSwapTrade.js中交割价格计算逻辑
This commit is contained in:
张名锐
2026-07-22 14:53:46 +08:00
parent 0755233ab6
commit c58a9d40c4
17 changed files with 127 additions and 44 deletions
@@ -51,6 +51,17 @@ namespace YLErp.Modules.SwapModule
{
}
private static decimal ValidateDeliveryPrice(decimal price, string fieldName)
{
var roundedPrice = Math.Round(price, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
if (price != roundedPrice)
{
throw new ServiceException($"{fieldName}最多保留{ConsGlobal.SwapDeliveryPriceRound}位小数");
}
return roundedPrice;
}
#region
/// <summary>
/// 新版收益互换预付金校验
@@ -370,7 +381,7 @@ namespace YLErp.Modules.SwapModule
CountRatio = underlying.CountRatio,
ContractSize = Convert.ToDecimal(underlying.ContractSize),
PosiNetPrice = flowMerge.TradingAmountFeeAvgAbs,
PosiGrossPrice = flowMerge.TradingAmountAvg,
PosiGrossPrice = Math.Round(flowMerge.TradingAmountAvg, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero),
PosiNetFeePrice = flowMerge.TradingAmountNetFeeAvg ?? 0,
PosiNetNoFeePrice = flowMerge.TradingAmountNetAvg ?? 0,
PosiQuantity = flowMerge.TradingQtyAbs,
@@ -1350,8 +1361,11 @@ namespace YLErp.Modules.SwapModule
position.UnderlyingCode = swap.UnderlyingCode;
position.UnderlyingInstrumentType = swap.UnderlyingInstrumentType;
position.PosiDirection = swap.PosiDirection;
position.PosiGrossPrice = swap.PosiGrossPrice;
position.PosiNetPrice = swap.PosiQuantity == 0 ? 0 : (swap.PosiGrossPrice + (position.PosiTradingFeePending / swap.PosiQuantity) * ratio);
// position.PosiGrossPrice = string.IsNullOrEmpty(swap.UnderlyingCode)
// ? Math.Round(swap.PosiGrossPrice, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero)
// : ValidateDeliveryPrice(swap.PosiGrossPrice, "期初交割价");
position.PosiGrossPrice = Math.Round(swap.PosiGrossPrice, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
position.PosiNetPrice = swap.PosiQuantity == 0 ? 0 : (position.PosiGrossPrice + (position.PosiTradingFeePending / swap.PosiQuantity) * ratio);
position.PosiNetPrice = Math.Round(position.PosiNetPrice, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
position.PosiNetNoFeePrice = swap.PosiNetNoFeePrice;
position.PosiNetFeePrice = swap.PosiQuantity == 0 ? 0 : (swap.PosiNetNoFeePrice + (position.PosiTradingFeePending / swap.PosiQuantity) * ratio);