Use this file to discover all available pages before exploring further.
BitMart’s spot algo order system lets you automate conditional execution without running your own monitoring loop. Two algo order types are supported: trigger orders (execute a market or limit order when a price condition is met) and TP/SL orders (take-profit / stop-loss pairs). All algo endpoints use the V4 API and require full authentication. This page also covers the getBrokerRebate method for API broker integrations.
A trigger order monitors the market and submits a new limit or market order once the spot price crosses a specified trigger_price.Use case: “Buy 0.1 BTC with a market order if the price drops to 45,000 USDT.”Key fields:
type: "trigger"
trigger_price — the price level to watch
trigger_type — "limit" (trigger at exact price) or "market" (trigger at market price)
price — the execution price for a limit trigger order
size or notional — order quantity
A TP/SL order is a take-profit / stop-loss conditional order that triggers when the asset price hits the specified threshold.Use case: “Sell 0.1 BTC at market if the price reaches 65,000 (take profit) or falls to 40,000 (stop loss).”Key fields:
This example shows how to submit a trigger order, monitor it until it activates or times out, and cancel it if needed.
import { RestClient } from 'bitmart-api';async function algoOrderLifecycle() { const client = new RestClient({ apiKey: process.env.API_KEY!, apiSecret: process.env.API_SECRET!, apiMemo: process.env.API_MEMO!, }); const clientOrderId = `algo-${Date.now()}`; // Step 1: Place a trigger buy order console.log('Placing trigger buy order...'); const submitResponse = await client.submitSpotAlgoOrderV4({ symbol: 'BTC_USDT', side: 'buy', type: 'trigger', trigger_price: '45000', trigger_type: 'market', size: '0.001', client_order_id: clientOrderId, }); const orderId = submitResponse.data.order_id; console.log(`Algo order placed: ${orderId}`); // Step 2: Verify it's active const orderDetail = await client.getSpotAlgoOrderByClientOrderIdV4({ clientOrderId, queryState: 'open', }); console.log(`Current state: ${orderDetail.data.state}`); // Step 3: List all open trigger orders const openOrders = await client.getSpotAlgoOpenOrdersV4({ symbol: 'BTC_USDT', orderMode: 'trigger', }); console.log(`Open trigger orders on BTC_USDT: ${openOrders.data.length}`); // Step 4: Cancel if the trigger condition is no longer relevant const cancelResponse = await client.cancelSpotAlgoOrderV4({ symbol: 'BTC_USDT', order_id: orderId, type: 'trigger', }); console.log(`Cancelled: ${cancelResponse.data.result}`); // Step 5: Confirm it appears in history const history = await client.getSpotAlgoHistoryOrdersV4({ symbol: 'BTC_USDT', limit: 5, }); const cancelled = history.data.find((o) => o.orderId === orderId); console.log(`Final state in history: ${cancelled?.state ?? 'not found yet'}`);}await algoOrderLifecycle();
Always persist the order_id returned by submitSpotAlgoOrderV4 immediately. If your process restarts, you can recover the order via getSpotAlgoOrderByClientOrderIdV4 using the client_order_id you supplied at creation.