Compendium Trading Tools Documentation
CompendiumPENDAXCompendexOfficial Links
  • ⭐Platform Overview
  • ⚫PENDAX
    • 🌐What is PENDAX?
    • 🖱️PENDAX Capabilities
    • 💾Installing PENDAX modules
    • 💡Using PENDAX SDK
      • 💻Common Functions
      • 💻OKX Functions
        • Trading & Orders
        • Funding
        • Convert
        • Account & Subaccount
        • Grid Trading
        • Market Data
        • Public Data
        • Trading Data
      • 💻Bitget Functions
        • Public (Spot)
        • Market (Spot)
        • Wallet (Spot)
        • Account (Spot)
        • Trade (Spot)
        • Market (Futures)
        • Account (Futures)
        • Trade (Futures)
        • CopyTrade (Futures)
        • Sub Account Interface (Broker)
        • Sub API Interface (Broker)
      • 💻ByBit Functions
        • Market
        • Trading
        • Position
        • Account
        • Asset
        • User
        • Spot Leverage Token
        • Spot Margin Trade (UTA)
        • Spot Margin Trade (Normal)
        • Institutional Lending
      • 💻Mexc Functions
        • Market
        • Sub-Account
        • Spot Account/Trade
        • Wallet
        • ETF
        • Rebate
        • Futures Market
        • Futures Account and Trading
      • 💻Phemex Functions
        • Contract
        • Hedged Contract
        • Spot
        • Margin Trading
        • Transfer
        • Convert
        • Deposit And Withdraw
      • 💻BloFin Functions
        • Websocket
        • Account
        • Affiliate
        • Public Data
        • Trading
        • User
      • 💻BingX Functions
        • Fund Account
        • Wallet Deposits and Withdrawals
        • Sub-Account Managenent
        • Market Data (USDT-M)
        • Account (USDT-M)
        • Trades (USDT-M)
        • Market Data (Coin-M)
        • Trades (Coin-M)
        • Market Data (Spot)
        • Fund Account (Spot)
        • Trades (Spot)
        • CopyTrader
      • ⚠️FTX Functions
    • 📜License Agreement
  • 🟣Compendium App
    • 📈Compendium Trading Tools
    • 🔗Connect An Exchange Account
      • 🗝️OKX.com API Keys
    • 🤖Verified Trading Bots
      • Explore The Marketplace
      • For Algo & Strategy Authors
        • Get Listed & Verified
        • Strategy Monetization
        • Sending Trading Signals
        • Simplified Signal Program
      • For Users & Subscribers
        • Subscribing To Bots
        • Managing A Subscription
    • 💫Copy Trading Groups
      • For Copy Group Leaders
        • Creating A Copy Group
        • Linking Leader Account
        • Important Trading Notes
        • Manage A Copy Group
        • Discord Webhooks Setup
      • For Users & Subscribers
        • Subscribe To Copy Group
        • Link Account To Group
    • 📶Signal Provider Groups
      • For Group Leaders
        • Creating A Signal Group
        • Managing A Signal Group
        • Sending Trading Signals
      • For Users & Subscribers
        • Subscribing To Signal Groups
        • Manage Signal Group Subscription
  • 🔵Compendex Suite
    • 🔮DeFi With Compendex
    • ☀️Solana Integrations
      • Supported Solana Wallets
      • Overview And News
      • Openbook Spot Markets
      • Smart Swap Aggregator
      • NFT Metaverse Markets
      • Solana DeFi Analytics Portal
      • Community Tools List
  • 🪙The CMFI Token Ecosystem
    • 📊Tokenomics Breakdown
    • 🍎Trade Incentive Program
    • 🌊Staking And Liquidity Pools
      • ✨Raydium Liquidity Pools
      • 🐳Orca Liquidity Whirlpools
      • 🐋Orca Liquidity Pools
    • 🐷Compendi-Pigs NFT
  • 👥Community Info
    • ✅Links And Social Pages
    • 🎨Branding Guidelines
