Skip to main content
Glama

get_positions

Retrieve current portfolio positions and cash balance for trading strategy analysis and portfolio management.

Instructions

Retrieves the current state of all held positions and cash balance. Returns: Dict with 'cash' and 'positions' keys

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that executes the get_positions tool logic, retrieving account cash, equity, buying power, and current positions from the Alpaca broker.
    def get_positions() -> Dict[str, Any]: """ Retrieves the current state of all held positions and cash balance. Returns: Dict with 'cash' and 'positions' keys """ if broker is None: return { "error": "Alpaca broker not initialized. Check your API credentials.", "cash": 0, "positions": {} } try: account = broker.get_account() positions_raw = broker.get_all_positions() # Convert to simple format: {symbol: qty} positions = { symbol: details['qty'] for symbol, details in positions_raw.items() } return { "cash": account['cash'], "equity": account['equity'], "buying_power": account['buying_power'], "positions": positions } except Exception as e: logger.error(f"Failed to get positions: {e}") return { "error": str(e), "cash": 0, "positions": {} }
  • server.py:375-378 (registration)
    Registers the get_positions tool (along with other execution tools) to the MCP server using the register_tools helper.
    register_tools( [place_order, cancel_order, get_positions, flatten, get_order_history], "Execution" )
  • app.py:288-288 (registration)
    Includes get_positions in the tools_map for the Gradio UI toolbox under Execution category.
    "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