Skip to main content
Glama

read_backtest_chart

Retrieve and analyze chart data from specific backtests on QuantConnect. Use the tool to access historical performance metrics, set time ranges, and extract key insights for strategy evaluation.

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
backtest_idYes
countNo
endNo
nameYes
project_idYes
startNo

Implementation Reference

  • The core handler function for the 'read_backtest_chart' tool. It authenticates with QuantConnect, prepares the request with project_id, backtest_id, chart name, count, and optional timestamps, calls the 'backtests/chart/read' API 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, }
  • Registration of backtest tools (including read_backtest_chart) by calling register_backtest_tools(mcp) during server initialization.
    register_file_tools(mcp) register_backtest_tools(mcp) register_live_tools(mcp) register_optimization_tools(mcp)
  • Alternative entry point registration of backtest tools (including read_backtest_chart) by calling register_backtest_tools(mcp).
    register_file_tools(mcp) register_backtest_tools(mcp) register_live_tools(mcp) register_optimization_tools(mcp)

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