Quick answer
alpaca-py is Alpaca’s official Python SDK, replacing the older alpaca-trade-api package. It provides typed request models and clients for trading (TradingClient), historical data (StockHistoricalDataClient, CryptoHistoricalDataClient, options) and live WebSocket streams, with paper=True for Alpaca’s free paper account.
alpaca-py at a glance
- Category
- Broker, exchange & data libraries
- Language
- Python
- License
- Apache-2.0
- Does
- Market data, Order execution, Paper trading
- Markets
- Stocks, ETFs, Options, Crypto
- Best for
- US stock, options and crypto automation on Alpaca.
- In AlgoGP
- Use the exported strategy object from your own code
Pick it if
US stock, options and crypto automation on Alpaca.
Watch out for
Alpaca only.
alpaca-py strengths and limitations
Strengths
- Official, typed SDK.
- Free paper trading.
- Stocks, options and crypto in one API.
Limitations
- Alpaca only.
- Free data plan is IEX-only for real-time stocks.
alpaca-py example
pip install alpaca-pyfrom alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce
client = TradingClient("KEY_ID", "SECRET", paper=True)
client.submit_order(MarketOrderRequest(symbol="AAPL", qty=1, side=OrderSide.BUY, time_in_force=TimeInForce.DAY))Use alpaca-py with AlgoGP
AlgoGP does not add alpaca-py to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from alpaca-py yourself.
- 1
Design and backtest in AlgoGP
Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.
- 2
Add any bridge to get the adapter core
Adding a bridged framework (for example Backtrader) writes
frameworks/algogp_bridge.py, whoseStrategyBridge.on_bar()returns the orders the strategy wants. - 3
Call it from alpaca-py
Feed alpaca-py’s bars to
StrategyBridge, place the returned orders with alpaca-py, and report fills back withsync().
alpaca-py connects to Alpaca. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.
alpaca-py: frequently asked questions
Do I need alpaca-py for AlgoGP?
No. AlgoGP’s exported code has a built-in standard-library Alpaca adapter; alpaca-py is useful for your own extensions.
alpaca-py alternatives
- LumibotPythonBeginner-friendly Python framework from Lumiwealth: one Strategy class for backtesting and live trading stocks, options, futures and crypto.
- CCXTPython, JavaScript, TypeScript, PHP, C#, GoOne unified API for 100+ crypto exchanges in Python, JavaScript, PHP, C# and Go: market data, balances and orders with the same calls everywhere.
- ib_asyncPythonThe maintained successor of ib_insync: a Pythonic, asyncio-friendly client for the Interactive Brokers TWS API and IB Gateway.
- BlanklyPythonPython framework for writing one strategy and running it as a backtest, paper or live bot on Alpaca, Coinbase, Binance, Kraken and OANDA.
Independent guide. AlgoGP is not affiliated with alpaca-py. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.