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
Function name:
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
Function name:
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
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
Function name:
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
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
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
Function name:
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)
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)
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
Function name:
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"
})