Merge remote-tracking branch 'origin/glms/feature/1.4.2' into glms/feature/1.4.2
This commit is contained in:
@@ -170,6 +170,18 @@ describe('多次部分平仓:全部↔部分切换 CloseQty 不跳变(占期
|
||||
test('除零保护:PositionQty=0 → ClosePercent=0', () => {
|
||||
expect(SwapCalc.calcOriginalClosePercentByQty(100, 0, oriClosePercent)).toBe(0);
|
||||
});
|
||||
|
||||
// GLMS-20260701-0006 生产 bug:第二次部分平仓 50%(占期初) 时
|
||||
// 32500000 * (0.5 / 0.65) = 24999999.999999996(JS 浮点精度偏差)
|
||||
// roundHalfAwayFromZero 应正确舍入为 25000000
|
||||
test('GLMS-20260701-0006:32500000×(0.5/0.65) 应=25000000 而非 24999999.999999996', () => {
|
||||
const closePercent = 0.5; // 占期初 50%
|
||||
const oriClosePercent = 0.65; // 剩余/期初 = 32500000/50000000
|
||||
const positionQty = 32500000; // 剩余持仓
|
||||
const closeQty = SwapCalc.calcCloseQtyByOriginalPercent(closePercent, oriClosePercent, positionQty);
|
||||
expectClose(closeQty, 25000000, '应=25000000 不受 JS 浮点偏差影响');
|
||||
expect(closeQty).not.toBe(24999999.999999996);
|
||||
});
|
||||
});
|
||||
|
||||
describe('交叉校验:对齐 C# FrontendCalcCharacterizationTest 金标准', () => {
|
||||
|
||||
Reference in New Issue
Block a user