Skip to main content
Glama

compare_strategies

Compare macro-factor quantitative trading strategies side-by-side to evaluate key metrics like return, drawdown, and Sharpe ratio for risk profile assessment.

Instructions

Compare multiple QuantToGo macro-factor strategies side-by-side. Returns a comparison table of key metrics (return, drawdown, Sharpe, recent performance). Useful for evaluating which quantitative signal source strategies fit your risk profile.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
productIdsYesArray of product IDs to compare, e.g. ['PROD-E3X', 'PROD-PCR']

Implementation Reference

  • Handler function that executes compare_strategies tool logic: fetches products via callAPI, filters by productIds, and returns comparison data with key metrics (return, drawdown, recent performance)
    async ({ productIds }) => {
      const res = (await callAPI("getProducts")) as {
        code: number;
        data: Record<string, unknown>[];
      };
      if (res.code !== 0 || !Array.isArray(res.data)) {
        return {
          content: [{ type: "text" as const, text: "Failed to fetch strategies" }],
        };
      }
    
      const selected = res.data.filter((p) =>
        productIds.includes(p.productId as string)
      );
    
      if (selected.length === 0) {
        return {
          content: [
            {
              type: "text" as const,
              text: `None of the specified product IDs were found. Use list_strategies to see available IDs.`,
            },
          ],
        };
      }
    
      const comparison = selected.map((p) => ({
        productId: p.productId,
        name: p.name,
        market: p.market || "—",
        totalReturn: p.totalReturn ?? p.totalReturn5Y ?? null,
        maxDrawdown: p.maxDrawdown ?? null,
        recent1dReturn: p.recent1dReturn ?? null,
        recent30dReturn: p.recent30dReturn ?? null,
      }));
    
      return {
        content: [
          { type: "text" as const, text: JSON.stringify(comparison, null, 2) },
        ],
      };
    }
  • src/index.ts:218-271 (registration)
    Tool registration using server.tool() with name 'compare_strategies', description, zod schema for input validation, and async handler function
    server.tool(
      "compare_strategies",
      "Compare multiple QuantToGo macro-factor strategies side-by-side. Returns a comparison table of key metrics (return, drawdown, Sharpe, recent performance). Useful for evaluating which quantitative signal source strategies fit your risk profile.",
      {
        productIds: z
          .array(z.string())
          .min(2)
          .max(8)
          .describe("Array of product IDs to compare, e.g. ['PROD-E3X', 'PROD-PCR']"),
      },
      async ({ productIds }) => {
        const res = (await callAPI("getProducts")) as {
          code: number;
          data: Record<string, unknown>[];
        };
        if (res.code !== 0 || !Array.isArray(res.data)) {
          return {
            content: [{ type: "text" as const, text: "Failed to fetch strategies" }],
          };
        }
    
        const selected = res.data.filter((p) =>
          productIds.includes(p.productId as string)
        );
    
        if (selected.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: `None of the specified product IDs were found. Use list_strategies to see available IDs.`,
              },
            ],
          };
        }
    
        const comparison = selected.map((p) => ({
          productId: p.productId,
          name: p.name,
          market: p.market || "—",
          totalReturn: p.totalReturn ?? p.totalReturn5Y ?? null,
          maxDrawdown: p.maxDrawdown ?? null,
          recent1dReturn: p.recent1dReturn ?? null,
          recent30dReturn: p.recent30dReturn ?? null,
        }));
    
        return {
          content: [
            { type: "text" as const, text: JSON.stringify(comparison, null, 2) },
          ],
        };
      }
    );
  • Zod schema definition for productIds parameter: array of strings with min 2 and max 8 elements, with descriptive text
    {
      productIds: z
        .array(z.string())
        .min(2)
        .max(8)
        .describe("Array of product IDs to compare, e.g. ['PROD-E3X', 'PROD-PCR']"),
    },
  • callAPI helper function used by the handler to fetch data from QuantToGo API endpoints via HTTP POST requests
    async function callAPI(fn: string, body: Record<string, unknown> = {}): Promise<unknown> {
      const resp = await fetch(`${API_BASE}/${fn}`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(body),
      });
      if (!resp.ok) throw new Error(`API ${fn} returned ${resp.status}`);
      return resp.json();
    }

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/QuantToGo/quanttogo-mcp'

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