Skip to main content
Glama

set_trading_stop

Define and manage stop-loss, take-profit, and trailing stop orders for cryptocurrency trading on Bybit. Specify category, symbol, and price levels to automate risk management and optimize trade outcomes.

Instructions

Set trading stop

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory (spot, linear, inverse, etc.)
positionIdxNoPosition index
stopLossNoStop loss price
symbolYesSymbol (e.g., BTCUSDT)
takeProfitNoTake profit price
trailingStopNoTrailing stop

Implementation Reference

  • Core handler implementation that sets trading stops (TP/SL/trailing stop) by calling Bybit API endpoint /v5/position/trading-stop.
    async setTradingStop( category: string, symbol: string, takeProfit?: string, stopLoss?: string, trailingStop?: string, positionIdx?: number ): Promise<BybitResponse<any> | { error: string }> { const params: any = { category, symbol }; if (takeProfit) params.takeProfit = takeProfit; if (stopLoss) params.stopLoss = stopLoss; if (trailingStop) params.trailingStop = trailingStop; if (positionIdx !== undefined) params.positionIdx = positionIdx; return this.makeBybitRequest('/v5/position/trading-stop', 'POST', params); }
  • MCP CallToolRequest handler that dispatches 'set_trading_stop' tool calls to the BybitService.
    case 'set_trading_stop': { const result = await this.bybitService.setTradingStop( typedArgs.category, typedArgs.symbol, typedArgs.takeProfit, typedArgs.stopLoss, typedArgs.trailingStop, typedArgs.positionIdx ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • src/index.ts:385-418 (registration)
    Tool registration in MCP server's ListTools response, including name, description, and input schema validation.
    { name: 'set_trading_stop', description: 'Set trading stop', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category (spot, linear, inverse, etc.)', }, symbol: { type: 'string', description: 'Symbol (e.g., BTCUSDT)', }, takeProfit: { type: 'string', description: 'Take profit price', }, stopLoss: { type: 'string', description: 'Stop loss price', }, trailingStop: { type: 'string', description: 'Trailing stop', }, positionIdx: { type: 'number', description: 'Position index', }, }, required: ['category', 'symbol'], }, },
  • Input schema for validating parameters of the set_trading_stop tool.
    inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category (spot, linear, inverse, etc.)', }, symbol: { type: 'string', description: 'Symbol (e.g., BTCUSDT)', }, takeProfit: { type: 'string', description: 'Take profit price', }, stopLoss: { type: 'string', description: 'Stop loss price', }, trailingStop: { type: 'string', description: 'Trailing stop', }, positionIdx: { type: 'number', description: 'Position index', }, }, required: ['category', 'symbol'], },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kondisettyravi/mcp-bybit-node'

If you have feedback or need assistance with the MCP directory API, please join our Discord server