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
  • Grid Trading
  • Place Grid Algo Order
  • Amend Grid Algo Order
  • Stop Grid Algo Order
  • Get Grid Algo Order List
  • Get Grid Algo Order History
  • Get Grid Algo Order Details
  • Get Grid Algo Sub Orders
  • Get Grid Algo Order Positions
  • Spot Grid Withdraw Income
  1. PENDAX
  2. Using PENDAX SDK
  3. OKX Functions

Grid Trading

Documentation on interacting with a OKX's native Grid Trading programmatic API functions through the PENDAX Javascript SDK.

PreviousAccount & SubaccountNextMarket Data

Last updated 2 years ago

All Grid Trading 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.

Grid Trading

Place Grid Algo Order

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

Function Name:

placeGridAlgoOrder()

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

const result = await placeGridAlgoOrder(myOkxAccount,
{
    instId: "BTC-USDT",
    algoOrdType: "grid",
    maxPx: "5000",
    minPx: "400",
    gridNum: "10",
    runType: "1",
    quoteSz: "25"
})

Amend Grid Algo Order

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

Function Name:

amendGrid()

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

const result = await amendGrid(myOkxAccount,
{
    algoId:"448965992920907776",
    instId:"BTC-USDT-SWAP",
    slTriggerPx:"1200",
    tpTriggerPx:""
})

Stop Grid Algo Order

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

Function Name:

stopGrid()

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

const result = await stopGrid(myOkxAccount,
{
    [
    {
        algoId:"198273485",
        instId:"BTC-USDT",
        stopType:"1",
        algoOrdType:"grid"
    }
    ]
})

Get Grid Algo Order List

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

Function Name:

getPendingGridOrders()

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

const result = await getPendingGridOrders(myOkxAccount,
{
        algoOrdType:"grid"
})

Get Grid Algo Order History

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

Function Name:

getGridOrderHistory()

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

const result = await getGridOrderHistory(myOkxAccount,
{
        algoOrdType:"grid"
})

Get Grid Algo Order Details

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

Function Name:

getGridOrderDetails()

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

const result = await getGridOrderDetails(myOkxAccount,
{
        algoId: "448965992920907776",
        algoOrdType: "grid"
})

Get Grid Algo Sub Orders

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

Function Name:

getGridSubOrders()

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

const result = await getGridSubOrders(myOkxAccount,
{
        algoId: "448965992920907776",
        algoOrdType: "grid"
})

Get Grid Algo Order Positions

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

Function Name:

getGridPositions()

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

const result = await getGridPositions(myOkxAccount,
{
        algoId: "448965992920907776",
        algoOrdType: "contract_grid"
})

Spot Grid Withdraw Income

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

Function Name:

spotGridWithdraw()

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

const result = await spotGridWithdraw(myOkxAccount,
{
    algoId:"448965992920907776"
})

⚫
💡
💻
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-place-grid-algo-order
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-amend-grid-algo-order
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-stop-grid-algo-order
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-list
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-history
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-details
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-sub-orders
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-get-grid-algo-order-positions
https://www.okx.com/docs-v5/en/#rest-api-grid-trading-spot-moon-grid-withdraw-income