Powered by GitBook
On this page
  • Account
  • Get Balance
  • Get Positions
  • Get Positions History
  • Get Account and Position Risk
  • Get Bills Details (last 7 days)
  • Get Bills Details (last 3 months)
  • Get Account Configuration
  • Set Position Mode
  • Set Leverage
  • Get Maximum Buy/Sell Amount or Open Amount
  • Get Maximum Available Tradable Amount
  • Increase/Decrease Margin
  • Get Leverage
  • Get The Maximum Loan Of Instrument
  • Get Fee Rates
  • Get Interest Accrued Data
  • Get Interest Rate
  • Set Greeks
  • Isolated Margin Trading Settings
  • Get Maximum Withdrawals
  • Get Account Risk State
  • VIP Loans Borrow and Repay
  • Get Borrow and Repay History for VIP Loans
  • Get Borrow Interest and Limit
  • Position Builder
  • Get Greeks
  • Subaccount
  • View Subaccount List
  • Get Subaccount Trading Balance
  • Get Subaccount Funding Balance
  • History of Subaccount Transfer
  • Master Accounts Manage the Transfers Between Subaccounts
  • Set Permission of Transfer Out
  • Get Custody Trading Subaccount List
  1. PENDAX
  2. Using PENDAX SDK
  3. OKX Functions

Account & Subaccount

Documentation on interacting with a variety of OKX account and subaccount API endpoint functions through the PENDAX Javascript SDK.

PreviousConvertNextGrid Trading

Last updated 1 year ago

All Account and Subaccount API endpoints require authentication. Please create OKX API keys to interact with these functions successfully.

Account

Get Balance

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

Function Name:

