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
  • Placing and Manipulating Orders
  • Place Order
  • Place Multiple Orders
  • Cancel Order
  • Cancel Multiple Orders
  • Amend Order
  • Amend Multiple Orders
  • Close Positions
  • Order Details And Transaction History
  • Get Order Details
  • Get Order List
  • Get Order History (last 7 days)
  • Get Order History (last 3 months)
  • Get Transaction Details (last 3 days)
  • Get Transaction Details (last 3 months)
  • Placing & Editing Algo Orders
  • Place Algo Order
  • Cancel Algo Order
  • Cancel Advance Algo Order
  • Get Algo Order List
  • Get Algo Order History
  • One-Click & Easy Convert
  • Get Easy Convert Currency List
  • Place Easy Convert
  • Get Easy Convert History
  • Get One-Click Repay Currency List
  • Trade One-Click Repay
  • Get One-Click Repay History
  • Block Trading
  • Get Counterparties
  • Create RFQ
  • Cancel RFQ
  • Cancel Multiple RFQ's
  • Cancel All RFQ's
  • Execute Quote
  • Set Quote Products
  • Reset MMP Status
  • Create Quote
  • Cancel Quote
  • Cancel Multiple Quotes
  • Cancel All Quotes
  • Get RFQ's
  • Get Quotes
  • Get Trades
  • Get Public Trades
  1. PENDAX
  2. Using PENDAX SDK
  3. OKX Functions

Trading & Orders

Documentation on interacting with a variety of OKX trading and order API functions through the PENDAX SDK.

PreviousOKX FunctionsNextFunding

Last updated 1 year ago

All Trading & Order API endpoints require authentication. Please create OKX API keys to interact with these functions successfully. Accounts must be funded or collateralized for any trades to successfully post. Please note that some endpoints for Algo & Block trading are currently under development.

Placing and Manipulating Orders

Place Order

Please refer to the official OKX API Docs for the required parameters. You can place an order only if you have sufficient funds.

Function Name:

placeOrder()

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 placeOrder(exchange, options) {
        try {
            let result = await exchange.placeOrder(options);
            return result
            console.log(result);
        } catch (error) {
            console.log(error.message);
        }
    }
  
    const result = await placeOrder(myOkxAccount, {
         instId: "BTC-USDT",
         tdMode: "cash",
         side: "buy",
         ordType: "limit",
         px: "10000",
         sz: ".01",         // for SWAPS sz is number of contracts which is .01 BTC
    })

Place Multiple Orders

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

Function Name:

placeMultiOrder()

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

const result = await placeMultiOrder(myOkxAccount, [

    {
        instId:"BTC-USDT",
        tdMode:"cash",
        clOrdId:"b15",
        side:"buy",
        ordType:"limit",
        px:"2.15",
        sz:"2"
    },
    {
        instId:"BTC-USDT",
        tdMode:"cash",
        clOrdId:"b15",
        side:"buy",
        ordType:"limit",
        px:"2.15",
        sz:"2"
    }
])

Cancel Order

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

Function Name:

cancelOrder()

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

const result = await cancelOrder(myOkxAccount, {
    ordId:"2510789768709120",
    instId:"BTC-USD-190927"
})

Cancel Multiple Orders

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

Function Name:

cancelMultiOrder()

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

const result = await cancelOrder(myOkxAccount, [
{
    ordId:"2510789768709120",
    instId:"BTC-USD-190927"
},
{
    ordId:"12312",
    instId:"BTC-USDT"
}
])

Amend Order

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

Function Name:

modifyOrder()

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

const result = await modifyOrder(myOkxAccount, {
    ordId:"2510789768709120",
    newSz:"2",
    instId:"BTC-USDT"
})

Amend Multiple Orders

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

Function Name:

modifyMultiOrder()

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

const result = await modifyMultiOrder(myOkxAccount, [
    {
        ordId:"2510789768709120",
        newSz:"2",
        instId:"BTC-USDT"
    },
    {
        ordId:"2510789768709121",
        newSz:"2",
        instId:"BTC-USDT"
    }
])

Close Positions

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

Function Name:

closePositions()

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

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

Order Details And Transaction History

Get Order Details

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

Function Name:

getOrderDetails()

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

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

Get Order List

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

Function Name:

getOrderList()

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

const result = await getOrderList(myOkxAccount)

Get Order History (last 7 days)

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

Function Name:

getOrderHistoryWeek()

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

const result = await getOrderHistoryWeek(myOkxAccount, {
                instType: "SPOT"
                })

Get Order History (last 3 months)

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

Function Name:

getOrderHistoryArchive()

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

const result = await getOrderHistoryArchive(myOkxAccount, {
                instType: "SPOT"
                })

Get Transaction Details (last 3 days)

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

Function Name:

getRecentTransactionDetailsShort()

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

const result = await getRecentTransactionDetailsShort(myOkxAccount)

Get Transaction Details (last 3 months)

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

Function Name:

getRecentTransactionDetailsLong()

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

const result = await getRecentTransactionDetailsLong(myOkxAccount)

Placing & Editing Algo Orders

Place Algo Order

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

Function Name:

placeAlgoOrder()

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

