list_strategies
List available trading strategies with live performance data. Shows strategy name, market, total return, drawdown, and recent returns.
Instructions
List all available trading strategies with live performance data. Returns strategy name, market (US/China), total return, drawdown, and recent returns.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:49-85 (handler)The full implementation of the list_strategies tool handler. It calls the 'getProducts' API via callAPI, maps the response data to a structured format (productId, name, market, totalReturn, metricsYearLabel, maxDrawdown, recent1dReturn, recent30dReturn, status), and returns it as JSON text.
// ── Tool: list_strategies ──────────────────────────────────── server.tool( "list_strategies", "List all available trading strategies with live performance data. Returns strategy name, market (US/China), total return, drawdown, and recent returns.", {}, async () => { 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 strategies = res.data.map((p) => ({ productId: p.productId, name: p.name, market: p.market || "—", totalReturn: p.totalReturn ?? p.totalReturn5Y ?? null, metricsYearLabel: p.metricsYearLabel || null, maxDrawdown: p.maxDrawdown ?? null, recent1dReturn: p.recent1dReturn ?? null, recent30dReturn: p.recent30dReturn ?? null, status: p.status, })); return { content: [ { type: "text" as const, text: JSON.stringify(strategies, null, 2), }, ], }; } ); - src/index.ts:51-85 (registration)Registration of the 'list_strategies' tool on the McpServer via server.tool() within the registerTools function. No input schema (empty object) because no parameters are needed.
server.tool( "list_strategies", "List all available trading strategies with live performance data. Returns strategy name, market (US/China), total return, drawdown, and recent returns.", {}, async () => { 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 strategies = res.data.map((p) => ({ productId: p.productId, name: p.name, market: p.market || "—", totalReturn: p.totalReturn ?? p.totalReturn5Y ?? null, metricsYearLabel: p.metricsYearLabel || null, maxDrawdown: p.maxDrawdown ?? null, recent1dReturn: p.recent1dReturn ?? null, recent30dReturn: p.recent30dReturn ?? null, status: p.status, })); return { content: [ { type: "text" as const, text: JSON.stringify(strategies, null, 2), }, ], }; } ); - src/index.ts:54-54 (schema)Input schema for list_strategies is an empty object {} — the tool takes no parameters.
{}, - src/index.ts:11-19 (helper)The callAPI helper used by the list_strategies handler to POST to the 'getProducts' endpoint at https://www.quanttogo.com.
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(); }