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

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],

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