Skip to main content
Glama

liquidate_live_algorithm

Close all open positions in a running live trading algorithm to exit the market and secure current holdings.

Instructions

Liquidate all positions in a live algorithm.

Args: project_id: ID of the project with the live algorithm to liquidate

Returns: Dictionary containing liquidation result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function for the 'liquidate_live_algorithm' tool, decorated with @mcp.tool(). It authenticates, prepares a POST request to QuantConnect's 'live/update/liquidate' endpoint with the project_id, and returns success/error responses based on the API result.
    @mcp.tool()
    async def liquidate_live_algorithm(project_id: int) -> Dict[str, Any]:
        """
        Liquidate all positions in a live algorithm.
    
        Args:
            project_id: ID of the project with the live algorithm to liquidate
    
        Returns:
            Dictionary containing liquidation result
        """
        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}
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="live/update/liquidate", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    return {
                        "status": "success",
                        "project_id": project_id,
                        "message": f"Successfully liquidated live algorithm for project {project_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Live algorithm liquidation failed",
                        "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 liquidate live algorithm: {str(e)}",
                "project_id": project_id,
            }
  • Invocation of register_live_tools(mcp) in the main entry point, which defines and registers the liquidate_live_algorithm tool (along with other live tools) using FastMCP decorators.
    register_live_tools(mcp)
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'liquidate all positions' which implies a destructive financial operation, but doesn't specify whether this is reversible, what permissions are required, potential financial consequences, or rate limits. The description is insufficient for a tool with significant financial implications.

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 efficiently structured with a clear purpose statement followed by Args and Returns sections. Every sentence serves a purpose with zero waste, making it easy to parse and understand quickly.

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 this is a destructive financial operation with no annotations and an output schema exists (so return values are documented elsewhere), the description is minimally adequate. However, for a tool that liquidates all positions in a live algorithm, more context about irreversible consequences, confirmation requirements, or financial impact would be expected.

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?

With only 1 parameter and 0% schema description coverage, the description compensates well by clearly explaining what 'project_id' represents ('ID of the project with the live algorithm to liquidate'). This adds meaningful context beyond the bare schema, though it could specify format expectations or validation rules.

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 action ('Liquidate all positions') and target resource ('in a live algorithm'), providing specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'stop_live_algorithm' or explain how liquidation differs from stopping an 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 about when to use this tool versus alternatives like 'stop_live_algorithm' or what prerequisites exist. The description only states what the tool does without context about appropriate usage scenarios or exclusions.

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