Skip to main content
Glama

read_backtest_orders

Retrieve order data from a backtest by specifying project ID, backtest ID, and index range. Returns a dictionary with order details and total count for analysis.

Instructions

Read orders from a backtest.

Args: project_id: ID of the project containing the backtest backtest_id: ID of the backtest to read orders from start: Starting index of orders to fetch (default: 0) end: Last index of orders to fetch (default: 100, max range: 100)

Returns: Dictionary containing orders data and total count

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
backtest_idYes
endNo
project_idYes
startNo

Implementation Reference

  • The handler function that executes the 'read_backtest_orders' tool. It validates the input range (max 100 orders), authenticates with QuantConnect, sends a POST request to the 'backtests/orders/read' API endpoint, and returns the orders data with total count or error information.
    @mcp.tool() async def read_backtest_orders( project_id: int, backtest_id: str, start: int = 0, end: int = 100 ) -> Dict[str, Any]: """ Read orders from a backtest. Args: project_id: ID of the project containing the backtest backtest_id: ID of the backtest to read orders from start: Starting index of orders to fetch (default: 0) end: Last index of orders to fetch (default: 100, max range: 100) Returns: Dictionary containing orders data and total count """ auth = get_auth_instance() if auth is None: return { "status": "error", "error": "QuantConnect authentication not configured. Use configure_auth() first.", } # Validate range if end - start > 100: return { "status": "error", "error": "Range too large: end - start must be less than or equal to 100", } if start < 0 or end < 0: return { "status": "error", "error": "Start and end indices must be non-negative", } if start >= end: return { "status": "error", "error": "Start index must be less than end index", } try: # Prepare request data request_data = { "projectId": project_id, "backtestId": backtest_id, "start": start, "end": end, } # Make API request response = await auth.make_authenticated_request( endpoint="backtests/orders/read", method="POST", json=request_data ) # Parse response if response.status_code == 200: data = response.json() # Note: This API doesn't appear to have a "success" field based on the spec orders = data.get("orders", {}) length = data.get("length", 0) return { "status": "success", "project_id": project_id, "backtest_id": backtest_id, "start": start, "end": end, "orders": orders, "length": length, "message": f"Successfully retrieved {length} orders from backtest {backtest_id} (range: {start}-{end})", } 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 orders: {str(e)}", "project_id": project_id, "backtest_id": backtest_id, "start": start, "end": end, }
  • The registration call for backtest tools module in the main entry point, which includes the read_backtest_orders tool among others.
    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