const result = await placeAlgoOrder(myOkxAccount, {
    instId:"BTC-USDT",
    tdMode:"cross",
    side:"buy",
    ordType:"conditional",
    sz:"2",
    tpTriggerPx:"15",
    tpOrdPx:"18")
    })

Cancel Algo Order

This endpoint is currently under development

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

Function Name:

cancelAlgoOrder()

Usage:

// 

Cancel Advance Algo Order

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

Function Name:

cancelAdvAlgoOrder()

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

const result = await cancelAdvAlgoOrder(myOkxAccount, 
[
    {
        algoId:"198273485",
        instId:"BTC-USDT"
    },
    {
        algoId:"198273485",
        instId:"BTC-USDT"
    }
])

Get Algo Order List

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

Function Name:

getAlgoOrderList()

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

const result = await getAlgoOrderList(myOkxAccount, {
            ordType: "conditional"
    })

Get Algo Order History

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

Function Name:

getAlgoOrderHistory()

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

const result = await getAlgoOrderHistory(myOkxAccount, {
            state: "effective",
            ordType: "conditional"
    })

One-Click & Easy Convert

Get Easy Convert Currency List

This endpoint is currently under development.

Place Easy Convert

This endpoint is currently under development.

Get Easy Convert History

This endpoint is currently under development.

Get One-Click Repay Currency List

This endpoint is currently under development.

Trade One-Click Repay

This endpoint is currently under development.

Get One-Click Repay History

This endpoint is currently under development.

Block Trading

Get Counterparties

This endpoint is under development

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

Function Name:

getCounterparties()

Usage:

// 

Create RFQ

This endpoint is under development

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

Function Name:

createRfq()

Usage:

// 

Cancel RFQ

This endpoint is under development

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

Function Name:

cancelRfq()

Usage:

//

Cancel Multiple RFQ's

This endpoint is under development

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

Function Name:

cancelBatchRfq()

Usage:

//

Cancel All RFQ's

This endpoint is under development

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

Function Name:

cancelAllRfqs()

Usage:

//

Execute Quote

This endpoint is under development

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

Function Name:

executeQuote()

Usage:

//

Set Quote Products

This endpoint is under development

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

Function Name:

//

Usage:

//

Reset MMP Status

This endpoint is under development

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

Function Name:

//

Usage:

//

Create Quote

This endpoint is under development

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

Function Name:

createQuote()

Usage:

//

Cancel Quote

This endpoint is under development

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

Function Name:

cancelQuote()

Usage:

//

Cancel Multiple Quotes

This endpoint is under development

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

Function Name:

cancelBatchQuotes()

Usage:

//

Cancel All Quotes

This endpoint is under development

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

Function Name:

cancelAllQuotes()

Usage:

//

Get RFQ's

This endpoint is under development

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

Function Name:

getRfqs()

Usage:

//

Get Quotes

This endpoint is under development

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

Function Name:

getQuotes()

Usage:

//

Get Trades

This endpoint is under development

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

Function Name:

getUserBlockTrades()

Usage:

//

Get Public Trades

This endpoint is under development

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

Function Name:

getPublicBlockTrades()

Usage:

//

⚫
💡
💻
https://www.okx.com/docs-v5/en/#rest-api-trade-place-order
https://www.okx.com/docs-v5/en/#rest-api-trade-place-multiple-orders
https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-order
https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-multiple-orders
https://www.okx.com/docs-v5/en/#rest-api-trade-amend-order
https://www.okx.com/docs-v5/en/#rest-api-trade-amend-multiple-orders
https://www.okx.com/docs-v5/en/#rest-api-trade-close-positions
https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-details
https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-list
https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-history-last-7-days
https://www.okx.com/docs-v5/en/#rest-api-trade-get-order-history-last-3-months
https://www.okx.com/docs-v5/en/#rest-api-trade-get-transaction-details-last-3-days
https://www.okx.com/docs-v5/en/#rest-api-trade-get-transaction-details-last-3-months
https://www.okx.com/docs-v5/en/#rest-api-trade-place-algo-order
https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-algo-order
https://www.okx.com/docs-v5/en/#rest-api-trade-cancel-advance-algo-order
https://www.okx.com/docs-v5/en/#rest-api-trade-get-algo-order-list
https://www.okx.com/docs-v5/en/#rest-api-trade-get-algo-order-history
https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-counterparties
https://www.okx.com/docs-v5/en/#rest-api-block-trading-create-rfq
https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-rfq
https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-multiple-rfqs
https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-all-rfqs
https://www.okx.com/docs-v5/en/#rest-api-block-trading-execute-quote
https://www.okx.com/docs-v5/en/#rest-api-block-trading-set-quote-products
https://www.okx.com/docs-v5/en/#rest-api-block-trading-reset-mmp-status
https://www.okx.com/docs-v5/en/#rest-api-block-trading-create-quote
https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-quote
https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-multiple-quotes
https://www.okx.com/docs-v5/en/#rest-api-block-trading-cancel-all-quotes
https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-rfqs
https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-quotes
https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-trades
https://www.okx.com/docs-v5/en/#rest-api-block-trading-get-public-trades