test(swap): 添加部分平仓利息计算测试用例
- 添加算尾部分平仓当日新计利息包含已平仓部分的测试 - 添加不算尾部分平仓当日新计利息只包含剩余持仓部分的测试 - 验证部分平仓待实现收益计算的正确性
This commit is contained in:
@@ -807,6 +807,50 @@ namespace YLErp.Modules.SwapModule
|
||||
"预付金部分平仓待实现收益应为历史待实现+平仓后当日新增-平仓实现");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DI_MANUAL_PARTIAL_CLOSE_CalcLastIncludesClosedPrincipalDailyInterest()
|
||||
{
|
||||
var service = new StubEodPositionService();
|
||||
var td = CreateTrade();
|
||||
td.trade_extend.ExtendJson = JsonConvert.SerializeObject(new TradeExtendJson
|
||||
{
|
||||
AnnualDays = AnnualDays,
|
||||
InterestCalcMode = "11",
|
||||
SettlementRules = 0
|
||||
});
|
||||
var position = CreateInterestPosition();
|
||||
var previousEod = CreatePreEod(StartDate.AddDays(2), 100m);
|
||||
previousEod.TdInterestPrincipal = Principal;
|
||||
var closeFlow = CreateSwapFlowEvent(StartDate.AddDays(3), 50m);
|
||||
closeFlow.EventType = (int)SwapFlowEventTypeEnum.平仓;
|
||||
|
||||
var result = service.ExecuteSaveAutoEodWithCloseInterestPosition(
|
||||
previousEod, position, td, StartDate.AddDays(3), null,
|
||||
500m, 0m, new List<swap_flow_event> { closeFlow }, 500m, false);
|
||||
|
||||
AssertDecimal(Principal * FixedRate / AnnualDays, result.TdInterestIncome,
|
||||
"算尾部分平仓的当日新计利息应包含已平仓部分");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DI_MANUAL_PARTIAL_CLOSE_NoCalcLastUsesRemainingPrincipalDailyInterest()
|
||||
{
|
||||
var service = new StubEodPositionService();
|
||||
var td = CreateTrade();
|
||||
var position = CreateInterestPosition();
|
||||
var previousEod = CreatePreEod(StartDate.AddDays(2), 100m);
|
||||
previousEod.TdInterestPrincipal = Principal;
|
||||
var closeFlow = CreateSwapFlowEvent(StartDate.AddDays(3), 50m);
|
||||
closeFlow.EventType = (int)SwapFlowEventTypeEnum.平仓;
|
||||
|
||||
var result = service.ExecuteSaveAutoEodWithCloseInterestPosition(
|
||||
previousEod, position, td, StartDate.AddDays(3), null,
|
||||
500m, 0m, new List<swap_flow_event> { closeFlow }, 500m, false);
|
||||
|
||||
AssertDecimal(500m * FixedRate / AnnualDays, result.TdInterestIncome,
|
||||
"不算尾部分平仓的当日新计利息只应包含剩余持仓部分");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DI_AUTO_SETTLEMENT_005_AutoSettlementKeepsRemainingPrincipal()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user