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
@@ -37,6 +37,8 @@ namespace YLErp.Modules.SwapModule
/// <summary>持久化 eod 持仓记录(生产: DbContext.Add;测试: 收集到列表)</summary>
protected virtual void PersistEodSwapPosition(eod_swap_position position)
{
position.PosiGrossPrice = Math.Round(position.PosiGrossPrice, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
position.UnderlyingPrice = Math.Round(position.UnderlyingPrice, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
position.PosiNotionalValue = Math.Round(position.PosiNotionalValue, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero);
if (position.id == 0)
{
@@ -181,10 +183,10 @@ namespace YLErp.Modules.SwapModule
{
var normalizedPrice = BondPriceConverter.ToStorage(price);
Log.Error($"互换债券日终价格按展示态返回,已转换为存储态: UnderlyingCode={code}, ValueDate={settleDate:yyyy-MM-dd}, PosiGrossPrice={posiGrossPrice}, SourcePrice={price}, NormalizedPrice={normalizedPrice}");
return normalizedPrice;
return Math.Round(normalizedPrice, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
}
return price;
return Math.Round(price, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
}
/// <summary>获取标的缓存数据(生产: DataCacheProvider;测试: 返回内存对象)</summary>
@@ -1473,7 +1475,7 @@ namespace YLErp.Modules.SwapModule
newEodPayPosition.ContractSize = eventFlow.ContractSize;
newEodPayPosition.CountRatio = eventFlow.CountRatio;
newEodPayPosition.PosiNetPrice = netPrice;
newEodPayPosition.PosiGrossPrice = grossPrice;
newEodPayPosition.PosiGrossPrice = Math.Round(grossPrice, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
newEodPayPosition.PosiNetFeePrice = netFeePrice;
newEodPayPosition.PosiNetNoFeePrice = netNoFeePrice;
newEodPayPosition.PosiQuantity = payQty;
@@ -1772,7 +1774,7 @@ namespace YLErp.Modules.SwapModule
posiQty = 0;
}
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.PosiGrossPrice = Math.Round(curretEod.PosiGrossPrice, ConsGlobal.SwapDeliveryPriceRound, 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);
@@ -1898,14 +1900,14 @@ namespace YLErp.Modules.SwapModule
}
if (data.IsBond())
{
return BondPrice(data, settleDate, out vobp);
return Math.Round(BondPrice(data, settleDate, out vobp), ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
}
var price = data.Price ?? 0;
if (EodPriceQueryService.TryGetEodPrice(settleDate, code, out var eodPrice))
{
price = eodPrice.GetPrice(SettlementTypeEnum.ClosePrice);
}
return Convert.ToDecimal(price);
return Math.Round(Convert.ToDecimal(price), ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
}
/// <summary>
/// 获取债券收盘价格