Skip to main content
Glama

read_live_orders

Retrieve live trading orders from a QuantConnect algorithm to monitor execution status and manage positions in real-time.

Instructions

Read orders from a live algorithm.

Args: project_id: Project ID of the live algorithm start: Starting index of orders to fetch (default: 0) end: Last index of orders to fetch (default: 100, max range: 100)

Returns: Dictionary containing live algorithm orders data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
startNo
endNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'read_live_orders' tool. Decorated with @mcp.tool(), validates inputs, authenticates, makes API request to QuantConnect's live/orders/read endpoint, and returns orders data or error.
    @mcp.tool()
    async def read_live_orders(
        project_id: int, start: int = 0, end: int = 100
    ) -> Dict[str, Any]:
        """
        Read orders from a live algorithm.
    
        Args:
            project_id: Project ID of the live algorithm
            start: Starting index of orders to fetch (default: 0)
            end: Last index of orders to fetch (default: 100, max range: 100)
    
        Returns:
            Dictionary containing live algorithm orders data
        """
        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,
                "start": start,
                "end": end,
            }
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="live/orders/read", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    orders = data.get("orders", {})
                    length = data.get("length", 0)
    
                    return {
                        "status": "success",
                        "project_id": project_id,
                        "start": start,
                        "end": end,
                        "orders": orders,
                        "length": length,
                        "message": f"Successfully retrieved {length} orders from live algorithm {project_id} (range: {start}-{end})",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Failed to read live algorithm orders",
                        "details": errors,
                        "project_id": project_id,
                    }
    
            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 live algorithm orders: {str(e)}",
                "project_id": project_id,
                "start": start,
                "end": end,
            }
  • Registers all live trading tools, including 'read_live_orders', by calling register_live_tools(mcp) during MCP server initialization.
    register_live_tools(mcp)
  • Input schema defined by function parameters (project_id: int required, start/end: int optional defaults) and comprehensive docstring. Output is Dict[str, Any] with status, orders, etc.
    async def read_live_orders(
        project_id: int, start: int = 0, end: int = 100
    ) -> Dict[str, Any]:
        """
        Read orders from a live algorithm.
    
        Args:
            project_id: Project ID of the live algorithm
            start: Starting index of orders to fetch (default: 0)
            end: Last index of orders to fetch (default: 100, max range: 100)
    
        Returns:
            Dictionary containing live algorithm orders data
        """
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 a 'max range: 100' constraint, which is useful, but lacks details on permissions, rate limits, error handling, or what the returned dictionary contains. For a read operation with zero annotation coverage, this leaves significant gaps in understanding tool behavior.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded, with a clear purpose statement followed by structured 'Args' and 'Returns' sections. Every sentence adds value without redundancy, making it efficient and easy to parse.

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?

Given the tool's moderate complexity (3 parameters, no annotations, but with an output schema), the description is partially complete. It covers parameters well and notes the return type, but lacks behavioral context (e.g., safety, errors) and doesn't leverage the output schema to explain return values. It's adequate but has clear gaps in usage and transparency.

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

Parameters4/5

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

The description adds meaningful semantics beyond the input schema, which has 0% description coverage. It explains 'project_id' as 'Project ID of the live algorithm', clarifies 'start' and 'end' as indices with defaults and a max range, and notes that only 'project_id' is required. This compensates well for the schema's lack of descriptions, though it doesn't detail parameter formats or constraints beyond the range.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Read') and resource ('orders from a live algorithm'), making the purpose specific and understandable. It distinguishes itself from siblings like 'read_backtest_orders' by specifying 'live' context, though it doesn't explicitly contrast with other live-related tools (e.g., 'read_live_algorithm').

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?

No guidance is provided on when to use this tool versus alternatives. While the description implies usage for fetching live algorithm orders, it doesn't mention prerequisites (e.g., needing a running live algorithm) or compare it to similar tools like 'read_backtest_orders' or 'list_live_algorithms' for context.

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