Skip to main content
All signal bot endpoints require authentication.

Method reference

Signal management

MethodHTTPEndpointDescription
createSignal(params)POST/api/v5/tradingBot/signal/create-signalCreate a new signal source
getSignals(params)GET/api/v5/tradingBot/signal/signalsList signal sources

Bot lifecycle

MethodHTTPEndpointDescription
createSignalBot(params)POST/api/v5/tradingBot/signal/order-algoDeploy a signal bot
cancelSignalBots(params)POST/api/v5/tradingBot/signal/stop-order-algoStop a signal bot
setSignalInstruments(params)POST/api/v5/tradingBot/signal/set-instrumentsSet tradable instruments for a bot
updateSignalMargin(params)POST/api/v5/tradingBot/signal/margin-balanceAdjust a bot’s margin balance
updateSignalTPSL(params)POST/api/v5/tradingBot/signal/amendTPSLUpdate take-profit / stop-loss

Bot queries

MethodHTTPEndpointDescription
getActiveSignalBot(params)GET/api/v5/tradingBot/signal/orders-algo-detailsDetails of an active bot
getSignalBotOrder(params)GET/api/v5/tradingBot/signal/orders-algo-detailsDetails of a specific bot order
getSignalBotHistory(params)GET/api/v5/tradingBot/signal/orders-algo-historyHistorical signal bots
getSignalBotPositions(params)GET/api/v5/tradingBot/signal/positionsOpen positions held by a bot
getSignalBotPositionHistory(params)GET/api/v5/tradingBot/signal/positions-historyHistorical bot positions

Sub-orders

MethodHTTPEndpointDescription
placeSignalBotSubOrder(params)POST/api/v5/tradingBot/signal/sub-orderManually place a sub-order on a bot
cancelSubOrder(params)POST/api/v5/tradingBot/signal/cancel-sub-orderCancel a bot sub-order
getSignalBotSubOrders(params)GET/api/v5/tradingBot/signal/sub-ordersSub-orders of a bot
getSignalBotEventHistory(params)GET/api/v5/tradingBot/signal/event-historyEvent history for a bot
closeSignalBotPosition(params)POST/api/v5/tradingBot/signal/close-positionClose a bot position

Examples

Create a signal source

import { RestClient } from 'okx-api';

const client = new RestClient({
  apiKey: process.env.API_KEY!,
  apiSecret: process.env.API_SECRET!,
  apiPass: process.env.API_PASS!,
});

const [signal] = await client.createSignal({
  signalChanName: 'My RSI Signal',
  signalChanDesc: 'Fires when 4H RSI crosses 30 or 70',
});

console.log('Signal channel token:', signal.signalChanToken);
console.log('Signal channel ID:', signal.signalChanId);

Deploy a signal bot

const [bot] = await client.createSignalBot({
  signalChanId: 'your-signal-channel-id',
  lever: '3',
  instIds: ['BTC-USDT-SWAP', 'ETH-USDT-SWAP'],
  investAmt: '500',
  subOrdType: '1',    // '1' = market orders
  includeAll: false,
});

console.log('Bot algo ID:', bot.algoId);

View active bot and positions

// Get active bot details
const bots = await client.getActiveSignalBot({
  algoOrdType: 'signal',
  algoId: 'your-algo-id',
});
console.log('Bot state:', bots[0]?.state);

// Get open positions
const positions = await client.getSignalBotPositions({
  algoOrdType: 'signal',
  algoId: 'your-algo-id',
});
for (const pos of positions) {
  console.log(`${pos.instId}: pos=${pos.pos}, uPnL=${pos.upl}`);
}

Update TP/SL

await client.updateSignalTPSL({
  algoId: 'your-algo-id',
  tpRatio: '0.2',   // 20% take profit
  slRatio: '0.1',   // 10% stop loss
});

Stop a bot

const [stopped] = await client.cancelSignalBots({
  algoId: 'your-algo-id',
});
console.log('Stopped bot:', stopped.algoId);

View event history

const events = await client.getSignalBotEventHistory({
  algoId: 'your-algo-id',
  limit: '20',
});
for (const event of events) {
  console.log(`[${event.cTime}] ${event.eventType}: ${event.msg}`);
}

Build docs developers (and LLMs) love