test(swap): 添加部分平仓利息计算测试用例

- 添加算尾部分平仓当日新计利息包含已平仓部分的测试
- 添加不算尾部分平仓当日新计利息只包含剩余持仓部分的测试
- 验证部分平仓待实现收益计算的正确性
This commit is contained in:
张名锐
2026-08-07 15:05:04 +08:00
parent 3a435ad89b
commit 6d6729cf9c
2 changed files with 49 additions and 2 deletions
@@ -1343,7 +1343,8 @@ namespace YLErp.Modules.SwapModule
positions.Add(position);
List<eod_swap_position> preEodPositions = new List<eod_swap_position>();
preEodPositions.Add(eodPayPosition);
var interests = CalcSwapInterests(td, td.trade_extend, valueDate, valueDate, preEodPositions, positions, posiNotionalValue, posiLongNotional, posiShortNational, closeNational, 1, eventType, false, true, grossPrice, orginPv, true, settment: false, newCalcLast: true);
var calcLast = tradeExtend?.InterestCalcMode?.EndsWith("1") ?? true;
var interests = CalcSwapInterests(td, td.trade_extend, valueDate, valueDate, preEodPositions, positions, posiNotionalValue, posiLongNotional, posiShortNational, closeNational, 1, eventType, false, true, grossPrice, orginPv, true, settment: false, newCalcLast: autoSwap || calcLast);
decimal TdInterestAmount = interests.Sum(x => x.TdInterestAmount);
decimal interestAmountBeforeSettlement = interests.Sum(x => x.InterestAmount);
decimal manualSettledInterestAmount = flowEvents.Sum(x => x.InterestAmount);
@@ -1399,7 +1400,9 @@ namespace YLErp.Modules.SwapModule
{
intersetAcmount /= tradeExtend.AnnualDays;
}
newEodPayPosition.TdInterestIncome = intersetAcmount;
newEodPayPosition.TdInterestIncome = !autoSwap && calcLast
? TdInterestAmount - lastInterestIncomeSum
: intersetAcmount;
Log.Info($"InterestIncomeSum is {lastInterestIncomeSum},TdInterestIncome is {newEodPayPosition.TdInterestIncome}" +
$",TdCloseInterest is {newEodPayPosition.TdCloseInterest}");
Log.Info($"InterestFeeSum is {eodPayPosition.InterestFeeSum},TdInterestFee is {newEodPayPosition.TdInterestFee}" +