fix: 统一互换部分平仓交易费用与待结算费用的分摊舍入

This commit is contained in:
tengyufan
2026-07-29 13:47:45 +08:00
parent e1d68393f8
commit 8c4f452482
4 changed files with 79 additions and 22 deletions
+10
View File
@@ -112,6 +112,16 @@ describe('base-rate pending trading fee', () => {
expectClose(result, 450.00);
});
test('partial close fee and pending fee both use the rounded opening fee allocation', () => {
const tradingFee = swapPosiFeeCalc.calcAllocatedTradingFee(
113.46, consPosiFeeType.Percent, 1.1234, 4039.2, 4000, 10098, 10000);
const pendingFee = swapPosiFeeCalc.calcTradingFeePending(
113.46, consPosiFeeType.Percent, 1.1234, 4039.2, 4000, 10098, 10000, 0.4);
expectClose(tradingFee, 45.38);
expectClose(pendingFee, 45.38);
});
test('without a configured base rate, the legacy close-percent calculation remains', () => {
const result = swapPosiFeeCalc.calcTradingFeePending(
2000, consPosiFeeType.Percent, 0, 300000, 3000, 1000000, 10000, 0.42);