Skip to main content
Glama

read_backtest_chart

Retrieve chart data from backtest results to analyze trading strategy performance, supporting customizable time ranges and data points.

Instructions

Read chart data from a backtest.

Args: project_id: Project ID containing the backtest backtest_id: ID of the backtest to get chart from name: Name of the chart to retrieve (e.g., "Strategy Equity") count: Number of data points to request (default: 100) start: Optional UTC start timestamp in seconds end: Optional UTC end timestamp in seconds

Returns: Dictionary containing chart data or loading status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
backtest_idYes
nameYes
countNo
startNo
endNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'read_backtest_chart' tool. Decorated with @mcp.tool(), it authenticates via QuantConnect API, prepares request parameters, calls the 'backtests/chart/read' endpoint, and returns chart data or loading progress.
    @mcp.tool()
    async def read_backtest_chart(
        project_id: int,
        backtest_id: str,
        name: str,
        count: int = 100,
        start: Optional[int] = None,
        end: Optional[int] = None,
    ) -> Dict[str, Any]:
        """
        Read chart data from a backtest.
    
        Args:
            project_id: Project ID containing the backtest
            backtest_id: ID of the backtest to get chart from
            name: Name of the chart to retrieve (e.g., "Strategy Equity")
            count: Number of data points to request (default: 100)
            start: Optional UTC start timestamp in seconds
            end: Optional UTC end timestamp in seconds
    
        Returns:
            Dictionary containing chart data or loading status
        """
        auth = get_auth_instance()
        if auth is None:
            return {
                "status": "error",
                "error": "QuantConnect authentication not configured. Use configure_auth() first.",
            }
    
        try:
            # Prepare request data
            request_data = {
                "projectId": project_id,
                "backtestId": backtest_id,
                "name": name,
                "count": count,
            }
    
            # Add optional timestamp parameters
            if start is not None:
                request_data["start"] = start
            if end is not None:
                request_data["end"] = end
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="backtests/chart/read", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    # Check if chart is still loading
                    if "progress" in data and "status" in data:
                        progress = data.get("progress", 0)
                        status = data.get("status", "loading")
                        return {
                            "status": "loading",
                            "project_id": project_id,
                            "backtest_id": backtest_id,
                            "chart_name": name,
                            "progress": progress,
                            "chart_status": status,
                            "message": f"Chart '{name}' is loading... ({progress * 100:.1f}% complete)",
                        }
    
                    # Chart is ready
                    elif "chart" in data:
                        chart = data.get("chart")
                        return {
                            "status": "success",
                            "project_id": project_id,
                            "backtest_id": backtest_id,
                            "chart_name": name,
                            "chart": chart,
                            "count": count,
                            "start": start,
                            "end": end,
                            "message": f"Successfully retrieved chart '{name}' from backtest {backtest_id}",
                        }
    
                    else:
                        return {
                            "status": "error",
                            "error": "Unexpected response format - no chart or progress data found",
                        }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Failed to read backtest chart",
                        "details": errors,
                        "project_id": project_id,
                        "backtest_id": backtest_id,
                        "chart_name": name,
                    }
    
            elif response.status_code == 401:
                return {
                    "status": "error",
                    "error": "Authentication failed. Check your credentials and ensure they haven't expired.",
                }
    
            else:
                return {
                    "status": "error",
                    "error": f"API request failed with status {response.status_code}",
                    "response_text": (
                        response.text[:500]
                        if hasattr(response, "text")
                        else "No response text"
                    ),
                }
    
        except Exception as e:
            return {
                "status": "error",
                "error": f"Failed to read backtest chart: {str(e)}",
                "project_id": project_id,
                "backtest_id": backtest_id,
                "chart_name": name,
            }
  • Invocation of register_backtest_tools(mcp) which defines and registers the read_backtest_chart tool (via nested @mcp.tool() decorator) with the FastMCP server instance.
    register_backtest_tools(mcp)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool returns 'chart data or loading status', hinting at possible async behavior, but fails to detail critical aspects like authentication requirements, rate limits, error conditions, or data format specifics.

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

Conciseness4/5

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

The description is well-structured with a brief purpose statement followed by organized parameter and return sections. It's appropriately sized, though the 'Returns' section could be slightly more detailed given the output schema exists.

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 read operation with an output schema, the description covers parameters thoroughly but lacks behavioral context (e.g., permissions, errors). The presence of an output schema reduces the need to detail return values, but without annotations, more operational guidance would be beneficial.

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

Parameters5/5

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

Given 0% schema description coverage, the description fully compensates by explaining all 6 parameters with clear semantics, including examples (e.g., 'Strategy Equity' for 'name'), defaults ('count: 100'), and optionality. It adds significant value beyond the bare schema.

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 ('Read chart data') and resource ('from a backtest'), distinguishing it from sibling tools like 'read_backtest' or 'read_live_chart'. It precisely identifies what the tool does without being vague or tautological.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'read_backtest' or 'read_live_chart'. It lacks context about prerequisites, such as whether the backtest must be completed, or any exclusions for its use.

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/taylorwilsdon/quantconnect-mcp'

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