How to place your first paper trade from Python with Alpaca (no real money)
The safest way to learn trading automation is to send orders that do not use real money. Alpaca's official Python SDK has a paper trading mode, so you can place a test order from code and see how an API behaves.
What you need
- Python 3.11 or newer (the SDK's requirement).
- alpaca-py, the official SDK, open source under Apache-2.0. Install it with
pip install alpaca-py. - Your Alpaca API keys for a paper account. Check Alpaca's official website for how to get them and for supported countries.
Step by step
- Create the client in paper mode. The SDK's example creates a
TradingClientwith your keys andpaper=True, so orders go to the simulated environment. - Describe the order. Build a
MarketOrderRequestwith the symbol, quantity, side and time in force. The project's own example buys a tiny amount of BTC/USD with a day order. - Send it. Pass the request to
submit_order()and print what comes back: you will see the order and its status. - Check it in your account. Open your paper account on Alpaca's site and confirm the order appears there.
- Keep the keys safe. Store them in environment variables, never inside the script you share or upload.
Ideas for what to do next
- Download price history for your tests, as in our CSV guide.
- Test the rule on past data first with the backtesting checklist.
- Get Telegram messages from a bot running in simulation, as in the Freqtrade dry-run guide.
Other ways to do it
Prefer another broker? Compare Alpaca, ib_async and Tradier using the data on their tool pages.
Good to know
Alpaca's public website does not list supported countries, so ask their support whether yours is accepted. A live account needs identity verification, and the brokerage is a commercial service: check the official website for current terms. A paper order is a technical test: it never promises results, and any example here is illustrative only.
See more ideas
Browse the use cases or the tool directory. Custom bots are coming soon: tell me when it opens.
Before you start
What does Alpaca (alpaca-py) cost and what licence does it use?
Check the official website. Licence: SDK under Apache-2.0; the brokerage account is a commercial service. Prices change, so check the official website before you decide.
What should I know before using Alpaca (alpaca-py)?
Its public website does not list supported countries: ask their support whether your country is accepted before opening an account. The SDK requires Python 3.11 or newer.
What does ib_async (Interactive Brokers) cost and what licence does it use?
Free (open source); your Interactive Brokers account has its own terms. Licence: BSD-2-Clause. Prices change, so check the official website before you decide.
What should I know before using ib_async (Interactive Brokers)?
Not official: the project explicitly states it is not affiliated with Interactive Brokers. Requires IB Gateway or TWS running with the API enabled: you have to keep that application up. Needs Python 3.11 or higher; the separate ibapi package is not needed. Version 3.0 is the only supported one; 2.x is unsupported after December 2026, and from December 2026 API connections require TWS / IB Gateway 10.51 or later. Upgrading from 2.x changes some APIs (see the migration guide in the repo).
What does Tradier cost and what licence does it use?
Lite $0/mo ($0.35 per stock trade and options contract), Pro $10/mo, Pro Plus $35/mo ($0 commissions); regulatory fees extra. Licence: Commercial brokerage service. Prices change, so check the official website before you decide.
What should I know before using Tradier?
Regulatory, exchange and clearing fees still apply on top of commissions. Check eligibility for your country of residence before applying. Other listed fees include a $50 yearly inactivity fee for accounts with fewer than 2 trades a year, and a $9 assignment/exercise fee on Lite and Pro ($5 on Pro Plus). Lite also has a $30 yearly IRA fee, and the desktop app is not included in Lite.
Tools in this guide
- Alpaca (alpaca-py): Alpaca's official Python SDK to trade stocks, crypto and options via API and download market data.
- ib_async (Interactive Brokers): Python library to connect to Interactive Brokers through TWS or IB Gateway; successor of the popular ib_insync.
- Tradier: US broker built around an API, with commission-based or subscription plans and API access included on every plan.
Compare your options
- schwab-py vs tastytrade SDK vs Tradier: which US stock and options API fits you?
- Alpaca vs ib_async vs Tradier: which broker API to automate US stocks?
Want a bot like this when custom bots open? Get notified · more bot ideas
Coming soon: custom bots
We are preparing a service to code, backtest and automate trading and statistics bots to your own rules. It is not available yet: follow our Telegram channel to know when it opens.