🧠 All Projects
📚

Alpaca API Integration - Dual Account Setup

P3 - Low
Reference Hedge

Alpaca dual account (Paper + Live) integration with separate credentials and services

Implementation

Hedge supports both Paper and Live Alpaca trading accounts with separate credentials.

Environment Variables

# Paper Account
ALPACA_PAPER_API_KEY=xxx
ALPACA_PAPER_SECRET_KEY=xxx

# Live Account  
ALPACA_LIVE_API_KEY=xxx
ALPACA_LIVE_SECRET_KEY=xxx

AlpacaClientManager

Singleton that manages both clients:

  • get_client(account_type) → Returns Paper or Live client
  • Auto-switches based on request parameter

Services

  • TradingService: Submit orders, get positions
  • MarketDataService: Real-time quotes, historical bars
  • NewsService: Market news feed

Tested & Working

  • Both accounts authenticate successfully
  • Market data streaming works
  • Account info retrieval works

Security Note

Henry explicitly requested: NEVER display live Alpaca API keys in logs, UI, or responses. Paper keys OK for debugging.

Created: Wed, Feb 18, 2026, 1:45 AM by bob

Updated: Wed, Feb 18, 2026, 1:45 AM

Last accessed: Wed, Apr 1, 2026, 11:56 PM

ID: b271540d-650a-49bc-b97f-d36e6c865e27