fix(swap): 修复浮动端已实现盈亏计算逻辑
- 添加了SetFloatingRealizedPnl方法统一计算已实现盈亏 - 已实现盈亏现在正确包含盯市、分红和费用三个组成部分 - 修复了多处RealizedPnl计算错误,确保数值准确性 - 为DF_008测试场景添加了专门的单元测试验证 - 移除了重复的盈亏计算代码,提高代码可维护性
This commit is contained in:
@@ -378,6 +378,39 @@ namespace YLErp.Modules.SwapModule
|
||||
Console.WriteLine($"分红增值税调整: 付息100, 税率6% → TdPosiDividend={result.TdPosiDividend}(期望{expected})✅");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void DF_008_CopyBranch_RealizedPnlIncludesRealizedFee()
|
||||
{
|
||||
var service = new StubEodService
|
||||
{
|
||||
UnderlyingPrice = 1.002m,
|
||||
TaxRate = 0m,
|
||||
BondPayment = 0m
|
||||
};
|
||||
var preEod = new eod_swap_position
|
||||
{
|
||||
id = 5001,
|
||||
SwapTradeId = SwapTradeId,
|
||||
PositionId = 3001,
|
||||
ValueDate = PreSettleDate,
|
||||
PosiQuantity = 10000m,
|
||||
PosiGrossPrice = 1.002m,
|
||||
PosiNetPrice = 1.005m,
|
||||
UnderlyingCode = "210210.IB",
|
||||
ContractSize = 1m,
|
||||
PositionType = (int)PositionTypeFlag.Long,
|
||||
PosiDirection = (int)SwapDirectionEnum.收取,
|
||||
RealizedMtmPnL = 98000000m,
|
||||
RealizedDividend = 0m,
|
||||
RealizedFee = 100m,
|
||||
RealizedPnl = 98000000m
|
||||
};
|
||||
|
||||
var result = service.ExecuteCopyEodPosition(preEod, null, CreateTrade(), TradeDate, PreSettleDate);
|
||||
|
||||
Assert.AreEqual(98000100m, result.RealizedPnl);
|
||||
}
|
||||
|
||||
private static void AssertDecimalEqual(decimal expected, decimal actual, decimal tolerance, string message = "")
|
||||
{
|
||||
Assert.IsTrue(Math.Abs(expected - actual) <= tolerance,
|
||||
|
||||
Reference in New Issue
Block a user