Skip to main content
Glama

get_order_history

Retrieve formatted order history from Alpaca trading platform to track open, closed, or all orders for portfolio analysis.

Instructions

Get order history from Alpaca. Args: status: "all", "open", or "closed" Returns: Formatted order history

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNoall

Implementation Reference

  • The core implementation of the get_order_history tool. This function retrieves orders from the Alpaca broker based on the specified status ('all', 'open', or 'closed'), formats the most recent 10 orders into a readable string, and handles errors appropriately.
    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 tools) to the MCP server via the register_tools helper function.
    register_tools( [place_order, cancel_order, get_positions, flatten, get_order_history], "Execution" )
  • server.py:13-13 (registration)
    Import statement in the MCP server file that brings in the get_order_history function for registration.
    from tools.execution import place_order, cancel_order, get_positions, flatten, get_order_history

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