Skip to main content
Glama

stop_strategy

Cancel all open orders for a trading pair to stop a running grid strategy on supported cryptocurrency exchanges.

Instructions

Cancel all open orders for a trading pair, effectively stopping any running grid strategy

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange to query. Supported: mexc, gateio, bitget, kraken
symbolYesTrading pair symbol (e.g., BTC/USDT, INDY/USDT)

Implementation Reference

  • Main handler implementation of stop_strategy tool - validates exchange/symbol, gets connector, cancels all open orders, and returns status with cancelled order count
    server.tool(
      'stop_strategy',
      'Cancel all open orders for a trading pair, effectively stopping any running grid strategy',
      {
        exchange: ExchangeParam,
        symbol: SymbolParam,
      },
      async ({ exchange, symbol }) => {
        const validExchange = validateExchange(exchange);
        const validSymbol = validateSymbol(symbol);
    
        const connector = await getConnectorSafe(exchange);
        const openOrders = await connector.getOpenOrders(validSymbol);
        const result = await connector.cancelAllOrders(validSymbol);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  status: 'stopped',
                  cancelledOrders: openOrders.length,
                  result,
                  exchange: validExchange,
                  symbol: validSymbol,
                  timestamp: new Date().toISOString(),
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Zod schema definitions for ExchangeParam and SymbolParam used as input validation for stop_strategy
    export const ExchangeParam = z
      .string()
      .describe('Exchange to query. Supported: mexc, gateio, bitget, kraken');
    
    export const SymbolParam = z.string().describe('Trading pair symbol (e.g., BTC/USDT, INDY/USDT)');
  • src/worker.ts:27-37 (registration)
    Registration of stop_strategy in the server card capabilities list for discovery
    tools: [
      { name: 'get_ticker' },
      { name: 'get_orderbook' },
      { name: 'get_trades' },
      { name: 'get_balance' },
      { name: 'list_orders' },
      { name: 'create_order' },
      { name: 'cancel_order' },
      { name: 'cancel_all_orders' },
      { name: 'start_grid_strategy' },
      { name: 'stop_strategy' },
  • Entry point that registers all tool groups including registerStrategyTools which contains stop_strategy
    export function registerTools(server: McpServer): void {
      registerMarketDataTools(server);
      registerAccountTools(server);
      registerTradingTools(server);
      registerCardanoTools(server);
      registerStrategyTools(server);
    }
  • Helper function that registers all strategy-related tools (start_grid_strategy, stop_strategy, get_strategy_status) with the MCP server
    export function registerStrategyTools(server: McpServer): void {
      server.tool(
        'start_grid_strategy',
        'Calculate and optionally place grid trading orders around the current price',
        {
          exchange: ExchangeParam,
          symbol: SymbolParam,
          levels: z.number().min(1).max(10).default(5).describe('Grid levels per side (default: 5)'),
          spacing: z
            .number()
            .min(0.001)
            .max(0.5)
            .default(0.02)
            .describe('Base spacing as decimal (default: 0.02 = 2%)'),
          orderSize: z
            .number()
            .positive()
            .default(50)
            .describe('Base order size in quote currency (default: 50)'),
          spacingModel: z.enum(['linear', 'geometric']).default('linear').describe('Spacing model'),
          spacingFactor: z
            .number()
            .positive()
            .default(1.3)
            .describe('Factor for geometric spacing (default: 1.3)'),
          sizeModel: z.enum(['flat', 'pyramidal']).default('flat').describe('Size model'),
          dryRun: z
            .boolean()
            .default(true)
            .describe('Preview grid without placing orders (default: true)'),
        },
        async ({
          exchange,
          symbol,
          levels,
          spacing,
          orderSize,
          spacingModel,
          spacingFactor,
          sizeModel,
          dryRun,
        }) => {
          const validExchange = validateExchange(exchange);
          const validSymbol = validateSymbol(symbol);
    
          const connector = await getConnectorSafe(exchange);
          const ticker = await connector.getTicker(validSymbol);
          const centerPrice = ticker.last;
    
          const grid = calculateGridLevels(
            centerPrice,
            levels,
            spacing,
            spacingModel,
            spacingFactor,
            orderSize,
            sizeModel
          );
    
          const placedOrders: any[] = [];
          if (!dryRun) {
            for (const level of grid) {
              const order = await connector.createOrder(
                validSymbol,
                'limit',
                level.side,
                level.orderSize,
                level.price
              );
              placedOrders.push(order);
            }
          }
    
          return {
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(
                  {
                    status: dryRun ? 'preview' : 'active',
                    centerPrice,
                    config: { levels, spacing, spacingModel, spacingFactor, orderSize, sizeModel },
                    grid: grid.map((l) => ({
                      side: l.side,
                      price: l.price,
                      amount: l.orderSize,
                      valueQuote: l.price * l.orderSize,
                    })),
                    totalOrders: grid.length,
                    totalBuyValue: grid
                      .filter((l) => l.side === 'buy')
                      .reduce((s, l) => s + l.price * l.orderSize, 0),
                    totalSellValue: grid
                      .filter((l) => l.side === 'sell')
                      .reduce((s, l) => s + l.price * l.orderSize, 0),
                    ...(dryRun ? {} : { placedOrders }),
                    exchange: validExchange,
                    symbol: validSymbol,
                    timestamp: new Date().toISOString(),
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      );
    
      server.tool(
        'stop_strategy',
        'Cancel all open orders for a trading pair, effectively stopping any running grid strategy',
        {
          exchange: ExchangeParam,
          symbol: SymbolParam,
        },
        async ({ exchange, symbol }) => {
          const validExchange = validateExchange(exchange);
          const validSymbol = validateSymbol(symbol);
    
          const connector = await getConnectorSafe(exchange);
          const openOrders = await connector.getOpenOrders(validSymbol);
          const result = await connector.cancelAllOrders(validSymbol);
    
          return {
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(
                  {
                    status: 'stopped',
                    cancelledOrders: openOrders.length,
                    result,
                    exchange: validExchange,
                    symbol: validSymbol,
                    timestamp: new Date().toISOString(),
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but lacks critical behavioral details. It mentions cancellation but doesn't disclose whether this is reversible, requires specific permissions, has rate limits, or what happens to partially filled orders. The 'effectively stopping' phrasing adds some context about strategy impact, but key operational traits are missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence efficiently conveys the core action, target, and strategic effect with zero redundant information. Every word earns its place, and the structure is front-loaded with the primary purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive operation with no annotations and no output schema, the description is minimally adequate. It covers the 'what' but lacks details about consequences, error conditions, or return values. Given the complexity of stopping trading strategies, more behavioral context would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so parameters are fully documented in the schema. The description doesn't add any parameter-specific information beyond what the schema provides (exchange and symbol usage). Baseline 3 is appropriate when schema handles parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Cancel all open orders') and resource ('for a trading pair'), with explicit mention of the effect on 'any running grid strategy'. It distinguishes from sibling tools like 'cancel_all_orders' by specifying the strategic context and trading pair scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('effectively stopping any running grid strategy'), suggesting it's for halting automated strategies rather than general order cancellation. However, it doesn't explicitly state when NOT to use it or name alternatives like 'cancel_all_orders' for non-strategic scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/QBT-Labs/openmm-mcp'

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