OKEx Contract Conversion Guide: How to Convert Between Zhang and Coin Units

·

Understanding Zhang and Coin Calculations on OKEx

OKEx uses two measurement units for contract trading:

This guide explains how to:

Conversion Formulas Explained

Coin to Zhang Conversion

function AmountToZhang(currency, px, sz) {
  let instId = currency.replace("_","-")+"-SWAP";
  let str = "https://www.okx.com/join/BLOCKSTARapi/v5/public/convert-contract-coin?instId="+instId+"&px="+px+"&sz="+sz;
  let ret = JSON.parse(HttpQuery(str));
  return ret.data[0].sz;
}

Zhang to Coin Conversion

function ZhangToAmount(currency, px, sz) {
  let instId = currency.replace("_","-")+"-SWAP";
  let str = "https://www.okx.com/join/BLOCKSTARapi/v5/public/convert-contract-coin?type=2&instId="+instId+"&px="+px+"&sz="+sz;
  let ret = JSON.parse(HttpQuery(str));
  return ret.data[0].sz;
}

Key Factors Affecting Conversion

  1. Contract Multiplier: Varies by trading pair
  2. Current Price: Affects value calculations
  3. Leverage: Modifies position sizing (note API returns base values)

👉 Master OKEx contract trading with our advanced guide

Practical Examples

Trading Pair1 Zhang EqualsConversion Example
BTC-USDT-SWAP0.01 BTC100 Zhang = 1 BTC
ETH-USDT-SWAP0.1 ETH10 Zhang = 1 ETH
BCH-USDT-SWAP10 BCH1 Zhang = 10 BCH

API Implementation Guide

To implement automated conversions:

  1. Format trading pairs correctly (replace "_" with "-")
  2. Include "-SWAP" suffix for swap contracts
  3. Specify conversion type (1 for coin→zhang, 2 for zhang→coin)
// Example implementation
function main() {
  let currency = "ETH_USDT";
  let price = 3500;
  let amount = 1;
  
  let zhang = AmountToZhang(currency, price, amount);
  let coins = ZhangToAmount(currency, price, 1);
  
  Log(`${amount} ${currency} = ${zhang} Zhang`);
  Log(`1 Zhang = ${coins} ${currency}`);
}

Frequently Asked Questions

What determines the Zhang-to-Coin ratio?

The contract multiplier set by OKEx for each trading pair. Different cryptocurrencies have different multipliers based on their volatility and market size.

Why does leverage affect my position size?

While the base conversion remains constant, leverage modifies your effective position size. A 20x leverage position would require 20x less capital for the same contract size.

How often do conversion rates change?

The Zhang-to-Coin ratio remains constant per contract, but the USD value changes with market price fluctuations.

Can I use these conversions for spot trading?

No, Zhang units only apply to derivative contracts (futures and perpetual swaps).

Where can I find official conversion rates?

👉 OKEx's official API documentation provides updated contract specifications for all trading pairs.

Advanced Conversion Considerations

  1. Margin Calculations: Remember to account for leverage in final position sizing
  2. Cross vs Isolated: Margin mode affects how conversions translate to position risk