Skip to main content
Glama
PaulieB14

Limitless MCP

get_top_traders

Identify top-performing traders by analyzing volume, trade frequency, or profit/loss metrics across market types to inform trading strategies.

Instructions

Get top traders ranked by volume, trade count, or PnL. Queries both subgraphs and merges rankings.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orderByNototalVolumeUSD
firstNo
marketTypeNoFilter by market type or combine bothall

Implementation Reference

  • The handler for 'get_top_traders' retrieves data from subgraphs and merges results based on the provided marketType.
    async ({ orderBy, first, marketType }) => {
      try {
        const userQuery = `{
          users(first: ${first * 2}, orderBy: ${orderBy}, orderDirection: desc, where: { tradesCount_gt: "0" }) {
            id tradesCount totalVolumeUSD totalFeesUSD realizedPnlUSD
            firstTradeAt lastTradeAt
          }
        }`;
    
        if (marketType === "simple") {
          const data = await querySimple(userQuery);
          return textResult({ marketType, traders: (data.users || []).slice(0, first) });
        }
        if (marketType === "negrisk") {
          const data = await queryNegRisk(userQuery);
          return textResult({ marketType, traders: (data.users || []).slice(0, first) });
        }
    
        // Merge both
        const { simple, negrisk } = await queryBoth(userQuery, userQuery);
        const merged = new Map<string, any>();
    
        for (const u of [...(simple.users || []), ...(negrisk.users || [])]) {
          const existing = merged.get(u.id);
          if (existing) {
            existing.tradesCount =
              parseInt(existing.tradesCount) + parseInt(u.tradesCount);
            existing.totalVolumeUSD =
              parseFloat(existing.totalVolumeUSD) + parseFloat(u.totalVolumeUSD);
            existing.totalFeesUSD =
              parseFloat(existing.totalFeesUSD) + parseFloat(u.totalFeesUSD);
            existing.realizedPnlUSD =
              parseFloat(existing.realizedPnlUSD) + parseFloat(u.realizedPnlUSD);
          } else {
            merged.set(u.id, {
              ...u,
              tradesCount: parseInt(u.tradesCount),
              totalVolumeUSD: parseFloat(u.totalVolumeUSD),
              totalFeesUSD: parseFloat(u.totalFeesUSD),
              realizedPnlUSD: parseFloat(u.realizedPnlUSD),
            });
          }
        }
  • Tool registration and input schema definition for 'get_top_traders'.
    server.registerTool(
      "get_top_traders",
      {
        description:
          "Get top traders ranked by volume, trade count, or PnL. Queries both subgraphs and merges rankings.",
        inputSchema: {
          orderBy: z
            .enum(["totalVolumeUSD", "tradesCount", "totalFeesUSD"])
            .default("totalVolumeUSD"),
          first: z.number().default(20),
          marketType: z
            .enum(["simple", "negrisk", "all"])
            .default("all")
            .describe("Filter by market type or combine both"),
        },
      },

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/PaulieB14/limitless-subgraphs'

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