Skip to main content
Glama

get_account_info

Retrieve detailed Alpaca account data such as equity, buying power, and day trade status for portfolio management and trading strategy development.

Instructions

Get detailed Alpaca account information including equity, buying power, and day trade status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • server.py:37-56 (handler)
    Primary MCP tool handler for 'get_account_info'. Decorated with @mcp.tool() for automatic registration. Retrieves and formats Alpaca brokerage account details including cash, equity, buying power, PDT status.
    @mcp.tool() def get_account_info() -> str: """ Get detailed Alpaca account information including equity, buying power, and day trade status. """ try: broker = get_broker() account = broker.get_account() return f""" === ALPACA ACCOUNT INFO === Cash: ${account['cash']:,.2f} Equity: ${account['equity']:,.2f} Buying Power: ${account['buying_power']:,.2f} Portfolio Value: ${account['portfolio_value']:,.2f} Pattern Day Trader: {account['pattern_day_trader']} Day Trade Count: {account['daytrade_count']} """ except Exception as e: return f"ERROR: Failed to get account info - {str(e)}"
  • AlpacaBroker.get_account() method called by get_account_info to fetch raw account data from Alpaca API.
    def get_account(self) -> Dict[str, Any]: """ Retrieve account information. Returns: Dict with keys: cash, equity, buying_power, portfolio_value """ try: account = self.trading_client.get_account() return { "cash": float(account.cash), "equity": float(account.equity), "buying_power": float(account.buying_power), "portfolio_value": float(account.portfolio_value), "pattern_day_trader": account.pattern_day_trader, "daytrade_count": account.daytrade_count } except Exception as e: logger.error(f"Failed to get account: {e}") raise
  • Singleton factory function get_broker() that provides the AlpacaBroker instance used in get_account_info.
    def get_broker() -> AlpacaBroker: """Get or create the Alpaca broker singleton.""" global _broker if _broker is None: _broker = AlpacaBroker() return _broker
  • server.py:37-56 (registration)
    The @mcp.tool() decorator registers get_account_info as an MCP tool.
    @mcp.tool() def get_account_info() -> str: """ Get detailed Alpaca account information including equity, buying power, and day trade status. """ try: broker = get_broker() account = broker.get_account() return f""" === ALPACA ACCOUNT INFO === Cash: ${account['cash']:,.2f} Equity: ${account['equity']:,.2f} Buying Power: ${account['buying_power']:,.2f} Portfolio Value: ${account['portfolio_value']:,.2f} Pattern Day Trader: {account['pattern_day_trader']} Day Trade Count: {account['daytrade_count']} """ except Exception as e: return f"ERROR: Failed to get account info - {str(e)}"
  • UI helper version of get_account_info used in Gradio dashboard.
    def get_account_info() -> str: try: broker = get_broker() account = broker.get_account() return f""" === ALPACA ACCOUNT INFO === Cash: ${account['cash']:,.2f} Equity: ${account['equity']:,.2f} Buying Power: ${account['buying_power']:,.2f} Portfolio Value: ${account['portfolio_value']:,.2f} Pattern Day Trader: {account['pattern_day_trader']} Day Trade Count: {account['daytrade_count']} """ except Exception as e: return f"ERROR: Failed to get account info - {str(e)}"

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