Trading Data

Documentation on interacting with a variety of OKX's Trading Data API functions through the PENDAX JavaScript SDK.

The API endpoints of Trading Data do not require authentication.

Trading Data

Get Support Coin

Please refer to the official OKX API Docs for the required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-support-coin

Function name:

getSupportCoin()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: "true",
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getSupportCoin(exchange) {
    try {
        let result = await exchange.getSupportCoin();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSupportCoin(myOkxAccount)

Get Taker Volume

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-taker-volume

Function name:

getTakerVolume()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTakerVolume(exchange) {
    try {
        let result = await exchange.getTakerVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTakerVolume(myOkxAccount, 
{
    ccy: "BTC",
    instType: "SPOT"
})

Get Margin Lending Ratio

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-margin-lending-ratio

Function name:

getMarginLendingRatio()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getMarginLendingRatio(exchange) {
    try {
        let result = await exchange.getMarginLendingRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMarginLendingRatio(myOkxAccount, 
{
        ccy: "BTC"
})

Get Long/Short Ratio

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-long-short-ratio

Function name:

getLongShortRatio()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getLongShortRatio(exchange) {
    try {
        let result = await exchange.getLongShortRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLongShortRatio(myOkxAccount, 
{
    ccy: "BTC"
})

Get Contracts Open Interest and Volume

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-contracts-open-interest-and-volume

Function name:

getContractsOiAndVolume()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getContractsOiAndVolume(exchange) {
    try {
        let result = await exchange.getContractsOiAndVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getContractsOiAndVolume(myOkxAccount, 
{
    ccy: "BTC"
})

Get Options Open Interest and Volume

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-options-open-interest-and-volume

Function name:

getOptionsOiAndVolume()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOptionsOiAndVolume(exchange) {
    try {
        let result = await exchange.getOptionsOiAndVolume();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOptionsOiAndVolume(myOkxAccount, 
{
    ccy: "BTC"
})

Get Put/Call Ratio

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-put-call-ratio

Function name:

getPutCallRatio()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getPutCallRatio(exchange) {
    try {
        let result = await exchange.getPutCallRatio();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPutCallRatio(myOkxAccount, 
{
    ccy: "BTC"
})

Get Open Interest and Volume (expiry)

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-open-interest-and-volume-expiry

Function name:

getOiAndVolumeExpiry()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOiAndVolumeExpiry(exchange) {
    try {
        let result = await exchange.getOiAndVolumeExpiry();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOiAndVolumeExpiry(myOkxAccount, 
{
    ccy: "BTC"
})

Get Open Interest and Volume (strike)

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-open-interest-and-volume-strike

Function name:

getOiAndVolumeStrike()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getOiAndVolumeStrike(exchange) {
    try {
        let result = await exchange.getOiAndVolumeStrikegetOiAndVolumeStrike();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getOiAndVolumeStrike(myOkxAccount, 
{
    ccy: "BTC",
    expTime: "<get example>"
})

Get Taker Flow

Please refer to the official OKX API Docs for required parameters.

https://www.okx.com/docs-v5/en/#rest-api-trading-data-get-taker-flow

Function name:

getTakerFlow()

Usage:

import { createExchange } from "./exchanges/exchange.js";

  let myOkxAccount = createExchange({
      exchange: "okx",
      authenticate: true,
      key: "myKeys",
      secret: "mySecret",
      passphrase: "myPassphrase",
      label: "okx",
      marginType: "usdt"
});

async function getTakerFlow(exchange) {
    try {
        let result = await exchange.getTakerFlow();
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getTakerFlow(myOkxAccount, 
{
    ccy: "BTC"
})

Last updated