Skip to main content
Glama

get_signal_stats

Analyze trading strategy performance by retrieving statistics like win rate, total trades, and P&L metrics for specified time periods.

Instructions

Get signal statistics and performance metrics for a strategy, including win rate, total trades, and P&L.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
strategyIdNoStrategy ID (omit for all strategies)
periodNoTime period30d

Implementation Reference

  • Main handler implementation for get_signal_stats tool. Registers the tool with MCP server, defines input schema using zod (strategyId optional, period enum with default '30d'), and implements the handler that calls client.getAnalytics() and returns the statistics data as JSON.
    server.tool(
      'get_signal_stats',
      'Get signal statistics and performance metrics for a strategy, including win rate, total trades, and P&L.',
      {
        strategyId: z.string().optional().describe('Strategy ID (omit for all strategies)'),
        period: z.enum(['7d', '30d', '90d', '1y', 'all']).default('30d').describe('Time period'),
      },
      async ({ strategyId, period }) => {
        try {
          const result = await client.getAnalytics({ type: 'signals', period });
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify(result.data || { message: 'No stats available' }, null, 2),
            }],
          };
        } catch (error: any) {
          return { content: [{ type: 'text', text: `Error: ${error.message}` }] };
        }
      }
    );
  • getAnalytics client method that wraps the API call. Accepts optional 'type' and 'period' parameters and makes a POST request to '/getAnalytics' endpoint. This is called by the get_signal_stats handler with type='signals'.
    async getAnalytics(params: { type?: string; period?: string } = {}) {
      return this.call('/getAnalytics', params);
    }
  • Base call method that performs HTTP POST requests to the QuantToGo API. Handles authentication headers (Bearer token and x-user-id), error handling, and response parsing. Used by getAnalytics and all other client methods.
    async call<T = any>(path: string, data: Record<string, any> = {}): Promise<ApiResponse<T>> {
      const url = `${this.apiBase}${path}`;
    
      const headers: Record<string, string> = {
        'Content-Type': 'application/json',
      };
    
      if (this.apiKey) {
        headers['Authorization'] = `Bearer ${this.apiKey}`;
      }
      if (this.userId) {
        headers['x-user-id'] = this.userId;
      }
    
      const response = await fetch(url, {
        method: 'POST',
        headers,
        body: JSON.stringify(data),
      });
    
      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(`API error ${response.status}: ${errorText}`);
      }
    
      const result = await response.json() as ApiResponse<T>;
    
      if (result.code !== undefined && result.success === undefined) {
        result.success = result.code === 0;
      }
    
      return result;
    }
  • ApiResponse type definition that defines the structure of API responses including code, data, message, and success fields. Used as the return type for all client methods including getAnalytics.
    export interface ApiResponse<T = any> {
      code: number;
      data?: T;
      message?: string;
      success?: boolean;
    }

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/michaeljiangmingfeng-debug/quanttogo-mcp-servers'

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