fix: 修复基础费率平仓待结算费用按实际平仓规模分摊

This commit is contained in:
tengyufan
2026-07-29 13:07:55 +08:00
parent 422507df8d
commit e1d68393f8
4 changed files with 123 additions and 2 deletions
+28
View File
@@ -90,3 +90,31 @@ describe('unwindSwapTrade 基础费率计算', () => {
expectClose(result, 200.00);
});
});
describe('base-rate pending trading fee', () => {
const { swapPosiFeeCalc, consPosiFeeType } = loadUnwindHelpers();
test('unit rate follows actual close quantity instead of an inconsistent close percent', () => {
const result = swapPosiFeeCalc.calcTradingFeePending(
2000, consPosiFeeType.Unit, 0.2, 4200, 3000, 10000, 10000, 0.42);
expectClose(result, 600.00);
});
test('percentage rate follows actual close notional value', () => {
const result = swapPosiFeeCalc.calcTradingFeePending(
2000, consPosiFeeType.Percent, 0.2, 300000, 4200, 1000000, 10000, 0.42);
expectClose(result, 600.00);
});
test('a manually adjusted original pending fee is allocated by actual close quantity', () => {
const result = swapPosiFeeCalc.calcTradingFeePending(
1500, consPosiFeeType.Unit, 0.2, 4200, 3000, 10000, 10000, 0.42);
expectClose(result, 450.00);
});
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);
expectClose(result, 840.00);
});
});