refactor(swap): 修复债券日终价格映射
- 移除 GetSwapValuationPrice 方法中的 posiGrossPrice 参数 - 删除债券价格转换相关的注释代码和日志记录 - 简化债券价格处理逻辑,直接使用原始价格进行四舍五入 - 更新所有调用 GetSwapValuationPrice 的地方以匹配新方法签名 - 移除多余的价格转换和展示态判断逻辑
This commit is contained in:
@@ -175,27 +175,15 @@ namespace YLErp.Modules.SwapModule
|
||||
return UnderlyingCodePrice(code, settleDate, out vobp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用于互换浮动腿盯市的标的价格。
|
||||
///
|
||||
/// 普通债券类收益互换的新录入页面将全价按小数保存,例如页面录入 20% 后 PosiGrossPrice 为 0.2
|
||||
///
|
||||
/// 因此仅当交易期初价已经是小数口径、且当前债券价明显仍处于展示态时,再做
|
||||
/// 一次展示态到存储态转换。期初价本身是历史展示态口径的存量交易保持原价格,
|
||||
/// 避免修改日终估值链路后改变其既有损益。
|
||||
/// </summary>
|
||||
private decimal GetSwapValuationPrice(string code, decimal posiGrossPrice, DateTime settleDate, out decimal vobp)
|
||||
/// <summary>获取用于互换浮动腿盯市的标的价格。</summary>
|
||||
private decimal GetSwapValuationPrice(string code, DateTime settleDate, out decimal vobp)
|
||||
{
|
||||
var price = GetUnderlyingPrice(code, settleDate, out vobp);
|
||||
var underlying = GetUnderlyingData(code);
|
||||
// var usesStoragePrice = Math.Abs(posiGrossPrice) < 2m;
|
||||
// var usesDisplayPrice = Math.Abs(price) >= 10m;
|
||||
|
||||
if (underlying?.IsBond() == true)
|
||||
{
|
||||
var normalizedPrice = BondPriceConverter.ToStorage(price);
|
||||
Log.Error($"互换债券日终价格按展示态返回,已转换为存储态: UnderlyingCode={code}, ValueDate={settleDate:yyyy-MM-dd}, PosiGrossPrice={posiGrossPrice}, SourcePrice={price}, NormalizedPrice={normalizedPrice}");
|
||||
return Math.Round(normalizedPrice, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
return Math.Round(price, ConsGlobal.PriceRound, MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
return Math.Round(price, ConsGlobal.SwapDeliveryPriceRound, MidpointRounding.AwayFromZero);
|
||||
@@ -1575,7 +1563,7 @@ namespace YLErp.Modules.SwapModule
|
||||
int shortRatio = eod.PositionType == (int)PositionTypeFlag.Long ? 1 : -1;
|
||||
int directionRatio = eod.PosiDirection == (int)SwapDirectionEnum.收取 ? 1 : -1;
|
||||
curretEod.PosiStatus = curretEod.PosiQuantity == 0 ? 1 : 0;
|
||||
var price = GetSwapValuationPrice(eod.UnderlyingCode, eod.PosiGrossPrice, dealDate, out decimal vobp);
|
||||
var price = GetSwapValuationPrice(eod.UnderlyingCode, dealDate, out decimal vobp);
|
||||
curretEod.dv01 = Dv01Helper.CalcDv01(eod.UnderlyingCode, curretEod.PosiQuantity, eod.PosiDirection, eod.PositionType, vobp);
|
||||
decimal tax = um.ValueAddedTax ?? 0;
|
||||
if (valueDate > td.StartDate.Value && curretEod.PosiQuantity > 0)
|
||||
@@ -1667,7 +1655,7 @@ namespace YLErp.Modules.SwapModule
|
||||
var dealDate = curretEod.ValueDate;
|
||||
int shortRatio = eod.PositionType == (int)PositionTypeFlag.Long ? 1 : -1;
|
||||
int directionRatio = eod.PosiDirection == (int)SwapDirectionEnum.收取 ? 1 : -1;
|
||||
var price = GetSwapValuationPrice(eod.UnderlyingCode, eod.PosiGrossPrice, dealDate, out decimal vobp);
|
||||
var price = GetSwapValuationPrice(eod.UnderlyingCode, dealDate, out decimal vobp);
|
||||
var todayConsumedDividend = CalcConsumedDividend(curretEod, unwindEvents);
|
||||
var originNotional = (decimal)td.OriginalStockEqvNotional / swapPosition.PosiNetPrice;
|
||||
decimal totalPayment = CalcBondPayment(curretEod.UnderlyingCode, td.StartDate.Value, valueDate, (decimal)originNotional, shortRatio, directionRatio);
|
||||
@@ -1856,7 +1844,7 @@ namespace YLErp.Modules.SwapModule
|
||||
curretEod.ContractSize = position.ContractSize;
|
||||
curretEod.CountRatio = position.CountRatio;
|
||||
curretEod.PosiTradingFee = position.PosiTradingFee;
|
||||
curretEod.UnderlyingPrice = GetSwapValuationPrice(position.UnderlyingCode, position.PosiGrossPrice, dealDate, out decimal vobp);
|
||||
curretEod.UnderlyingPrice = GetSwapValuationPrice(position.UnderlyingCode, dealDate, out decimal vobp);
|
||||
SetPriceInfoByFlowEvent(eod, curretEod, unwindEvents, position);
|
||||
curretEod.dv01 = Dv01Helper.CalcDv01(curretEod.UnderlyingCode, curretEod.PosiQuantity, curretEod.PosiDirection, curretEod.PositionType, vobp);
|
||||
//if (settleDate == td.TradeDate)
|
||||
|
||||
Reference in New Issue
Block a user