← All articles

Gate futures order size in Node.js: contracts, quanto_multiplier and limits

Gate futures order size: quanto_multiplier values across 1,042 USDT-settled contracts

Gate futures order size is counted in contracts, not in coins. On BTC_USDT one contract is 0.0001 BTC, so 0.05 BTC is 500 contracts, and a bot that sends size: 0.05 or rounds it up to 1 is asking for something very different from what it meant. Each contract has its own quanto_multiplier, its own size limits and its own price band, and they vary a lot across Gate’s 1,042 USDT-settled perpetuals.

Read each contract with gateio-api 1.6.9 before converting a coin quantity into contracts. Use that contract’s multiplier, size limits and price band.

Gate futures order size: quanto_multiplier values across 1,042 USDT-settled contracts

Read the Gate futures order size rules for a contract

getFuturesContract() is public, so no API key is needed. The fields that matter for sizing are quanto_multiplier (base asset per contract), order_size_min, order_size_max, market_order_size_max, order_price_round and order_price_deviate.

import { RestClient } from 'gateio-api';

const client = new RestClient();

export async function readRules(contract: string) {
  const c = await client.getFuturesContract({ settle: 'usdt', contract });
  return {
    multiplier: Number(c.quanto_multiplier), // base asset per contract
    minSize: Number(c.order_size_min),
    maxSize: Number(c.order_size_max),
    marketMaxSize: Number(c.market_order_size_max ?? 0),
    decimalSizes: c.enable_decimal === true,
    priceStep: c.order_price_round ?? '1',
    maxDeviation: Number(c.order_price_deviate),
    markPrice: Number(c.mark_price),
  };
}

What came back:

Contract quanto_multiplier order_size_min order_size_max market_order_size_max order_price_round order_price_deviate
BTC_USDT 0.0001 1 12000000 10000000 0.1 0.03
ETH_USDT 0.01 0 10000000 8000000 0.01 0.03
SOL_USDT 1 0 300000 200000 0.01 0.03
DOGE_USDT 10 1 12000000 8000000 0.00001 0.2
PEPE_USDT 10000000 0 120000 75000 0.000000001 0.05

Across all 1,042 USDT-settled contracts the multiplier ranged from 0.0001 to 10,000,000. Never hard-code it: read it per contract and cache it for a few minutes.

Why order_size_min shows 0 on some contracts

Without X-Gate-Size-Decimal: 1, Gate returns integer sizes and truncates fractional minimums to zero. For example, the decimal minimum for ETH_USDT was 0.1. Request decimal sizes when validating fractional orders. For the whole-contract orders below, the smallest positive quantity is one contract.

Convert a coin amount into a Gate futures order size

export function contractsFromBase(baseAmount: number, multiplier: number): number {
  // Small epsilon so 0.05 / 0.0001 doesn't become 499.99999
  return Math.floor(baseAmount / multiplier + 1e-9);
}

export function baseFromContracts(contracts: number, multiplier: number): number {
  return contracts * multiplier;
}

On BTC_USDT, 0.05 BTC became 500 contracts and converted back to 0.05. A 0.00005 BTC request became 0 contracts, which is exactly the case to stop before sending. Round down, not up, so a size never grows beyond what you meant.

Check the size and price before submitFuturesOrder

type Rules = Awaited<ReturnType<typeof readRules>>;

export function checkSize(contracts: number, rules: Rules, isMarket: boolean): string | null {
  const abs = Math.abs(contracts);
  const min = rules.minSize >= 1 ? rules.minSize : 1; // 0 means "below 1" in the integer view
  if (!Number.isInteger(abs)) return 'size must be a whole number of contracts';
  if (abs < min) return `size ${abs} is below the minimum of ${min} contract(s)`;
  if (abs > rules.maxSize) return `size ${abs} is above order_size_max ${rules.maxSize}`;
  if (isMarket && rules.marketMaxSize > 0 && abs > rules.marketMaxSize) {
    return `market size ${abs} is above market_order_size_max ${rules.marketMaxSize}`;
  }
  return null;
}

export function roundToStep(price: number, step: string): string {
  const decimals = step.includes('.') ? step.split('.')[1].length : 0;
  const s = Number(step);
  return (Math.round(price / s) * s).toFixed(decimals);
}

export function insideBand(price: number, rules: Rules): boolean {
  return Math.abs(price - rules.markPrice) <= rules.markPrice * rules.maxDeviation;
}

The band check follows Gate’s documented rule, abs(order_price - mark_price) <= mark_price * order_price_deviate. With BTC_USDT marked at 59,899.3 and a deviation of 0.03, limit prices between about 58,102 and 61,696 passed and a price 5% below mark did not. Note that market orders have their own, lower ceiling: market_order_size_max was 10,000,000 contracts on BTC_USDT against 12,000,000 for limit orders.

Send the order with a signed size

Gate has no side field on futures orders. A positive size buys and a negative size sells.

import type { SubmitFuturesOrderReq } from 'gateio-api';

export async function placeLimit(baseAmount: number, side: 'buy' | 'sell', limitPrice: number) {
  const privateClient = new RestClient({
    apiKey: process.env.GATE_API_KEY!,
    apiSecret: process.env.GATE_API_SECRET!,
  });
  const rules = await readRules('BTC_USDT');
  const contracts = contractsFromBase(baseAmount, rules.multiplier);
  const problem = checkSize(contracts, rules, false);
  if (problem) throw new Error(problem);
  const price = roundToStep(limitPrice, rules.priceStep);
  if (!insideBand(Number(price), rules)) throw new Error(`price ${price} is outside the mark-price band`);

  const order: SubmitFuturesOrderReq = {
    settle: 'usdt',
    contract: 'BTC_USDT',
    size: side === 'buy' ? contracts : -contracts, // negative size = sell
    price,
    tif: 'gtc',
  };
  return privateClient.submitFuturesOrder(order);
}

To close a whole position, send size: 0 with close: true. Gate treats price: '0' with tif: 'ioc' as a market order:

export async function closePosition() {
  const privateClient = new RestClient({
    apiKey: process.env.GATE_API_KEY!,
    apiSecret: process.env.GATE_API_SECRET!,
  });
  return privateClient.submitFuturesOrder({
    settle: 'usdt',
    contract: 'BTC_USDT',
    size: 0,
    close: true,
    price: '0',
    tif: 'ioc',
  });
}

Use an API key with trade permission only, no withdrawal permission, and an IP whitelist. Our API key security guide covers the rest.

Zero-size levels in the order book

The same integer view affects market data. In five ETH_USDT snapshots of the top 20 levels taken a second or two apart, between 2 and 8 levels per side showed s: 0: real resting orders smaller than one contract, rounded down to zero. If a bot reads the first level as the best price, it can quote against an amount it can’t trade. Filter them out:

export async function bestLevels(contract: string) {
  const book = await client.getFuturesOrderBook({ settle: 'usdt', contract, limit: 20 });
  const bids = book.bids.filter((l) => Number(l.s) > 0);
  const asks = book.asks.filter((l) => Number(l.s) > 0);
  return { bestBid: bids[0], bestAsk: asks[0] };
}

If you hit a pair-format error before you reach sizing, see Gate API INVALID_CURRENCY_PAIR in Node.js.

Tutorial: Gate API JavaScript tutorial for Node.js and TypeScript
Docs: Gate.io API SDK docs for Node.js, JavaScript and TypeScript