alpaca-py-cliAI agent skill for Alpaca Markets trading. Intelligent setup wizard (alpaca init) guides users through registration. Trade stocks/crypto, manage portfolios,...
Install via ClawdBot CLI:
clawdbot install zijunl/alpaca-py-cliInstall alpaca-py (pip3 install alpaca-py):
Install alpaca-py (pip3 install alpaca-py)Install pytz (pip3 install pytz):
Install pytz (pip3 install pytz)Requires:


Trade stocks and crypto programmatically via Alpaca's API using a Python-based CLI tool.
IMPORTANT - READ BEFORE USE:
This skill stores API keys as environment variables in your shell config file.
What happens during setup:
alpaca init displays registration steps for agent automationalpaca auth saves API keys to shell startup files (~/.zshrc, ~/.bashrc, or ~/.profile)Security considerations:
Recommended practices:
For agents:
alpaca auth (saves keys to shell config)alpaca init is safe to run - it only displays instructionsalpaca auth to save themLinks:


Trade stocks and crypto programmatically via Alpaca's API using a Python-based CLI tool.
Links:
Manage your Alpaca Markets trading account using the alpaca CLI tool and Python SDK. Supports both paper trading (simulated) and live trading.
# Install Homebrew Python 3.11+
brew install python@3.11
# Install alpaca-py
/opt/homebrew/bin/pip3.11 install alpaca-py pytz
pip3 install alpaca-py pytz
Note: System Python may show urllib3 warnings on macOS due to LibreSSL compatibility. Use Homebrew Python for a cleaner experience.
alpaca auth
This will interactively prompt you for:
The command automatically saves your credentials to your shell config file (~/.zshrc, ~/.bashrc, or ~/.profile).
Alternatively, set these in your shell profile manually:
export ALPACA_API_KEY="your_api_key"
export ALPACA_SECRET_KEY="your_secret_key"
export ALPACA_PAPER="true" # Use "false" for live trading
Get your API keys from https://alpaca.markets (Dashboard → API Keys)
Paper Trading (recommended for testing):
Live Trading (real money):
alpaca auth
Interactive setup wizard that guides you through:
alpaca account
Shows:
alpaca clock
Shows:
# Show next 30 trading days (default)
alpaca calendar
# Show next 7 trading days
alpaca calendar --days 7
Shows trading days with open/close times (Eastern Time).
# Default: 1 month, daily bars
alpaca history
# Last week
alpaca history --period 1W
# Last 3 months with hourly bars
alpaca history --period 3M --timeframe 1H
Periods: 1D, 1W, 1M, 3M, 1Y, all
Timeframes: 1Min, 5Min, 15Min, 1H, 1D
Shows:
alpaca positions
Shows all current holdings with:
# Single symbol
alpaca quote AAPL
# Multiple symbols
alpaca quote AAPL,TSLA,MSFT
Shows:
Note: Quotes may show incomplete data when market is closed. Best used during market hours (9:30 AM - 4:00 PM ET).
# Show open orders (default)
alpaca orders
# Show all recent orders
alpaca orders --status all
# Show last 20 closed orders
alpaca orders --status closed --limit 20
Shows:
# Buy shares
alpaca buy AAPL 10
# Sell shares
alpaca sell AAPL 5
Places a market order that executes at market price when market is open.
# Cancel specific order
alpaca cancel <order_id>
# Cancel all open orders
alpaca cancel-all
# Close specific position
alpaca close AAPL
# Close all positions (requires confirmation)
alpaca close-all
Note: close-all will prompt for confirmation before closing all positions.
# Configure credentials
alpaca auth
# Check account
alpaca account
# Check if market is open
alpaca clock
# Check current price
alpaca quote TSLA
# Check account balance
alpaca account
# Buy some shares
alpaca buy TSLA 5
# Check pending orders
alpaca orders
# View positions (after order fills)
alpaca positions
# Get updated quote
alpaca quote TSLA
# Sell some shares
alpaca sell TSLA 2
# Check order history
alpaca orders --status all
# View current positions
alpaca positions
# View portfolio history
alpaca history --period 1M
# Check market calendar
alpaca calendar --days 7
# Check all open orders
alpaca orders
# Cancel specific order
alpaca cancel <order_id>
# Cancel all orders
alpaca cancel-all
# Close specific position
alpaca close AAPL
# Close all positions
alpaca close-all
When a user wants to start trading but hasn't configured Alpaca yet, agents can automate the entire setup process using browser automation.
alpaca init - Displays clear registration stepsalpaca auth - Save the extracted keys to shell configUser: "I want to start trading stocks"
Agent:
1. Runs: alpaca init (gets registration steps)
2. Uses browser skill to:
- Open https://alpaca.markets
- Fill registration form with user info
- Verify email automatically
- Navigate to API Keys page
- Generate and extract keys
3. Runs: alpaca auth (with extracted keys)
4. Confirms: "✓ Setup complete! You have $100k in paper money."
alpaca init is non-interactive - just displays stepsalpaca auth requires user consent (modifies shell config)alpaca clock or alpaca accountWhen the user asks about their portfolio or wants to trade:
alpaca auth for first-time setupalpaca clock to see if market is openalpaca account to see current balance and buying poweralpaca positions to list current holdingsalpaca orders to see pending/recent ordersalpaca quote to check current pricesalpaca buy/sell to execute tradesalpaca cancel/close commands as neededALPACA_PAPER=true)alpaca auth to safely configure credentials (secret key is hidden)alpaca clock before trading to see if market is openaccount.buying_power before placing ordersTimeInForce.DAY to auto-cancel unfilled orders at market closealpaca positionsalpaca ordersalpaca historyalpaca cancel-all to quickly cancel all pending ordersalpaca close-all with caution (requires confirmation)US stock market hours (Eastern Time):
Orders placed outside market hours will be queued and executed when market opens.
Quotes may show incomplete or stale data when market is closed.
Use alpaca clock to check current market status.
If you see:
NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently using LibreSSL
Solution: Install and use Homebrew Python 3.11+ which uses OpenSSL:
brew install python@3.11
/opt/homebrew/bin/pip3.11 install alpaca-py pytz
Then update the script shebang to use Homebrew Python:
sed -i '' '1s|#!/usr/bin/env python3|#!/opt/homebrew/bin/python3.11|' ~/.openclaw/workspace/skills/alpaca-py-cli/scripts/alpaca
If you see:
ModuleNotFoundError: No module named 'pytz'
Solution:
pip3 install pytz
# or
/opt/homebrew/bin/pip3.11 install pytz
If alpaca command is not found, use the full path:
~/.openclaw/workspace/skills/alpaca-py-cli/scripts/alpaca
Or add to PATH in your shell config:
export PATH="$HOME/.openclaw/workspace/skills/alpaca-py-cli/scripts:$PATH"
~/.openclaw/workspace/skills/alpaca-py-cli/scripts/alpaca~/.zshrc (or ~/.bashrc, ~/.profile)See the "Automated Setup for Agents" section above for the complete workflow.
Quick summary:
alpaca init to see registration stepsalpaca auth to save keys (with user consent)alpaca clock or alpaca accountThe new alpaca init command is non-interactive and agent-friendly - it simply displays clear steps that an agent can follow using browser automation.
Generated Mar 1, 2026
A quantitative analyst uses the skill to backtest and deploy simple trading algorithms in a paper trading environment. They automate order execution based on market signals, leveraging the CLI's natural language commands to adjust positions and monitor portfolio performance without manual intervention, ideal for validating strategies risk-free.
A finance instructor integrates the skill into a classroom setting, allowing students to practice trading stocks and crypto with virtual money. Students learn market mechanics, portfolio management, and risk assessment through hands-on CLI interactions, enhancing their understanding of real-world trading dynamics.
An individual investor employs the skill to automate routine trades and rebalance their portfolio based on predefined criteria. They use the setup wizard to securely configure API keys and rely on paper trading by default to test automation scripts before applying them to live accounts, minimizing risk.
A startup team leverages the skill to quickly prototype a trading bot or financial dashboard, using the CLI's token-efficient design and runtime guidance. They iterate on features in a sandboxed paper trading environment, ensuring compliance and security before scaling to live markets.
A developer builds a custom bot that interfaces with the Alpaca API via this skill to trade cryptocurrencies. They utilize the natural language execution for flexible order management and the setup wizard to handle key configuration, focusing on automation while maintaining security through user consent.
A company offers a subscription-based platform that uses this skill to provide automated trading tools to retail investors. Revenue is generated through monthly fees for access to advanced features like strategy backtesting and real-time alerts, leveraging the paper trading default to onboard users safely.
An app developer creates a free educational tool that teaches trading basics using this skill's paper trading capabilities. Premium tiers unlock live trading integration, personalized analytics, and advanced CLI commands, driving revenue from upgrades and in-app purchases.
A consulting firm uses the skill to demonstrate trading strategies and portfolio management techniques to corporate clients. Revenue comes from service fees for customized implementations, training sessions, and ongoing support, utilizing the skill's setup wizard for secure client onboarding.
💬 Integration Tip
Ensure user consent is obtained before running the setup wizard to modify shell config files, and prioritize paper trading mode during initial integration to mitigate risks.
Analyze stocks and cryptocurrencies using Yahoo Finance data. Supports portfolio management, watchlists with alerts, dividend analysis, 8-dimension stock scoring, viral trend detection (Hot Scanner), and rumor/early signal detection. Use for stock analysis, portfolio tracking, earnings reactions, crypto monitoring, trending stocks, or finding rumors before they hit mainstream.
Get stock prices, quotes, fundamentals, earnings, options, dividends, and analyst ratings using Yahoo Finance. Uses yfinance library - no API key required.
Yahoo Finance (yfinance) powered stock analysis skill: quotes, fundamentals, ASCII trends, high-resolution charts (RSI/MACD/BB/VWAP/ATR), plus optional web a...
Become an autonomous prediction market trader on Polymarket with AI-powered analysis and a performance-backed token on Base. Trade real markets, build a track record, and let the buyback flywheel run.
Get cryptocurrency token price and generate candlestick charts via CoinGecko API or Hyperliquid API. Use when user asks for token price, crypto price, price chart, or cryptocurrency market data.
Trade and monitor Hyperliquid perpetual futures. Check balances, view positions with P&L, place/cancel orders, execute market trades. Use when the user asks about Hyperliquid trading, portfolio status, crypto positions, or wants to execute trades on Hyperliquid.