Skip to content

feat: opt-in X-Gate-Size-Decimal for futures and delivery (v1.7.0) - #3

Closed
JJ-Cro wants to merge 2 commits into
masterfrom
update08102026
Closed

JJ-Cro wants to merge 2 commits into
masterfrom
update08102026

Conversation

@JJ-Cro

@JJ-Cro JJ-Cro commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Summary

Gate requires X-Gate-Size-Decimal: 1 on REST and WebSocket futures traffic so size-related fields are returned as decimal strings instead of integers (rounded down). This PR adds an opt-in client flag and widens the affected TypeScript types.

Version: 1.7.0 (minor bump from 1.6.4). The draft update07102026 branch also targets a minor bump; align versions before release if both land.

Changelog

  • Add futuresSizeDecimal?: boolean to RestClientOptions and WSClientConfigurableOptions (default false).
  • When enabled, send X-Gate-Size-Decimal: 1 on:
    • REST requests whose path starts with /futures/ or /delivery/ (all futures/delivery REST methods in this SDK use those prefixes, including autoorder under /futures/.../autoorder/...).
    • WebSocket HTTP upgrade for perpFuturesUSDTV4, perpFuturesBTCV4, deliveryFuturesUSDTV4, and deliveryFuturesBTCV4.
    • Futures WebSocket API req_header on those connections (login, order place/amend, etc.).
  • Introduce FuturesContractSize (number | string) and apply it to futures/delivery size-related request and response fields (and futures WS API order types), with JSDoc noting string values when futuresSizeDecimal is on.
  • Unit tests in test/lib/futuresSizeDecimal.test.ts for header scoping and REST behavior.

Type fields updated

FuturesContractSize on:

Futures response: FuturesOrderBook (asks/bids.s), FuturesTrade.size, FuturesCandle.v, FuturesStats (long_liq_size, short_liq_size, open_interest, top_lsr_size, top_long_size, top_short_size, long_taker_size, short_taker_size), LiquidationHistoryRecord (size, order_size, left), FuturesOrder (size, iceberg, left), FuturesPosition.size, FuturesTradingHistoryRecord (size, close_size), FuturesLiquidationHistoryRecord (size, left), FuturesAutoDeleveragingHistoryRecord (trade_size, position_size), FuturesContract / FuturesDeliveryContract (order_size_min, order_size_max, trade_size, position_size), FuturesPriceTriggeredOrder.initial.size, BatchAmendOrderResp (size, iceberg, left).

Futures request: SubmitFuturesOrderReq (size, iceberg), UpdateFuturesOrderReq.size, SubmitFuturesTriggeredOrderReq.initial.size, BatchAmendOrderReq.size, UpdateFuturesPriceTriggeredOrderReq.size.

Delivery response: DeliveryOrderBook (asks/bids.s), DeliveryTrade.size, DeliveryCandle.v, DeliveryTradingHistoryRecord.size, DeliveryLiquidationHistoryRecord (size, left), DeliverySettlementHistoryRecord.size.

Delivery request: SubmitDeliveryFuturesOrderReq (size, iceberg).

Futures WS API: WSAPIFuturesOrderPlaceReq (size, iceberg), WSAPIFuturesOrderAmendReq.size, WSAPIFuturesOrder (size, left, iceberg).

Testing

  • npm run lint — pass
  • npm run build — pass
  • npm test — test/lib/futuresSizeDecimal.test.ts, test/REST/public.test.ts, test/websockets/wsStore.test.ts pass; test/REST/private.test.ts fails without API credentials (7 tests, expected in CI without secrets)

References

Open in Web Open in Cursor 

cursoragent and others added 2 commits October 8, 2026 07:28
- Add futuresSizeDecimal client option (REST and WebSocket, default off)
- Send X-Gate-Size-Decimal: 1 on /futures/* and /delivery/* REST calls when enabled
- Send the same header on perp/delivery WS connections and futures WS API req_header
- Widen futures/delivery size-related types to number | string (FuturesContractSize)
- Bump version to 1.7.0

Co-authored-by: Jerko J <JJ-Cro@users.noreply.github.com>
@JJ-Cro JJ-Cro closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants