Skip to main content
Glama

set_trading_stop

Configure stop-loss and take-profit orders to manage risk and secure profits on Bybit cryptocurrency trades.

Instructions

Set trading stop

Input Schema

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

Implementation Reference

  • Core implementation of the setTradingStop function that prepares parameters and makes authenticated POST request to Bybit's /v5/position/trading-stop endpoint to set take profit, stop loss, and/or trailing 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); }
  • src/index.ts:385-418 (registration)
    MCP tool registration entry in the server's listTools response, defining the tool name, description, and input schema.
    { 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/parameter validation definition for 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'], },
  • MCP server dispatch handler that receives tool call parameters and delegates to BybitService.setTradingStop, returning the result as MCP content.
    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), }, ], }; }

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