Skip to main content
Glama

get_order_history

Retrieve formatted order history from Alpaca to track trading activity and analyze past transactions for portfolio management.

Instructions

Get order history from Alpaca.

Args:
    status: "all", "open", or "closed"
    
Returns:
    Formatted order history

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNoall

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function that retrieves order history from the Alpaca broker. It fetches orders based on the provided status ('all', 'open', or 'closed'), limits to the 10 most recent, formats them nicely, and returns as a string.
    def get_order_history(status: str = "all") -> str:
        """
        Get order history from Alpaca.
        
        Args:
            status: "all", "open", or "closed"
            
        Returns:
            Formatted order history
        """
        if broker is None:
            return "ERROR: Alpaca broker not initialized."
        
        try:
            orders = broker.get_orders(status)
            
            if not orders:
                return f"No {status} orders found."
            
            msg = [f"=== {status.upper()} ORDERS ({len(orders)}) ==="]
            for order in orders[:10]:  # Limit to 10 most recent
                msg.append(
                    f"{order['symbol']}: {order['side'].upper()} {order['qty']} "
                    f"({order['type']}, {order['status']}) - {order['submitted_at']}"
                )
            
            if len(orders) > 10:
                msg.append(f"\n... and {len(orders) - 10} more orders")
            
            return "\n".join(msg)
        except Exception as e:
            logger.error(f"Get order history failed: {e}")
            return f"ERROR: Failed to get order history - {str(e)}"
  • server.py:375-378 (registration)
    The registration of the get_order_history tool (as part of the Execution category) to the FastMCP server using the register_tools helper function.
    register_tools(
        [place_order, cancel_order, get_positions, flatten, get_order_history],
        "Execution"
    )
  • app.py:288-288 (registration)
    Inclusion of get_order_history in the tools_map dictionary under 'Execution' category for the Gradio UI toolbox.
    "Execution": [place_order, cancel_order, get_positions, flatten, get_order_history],
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 the return is 'Formatted order history' but does not specify if this is read-only, requires authentication, includes pagination, or has rate limits, leaving significant gaps for a tool that likely accesses sensitive order data.

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 brief and structured with 'Args' and 'Returns' sections, making it easy to parse. It could be slightly more front-loaded by stating the purpose more prominently, but it is efficient with minimal waste.

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 has an output schema, the description does not need to detail return values. However, for a tool with no annotations and low schema coverage, it lacks information on authentication, error handling, or behavioral traits, making it only minimally adequate.

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

Parameters3/5

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

The description adds meaning by explaining the 'status' parameter values ('all', 'open', or 'closed'), which is not covered in the input schema (0% schema description coverage). However, it does not elaborate on the implications of these statuses or other potential parameters, so it partially compensates but not fully.

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 'Get' and resource 'order history from Alpaca', making the purpose evident. However, it does not explicitly differentiate from sibling tools like 'get_positions' or 'place_order', which prevents a perfect score.

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, such as 'get_positions' for current holdings or 'place_order' for new orders. The description lacks context for usage decisions.

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/N-lia/MonteWalk'

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