getBalances()

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 getBalances(exchange, options) {
    try {
        let result = await exchange.getBalances(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBalances(myOkxAccount)

Get Positions

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

Function Name:

getPositions()

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 getPositions(exchange, options) {
    try {
        let result = await exchange.getPositions(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPositions(myOkxAccount)

Get Positions History

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

Function Name:

getPositionsHistory()

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 getPositionsHistory(exchange, options) {
    try {
        let result = await exchange.getPositionsHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getPositionsHistory(myOkxAccount)

Get Account and Position Risk

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

Function Name:

getAccountPosAndRisk()

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 getAccountPosAndRisk(exchange, options) {
    try {
        let result = await exchange.getAccountPosAndRisk(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountPosAndRisk(myOkxAccount)

Get Bills Details (last 7 days)

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

Function Name:

getBills()

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 getBills(exchange, options) {
    try {
        let result = await exchange.getBills(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBills(myOkxAccount)

Get Bills Details (last 3 months)

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

Function Name:

getBillsArchive()

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 getBillsArchive(exchange, options) {
    try {
        let result = await exchange.getBillsArchive(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBillsArchive(myOkxAccount)

Get Account Configuration

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

Function Name:

getAccountConfig()

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 getAccountConfig(exchange, options) {
    try {
        let result = await exchange.getAccountConfig(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getAccountConfig(myOkxAccount)

Set Position Mode

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

Function Name:

setPosMode()

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 setPosMode(exchange, options) {
    try {
        let result = await exchange.setPosMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setPosMode(myOkxAccount,
{
    posMode:"long_short_mode"
}
)

Set Leverage

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

Function Name:

setLeverage()

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 setLeverage(exchange, options) {
    try {
        let result = await exchange.setLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setLeverage(myOkxAccount,
{
    instId:"BTC-USDT",
    lever:"5",
    mgnMode:"isolated"
}
)

Get Maximum Buy/Sell Amount or Open Amount

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

Function Name:

getMaxSize()

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 getMaxSize(exchange, options) {
    try {
        let result = await exchange.getMaxSize(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxSize(myOkxAccount,
{
    instId:"BTC-USDT",
    tdMode:"isolated"
}
)

Get Maximum Available Tradable Amount

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

Function Name:

getMaxAvailSize()

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 getMaxAvailSize(exchange, options) {
    try {
        let result = await exchange.getMaxAvailSize(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxAvailSize(myOkxAccount,
{
    instId:"BTC-USDT",
    tdMode:"isolated"
}
)

Increase/Decrease Margin

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

Function Name:

adjustMargin()

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 adjustMargin(exchange, options) {
    try {
        let result = await exchange.adjustMargin(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await adjustMargin(myOkxAccount,
{
    instId:"BTC-USDT-200626",
    posSide:"short",
    type:"add",
    amt:"1"
}
)

Get Leverage

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

Function Name:

getLeverage()

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 getLeverage(exchange, options) {
    try {
        let result = await exchange.getLeverage(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getLeverage(myOkxAccount,
{
    instId:"BTC-USDT-200626",
    mgnMode: "cross"
}
)

Get The Maximum Loan Of Instrument

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

Function Name:

getMaxLoan()

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 getMaxLoan(exchange, options) {
    try {
        let result = await exchange.getMaxLoan(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxLoan(myOkxAccount,
{
    instId:["BTC-USDT-200626"],
    mgnMode: "cross"
}
)

Get Fee Rates

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

Function Name:

getFeeRates()

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 getFeeRates(exchange, options) {
    try {
        let result = await exchange.getFeeRates(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getFeeRates(myOkxAccount,
{
    instType: "SPOT",
    instID: "BTC-USDT"
}
)

Get Interest Accrued Data

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

Function Name:

getFeeRates()

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 getInterestAccrued(exchange, options) {
    try {
        let result = await exchange.getInterestAccrued(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInterestAccrued(myOkxAccount)

Get Interest Rate

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

Function Name:

getInterestRate()

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 getInterestRate(exchange, options) {
    try {
        let result = await exchange.getInterestRate(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getInterestRate(myOkxAccount)

Set Greeks

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

Function Name:

setGreeks()

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 setGreeks(exchange, options) {
    try {
        let result = await exchange.setGreeks(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setGreeks(myOkxAccount, {
    greeksType:"PA"
})

Isolated Margin Trading Settings

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

Function Name:

setIsolatedMode()

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 setIsolatedMode(exchange, options) {
    try {
        let result = await exchange.setIsolatedMode(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await setIsolatedMode(myOkxAccount, {
    isoMode:"automatic",
    type:"MARGIN"
})

Get Maximum Withdrawals

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

Function Name:

getMaxWithdrawal()

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 getMaxWithdrawal(exchange, options) {
    try {
        let result = await exchange.getMaxWithdrawal(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getMaxWithdrawal(myOkxAccount)

Get Account Risk State

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

Function Name:

getRiskState()

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 getRiskState(exchange, options) {
    try {
        let result = await exchange.getRiskState(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getRiskState(myOkxAccount)

VIP Loans Borrow and Repay

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

Function Name:

vipLoanBorrowRepay()

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 vipLoanBorrowRepay(exchange, options) {
    try {
        let result = await exchange.vipLoanBorrowRepay(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await vipLoanBorrowRepay(myOkxAccount, {
    ccy:"USDT",
    side:"borrow",
    amt:"100"
})

Get Borrow and Repay History for VIP Loans

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

Function Name:

getVipLoanHistory()

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 getVipLoanHistory(exchange, options) {
    try {
        let result = await exchange.getVipLoanHistory(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getVipLoanHistory(myOkxAccount)

Get Borrow Interest and Limit

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

Function Name:

getBorrowInterestAndLimit()

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 getBorrowInterestAndLimit(exchange, options) {
    try {
        let result = await exchange.getBorrowInterestAndLimit(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getBorrowInterestAndLimit(myOkxAccount)

Position Builder

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

Function Name:

positionBuilder()

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 positionBuilder(exchange, options) {
    try {
        let result = await exchange.positionBuilder(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await positionBuilder(myOkxAccount,
{
   instType:"SWAP",
   inclRealPos:"true",
   simPos:[
     {
          pos:"10",
          instId:"BTC-USDT-SWAP"
     },
     {
          pos:"10",
          instId:"LTC-USDT-SWAP"
     }
   ]
})

Get Greeks

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

Function Name:

getGreeks()

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 getGreeks(exchange, options) {
    try {
        let result = await exchange.getGreeks(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getGreeks(myOkxAccount)

Subaccount

View Subaccount List

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

Function Name:

getSubaccountList()

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 getSubaccountList(exchange, options) {
    try {
        let result = await exchange.getSubaccountList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountList(myOkxAccount)

Get Subaccount Trading Balance

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

Function Name:

getSubaccountTradingBalance()

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 getSubaccountTradingBalance(exchange, options) {
    try {
        let result = await exchange.getSubaccountTradingBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountTradingBalance(myOkxAccount, {
    subAcct: "mySubaccount"
    })

Get Subaccount Funding Balance

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

Function Name:

getSubaccountFundingBalance()

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 getSubaccountFundingBalance(exchange, options) {
    try {
        let result = await exchange.getSubaccountFundingBalance(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountFundingBalance(myOkxAccount, {
    subAcct: "mySubaccount"
    })

History of Subaccount Transfer

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

Applies to master accounts only.

Function Name:

getSubaccountBills()

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 getSubaccountBills(exchange, options) {
    try {
        let result = await exchange.getSubaccountBills(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getSubaccountBills(myOkxAccount)

Master Accounts Manage the Transfers Between Subaccounts

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

Function Name:

subaccountTransfer()

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 subaccountTransfer(exchange, options) {
    try {
        let result = await exchange.subaccountTransfer(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await subaccountTransfer(myOkxAccount, 
{
    ccy:"USDT",
    amt:"1.5",
    from:"6",
    to:"6",
    fromSubAccount:"test-1",
    toSubAccount:"test-2"
})

Set Permission of Transfer Out

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

Function Name:

canTransferOut()

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 canTransferOut(exchange, options) {
    try {
        let result = await exchange.canTransferOut(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await canTransferOut(myOkxAccount, 
{
    subAcct:"test-1",
    canTransOut:true
})

Get Custody Trading Subaccount List

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

Function Name:

getCustodyTradingAccountList()

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 getCustodyTradingAccountList(exchange, options) {
    try {
        let result = await exchange.getCustodyTradingAccountList(options);
        console.log(result);
    } catch (error) {
        console.log(error.message);
    }
}

const result = await getCustodyTradingAccountList(myOkxAccount)

⚫
💡
💻
https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-balance
https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
https://www.okx.com/docs-v5/en/#rest-api-account-get-positions-history
https://www.okx.com/docs-v5/en/#rest-api-account-get-account-and-position-risk
https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-7-days
https://www.okx.com/docs-v5/en/#rest-api-account-get-bills-details-last-3-months
https://www.okx.com/docs-v5/en/#rest-api-account-get-account-configuration
https://www.okx.com/docs-v5/en/#rest-api-account-set-position-mode
https://www.okx.com/docs-v5/en/#rest-api-account-set-leverage
https://www.okx.com/docs-v5/en/#rest-api-account-get-maximum-buy-sell-amount-or-open-amount
https://www.okx.com/docs-v5/en/#rest-api-account-get-maximum-available-tradable-amount
https://www.okx.com/docs-v5/en/#rest-api-account-increase-decrease-margin
https://www.okx.com/docs-v5/en/#rest-api-account-get-leverage
https://www.okx.com/docs-v5/en/#rest-api-account-get-the-maximum-loan-of-instrument
https://www.okx.com/docs-v5/en/#rest-api-account-get-fee-rates
https://www.okx.com/docs-v5/en/#rest-api-account-get-interest-accrued-data
https://www.okx.com/docs-v5/en/#rest-api-account-get-interest-rate
https://www.okx.com/docs-v5/en/#rest-api-account-set-greeks-pa-bs
https://www.okx.com/docs-v5/en/#rest-api-account-isolated-margin-trading-settings
https://www.okx.com/docs-v5/en/#rest-api-account-get-maximum-withdrawals
https://www.okx.com/docs-v5/en/#rest-api-account-get-account-risk-state
https://www.okx.com/docs-v5/en/#rest-api-account-vip-loans-borrow-and-repay
https://www.okx.com/docs-v5/en/#rest-api-account-get-borrow-and-repay-history-for-vip-loans
https://www.okx.com/docs-v5/en/#rest-api-account-get-borrow-interest-and-limit
https://www.okx.com/docs-v5/en/#rest-api-account-position-builder
https://www.okx.com/docs-v5/en/#rest-api-account-get-greeks
https://www.okx.com/docs-v5/en/#rest-api-subaccount-view-sub-account-list
https://www.okx.com/docs-v5/en/#rest-api-subaccount-get-sub-account-trading-balance
https://www.okx.com/docs-v5/en/#rest-api-subaccount-get-sub-account-funding-balance
https://www.okx.com/docs-v5/en/#rest-api-subaccount-history-of-sub-account-transfer
https://www.okx.com/docs-v5/en/#rest-api-subaccount-master-accounts-manage-the-transfers-between-sub-accounts
https://www.okx.com/docs-v5/en/#rest-api-subaccount-set-permission-of-transfer-out
https://www.okx.com/docs-v5/en/#rest-api-subaccount-get-custody-trading-sub-account-list