Command-line trading made simple. Execute trades, monitor positions, and manage your portfolio directly from your terminal using Alpaca's powerful API.
For developers and traders who want:
- β Speed: Execute trades faster than clicking through a web interface
- β Automation: Script your trading strategies with simple shell commands
- β Transparency: See exactly what commands are being run
- β Control: Manage everything from your terminal without context switching
- β Safety: Test with paper trading before risking real money
What makes this different:
Unlike GUI-based trading platforms, apcacli gives you programmatic access to your Alpaca account through a clean, efficient command-line interface. Perfect for developers, algorithmic traders, and terminal enthusiasts.
# Install Rust (if needed - skip if already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install apcacli
cargo install apcacli
# Verify it works
apcacli --help- Sign up at Alpaca Markets (free account)
- Navigate to your dashboard
- Generate paper trading API keys (no credit card required)
- Copy your
APCA_API_KEY_IDandAPCA_API_SECRET_KEY
# For Paper Trading (start here - it's free and safe!)
export APCA_API_KEY_ID='your_paper_key_id'
export APCA_API_SECRET_KEY='your_paper_secret_key'
# Add to your shell profile for persistence
echo "export APCA_API_KEY_ID='your_paper_key_id'" >> ~/.zshrc
echo "export APCA_API_SECRET_KEY='your_paper_secret_key'" >> ~/.zshrc# Check your account
apcacli account get
# See if the market is open
apcacli market clock
# You're ready to trade! π- Execute market, limit, stop, and trailing-stop orders
- Buy and sell stocks, ETFs, options, and crypto
- Cancel orders individually or in bulk
- Close positions partially or completely
- View all open positions with real-time P/L
- Check account balance and buying power
- Track daily and total profit/loss (color-coded!)
- Review position history
- Get asset information and availability
- Check market clock and trading hours
- Search for symbols
- Access real-time quotes through Alpaca's API
- Stream account events (orders, fills, updates)
- Monitor trade executions live
- Track portfolio changes in real-time
- Shell completion for faster command entry
- Scriptable automation for strategies
- Session management for multiple accounts
- Output formatting (JSON, colored text)
# 1. Check your buying power
apcacli account get
# 2. Verify the market is open
apcacli market clock
# 3. Buy $1000 worth of AAPL at market price
apcacli order submit buy AAPL --value 1000
# 4. Confirm your position
apcacli position listWhat just happened?
- You checked your account had funds available
- You verified the market was open (trades only execute during market hours)
- You submitted a market order for $1000 worth of Apple stock
- You confirmed the position appeared in your portfolio
# Buy 10 shares of Microsoft, but only if price drops to $420
apcacli order submit buy MSFT --quantity 10 --limit-price 420
# Check if your order is still open
apcacli order list
# Cancel it if you change your mind
apcacli order cancel <ORDER_ID>Why limit orders? Market orders execute immediately at current price (fast but unpredictable). Limit orders only execute at your specified price or better (slower but controlled).
# You own 10 shares of AAPL and want to protect gains
# Set a trailing stop 5% below the current price
apcacli order submit sell AAPL --quantity 10 --trail-percent 5
# If AAPL drops 5% from its peak, your shares auto-sell
# But if it keeps rising, the stop price rises with itRisk management 101: Never hold a position without a stop loss. Trailing stops let you capture upside while limiting downside.
#!/bin/bash
# Save as ~/check-portfolio.sh
echo "π Daily Portfolio Report - $(date)"
echo "ββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "π° Account Status"
apcacli account get
echo ""
echo "π Open Positions"
apcacli position list
echo ""
echo "π Recent Activity"
apcacli account activity | head -10# Make it executable
chmod +x ~/check-portfolio.sh
# Run daily
~/check-portfolio.sh| What You Want | Command |
|---|---|
| Account & Balance | |
| View account details | apcacli account get |
| Check account activity | apcacli account activity |
| Market Data | |
| Check if market is open | apcacli market clock |
| Get asset info | apcacli asset get SYMBOL |
| Search for symbol | apcacli asset search QUERY |
| Trading | |
| Buy with $ amount | apcacli order submit buy SYMBOL --value AMOUNT |
| Buy X shares at market | apcacli order submit buy SYMBOL --quantity X |
| Buy with limit price | apcacli order submit buy SYMBOL --quantity X --limit-price PRICE |
| Sell shares | apcacli order submit sell SYMBOL --quantity X |
| Set trailing stop | apcacli order submit sell SYMBOL --quantity X --trail-percent 5 |
| Order Management | |
| List all orders | apcacli order list |
| Get order details | apcacli order get ORDER_ID |
| Cancel an order | apcacli order cancel ORDER_ID |
| Cancel all orders | apcacli order cancel-all |
| Portfolio | |
| List positions | apcacli position list |
| Get position details | apcacli position get SYMBOL |
| Close position | apcacli position close SYMBOL |
| Close all positions | apcacli position close-all |
| Monitoring | |
| Stream account events | apcacli stream account |
| Stream trades | apcacli stream trades |
ALWAYS start with paper trading:
- Paper trading uses fake money - perfect for learning
- You get $100,000 virtual cash to experiment with
- All features work exactly like live trading
- Zero risk, full learning
Before going live:
- Test all commands with paper trading
- Understand order types (market vs limit vs stop)
- Know the risks of trading
- Never invest money you can't afford to lose
- Set stop losses on every position
- Double-check symbols and quantities
Security:
- Never share your API keys
- Store keys in environment variables, never in code
- Use paper keys for testing, live keys only for real trading
- Verify
APCA_API_BASE_URLis correct before trading
Once published on ClawdHub, users can install this skill with:
# Install the skill
clawhub install alpaca-trading
# Install the underlying tool
cargo install apcacli
# Set up API keys
export APCA_API_KEY_ID='your_key'
export APCA_API_SECRET_KEY='your_secret'Manual installation:
# Clone or copy to your skills directory
cp -r alpaca-trading ~/.clawdbot/skills/| Requirement | Details | How to Get |
|---|---|---|
| apcacli | The CLI tool itself | cargo install apcacli |
| Rust 1.71+ | Required to install apcacli | rustup.rs |
| Alpaca account | Free paper or funded live | alpaca.markets |
| API keys | APCA_API_KEY_ID + APCA_API_SECRET_KEY |
Generate in Alpaca dashboard |
Solution: Install apcacli with cargo install apcacli. Make sure ~/.cargo/bin is in your PATH.
Solution: Export your environment variables:
export APCA_API_KEY_ID='your_key'
export APCA_API_SECRET_KEY='your_secret'Possible causes:
- Market is closed (check
apcacli market clock) - Insufficient buying power (check
apcacli account get) - Invalid symbol (verify with
apcacli asset get SYMBOL) - Account restrictions
# Paper (default - no URL needed)
export APCA_API_KEY_ID='pk_...'
export APCA_API_SECRET_KEY='sk_...'
# Live (set URL to production)
export APCA_API_BASE_URL='https://api.alpaca.markets'
export APCA_API_KEY_ID='LIVE_KEY'
export APCA_API_SECRET_KEY='LIVE_SECRET'- apcacli Repository - Full documentation and source code
- Alpaca Docs - Trading platform documentation
- API Reference - Complete API specifications
- Paper Trading Dashboard - Web interface for your paper account
- apca Rust Crate - The underlying library powering apcacli
- apcacli issues: GitHub Issues
- Alpaca support: support@alpaca.markets
- Alpaca community: Alpaca Forum
Skill Type: CLI Tool Integration Tool: apcacli (Rust-based Alpaca CLI) Created for: ClawdHub / Claude Code License: GPL-3.0 (following apcacli's license)
Credits:
apcaclicreated by d-e-s-o- Built on the
apcaRust crate for Alpaca API interactions - Skill documentation by the ClawdHub community
This skill provides tools for trading financial instruments. Trading involves substantial risk of loss.
- This skill is educational and informational only
- Not financial advice - do your own research
- Start with paper trading to learn risk-free
- Only trade with money you can afford to lose
- Understand the risks before trading real money
By using this skill, you acknowledge that trading decisions are your own responsibility.
Ready to start? Install apcacli and get your free paper trading account today! π