fix(swap): 修复股票基金类互换合约平仓时公司行为处理逻辑
- 优化 FindFundCorporateActions 方法,明确查询范围为严格大于 eodDate 的开区间,并添加日志记录 - 重命名 TryRestoreEffectiveFundPosition 为 TryRestorePositionFromEod 和 TryRestoreAndValidateUnwindData - 完善 EOD 数据完整性验证,检查持仓数量和价格的有效性 - 添加详细的公司行为查询和应用过程日志记录 - 优化异常信息,包含更多上下文信息如生效日和记录ID - 更新方法调用引用以使用新的方法名称
This commit is contained in:
@@ -497,6 +497,48 @@ namespace YLErp.Modules.SwapModule
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 根据指定日期刷新浮动腿基线(处理公司行为除权)
|
||||
/// 用于前端修改平仓日期后重新获取除权后的持仓数量和价格
|
||||
/// </summary>
|
||||
/// <param name="tradeId">交易ID</param>
|
||||
/// <param name="valueDate">平仓日期</param>
|
||||
/// <returns>返回浮动腿的最新基线数据</returns>
|
||||
public virtual (decimal PositionQty, decimal PosiNotionalValue, decimal PosiGrossPrice, decimal PosiNetPrice, bool IsRestored) RefreshFloatLegBaseline(int tradeId, DateTime valueDate)
|
||||
{
|
||||
var td = DbContext.trade.Find(tradeId);
|
||||
if (td == null)
|
||||
{
|
||||
throw new ServiceException("未找到交易信息");
|
||||
}
|
||||
|
||||
var positions = DbContext.swap_position.ActiveByTrade(tradeId);
|
||||
var position = positions.Where(x => !string.IsNullOrEmpty(x.UnderlyingCode) && !x.IsInitial).FirstOrDefault();
|
||||
|
||||
if (position == null)
|
||||
{
|
||||
// 无浮动腿,返回trade表的原始值
|
||||
return (
|
||||
Convert.ToDecimal(td.TradeAmount),
|
||||
Convert.ToDecimal(td.StockEqvNotional),
|
||||
0m,
|
||||
0m,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
// 尝试恢复除权后的 EOD 基线
|
||||
var restoredCorporateActionBaseline = TryRestorePositionFromEod(position, valueDate);
|
||||
|
||||
return (
|
||||
position.PosiQuantity,
|
||||
position.PosiNotionalValue,
|
||||
position.PosiGrossPrice,
|
||||
position.PosiNetPrice,
|
||||
restoredCorporateActionBaseline
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 平仓初始化
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user