refactor(swap): 合并多空名义本金参数为单一 posiTotalNotional 并加固测试
- DealInterests 的 posiLongNotionalValue + posiShortNotionalValue 合并为 posiTotalNotional(调用点以 posiLongNotional+posiShortNotional 求和传入),净减一个参数 - SwapDealService / SwapEodPositionService / InterestCalcRequest 同步收敛多空死管道参数 - 19 个测试调用点适配新签名 - SwapEodPositionServiceIntegrationTest 参数计数断言由裸数字改为参数名集合断言(CollectionAssert.AreEquivalent,对增删/重排/改名敏感)
This commit is contained in:
@@ -467,16 +467,11 @@ namespace YLErp.Modules.SwapModule
|
||||
// 迭代源仍用 origPositions(保留 orig.id → eod_swap_position.PositionId 的日终匹配),
|
||||
// 仅对预付金腿以实时腿的剩余本金克隆覆盖,故此处不改任何日终匹配行为。
|
||||
var positions = ResolveInterestLegPositions(origPositions, realPostitions);
|
||||
var fpositions = origPositions.Where(x => x.PosiDirection > 0).ToList();
|
||||
var longPositions = fpositions.Where(x => x.PositionType == (int)PositionTypeFlag.Long).ToList();
|
||||
var shortPositions = fpositions.Where(x => x.PositionType == (int)PositionTypeFlag.Short).ToList();
|
||||
var tradeExtend = DbContext.trade_extend.FirstOrDefault(x => x.TradeId == tradeId);
|
||||
List<int> eventTypes = new List<int>() { (int)SwapEventTypeEnum.平仓, (int)SwapEventTypeEnum.互换, (int)SwapEventTypeEnum.自动互换 };
|
||||
var lastEod = DbContext.eod_swap.Where(x => x.ValueDate < unwindDate && x.SwapTradeId == tradeId).OrderByDescending(o => o.ValueDate).FirstOrDefault();
|
||||
var _preSetteDate = lastEod == null ? unwindDate.AddDays(-1) : lastEod.ValueDate;
|
||||
List<eod_swap_position> lastEodPositions = new SwapEodPositionService(this).GetPreEodPositions(tradeId, _preSetteDate);//上一交易数据
|
||||
var posiLongNotionalValue = longPositions.Sum(s => s.PosiNotionalValue);// 剩余名义本金
|
||||
var posiShortNotionalValue = shortPositions.Sum(s => s.PosiNotionalValue);// 剩余名义本金
|
||||
var stockEqvNotional = realPostitions.Where(x => x.PosiDirection > 0).Sum(s => s.PosiNotionalValue); // 当前平仓前的实时剩余本金
|
||||
var posiNotionalValue = stockEqvNotional * closePercent;// 本次平仓名义本金
|
||||
var orginPv = ResolveUnwindPreviousNotional(lastEod, lastEodPositions, stockEqvNotional); // 上一日终的浮动端本金
|
||||
@@ -489,7 +484,7 @@ namespace YLErp.Modules.SwapModule
|
||||
// 显式入口:平仓前剩余本金 + 实际平掉额 + B语义比例,盘中重放(语义见 InterestCalcRequest.IntradayUnwind)
|
||||
interests = GetIntradayUnwindInterests(InterestCalcRequest.IntradayUnwind(
|
||||
td, tradeExtend, valueDate, unwindDate, lastEodPositions, positions,
|
||||
stockEqvNotional, posiLongNotionalValue, posiShortNotionalValue, posiNotionalValue,
|
||||
stockEqvNotional, posiNotionalValue,
|
||||
closePercent, eventType, tdClose, orginPv, add: true, newCalcLast: false, closeList));
|
||||
return interests;
|
||||
}
|
||||
@@ -626,7 +621,7 @@ namespace YLErp.Modules.SwapModule
|
||||
/// </summary>
|
||||
public List<swap_flow_event> GetIntradayUnwindInterests(InterestCalcRequest req)
|
||||
=> GetInterests(req.Td, req.TradeExtend, req.ValueDate, req.UnwindDate, req.EodPositions, req.Positions,
|
||||
req.PosiNotionalValue, req.PosiLongNotionalValue, req.PosiShortNotionalValue, req.ClosePosiNotionalValue,
|
||||
req.PosiNotionalValue, req.ClosePosiNotionalValue,
|
||||
req.ClosePercent, req.EventType, req.TdClose,
|
||||
req.OrginPv, req.Add, settment: false, req.NewCalcLast, req.CloseList);
|
||||
|
||||
@@ -638,8 +633,6 @@ namespace YLErp.Modules.SwapModule
|
||||
List<eod_swap_position> eodPositions,
|
||||
List<swap_position> positions,
|
||||
decimal posiNotionalValue,
|
||||
decimal posiLongNotionalValue,
|
||||
decimal posiShortNotionalValue,
|
||||
decimal closePosiNotionalValue,
|
||||
decimal closePrecent,
|
||||
int eventType,
|
||||
|
||||
Reference in New Issue
Block a user