This blog was last updated on March 23, 2026.

How to Start Paper Trading with Alpaca

Paper trading allows you to simulate trading without financial risk, providing a way to test strategies and become familiar with Alpaca’s Trading API. However, paper trading results do not reflect actual market conditions and may differ significantly from live trading outcomes. This guide walks you through the process of how to place your first paper trade via python and the dashboard.

Looking for help on when to start live trading? Read our data-backed guide on paper trading vs live trading and when our users make the shift.

Prerequisites

  1. Alpaca's Trading API account
    1. You can receive your ALPACA_API_KEY and ALPACA_SECRET_KEY from your Alpaca dashboard
  2. Google Colab or Code Editor (IDE):
    1. Use your Google account to access Google Colab or run the code in your own IDE.

Placing Your First Paper Trade via Alpaca’s Trading API

Step 1: Fetch Your Alpaca’s Trading API Keys

  1. Log in to your Alpaca's Trading API account. If you haven’t created an account yet, you can sign up or use our “How to Connect to Alpaca’s Trading API” as an onboarding guide.
  2. In the upper-left corner, choose your “Paper Trading” account.
  3. Obtain Trading API Keys: Navigate to the API section to generate your API Keys.

Note: It’s important to write down or save your Secret Key in a secure place, as you will only have access to it once. If a new Secret Key is required, you can regenerate a new one. However, your current API Keys will be invalidated and you will need to re-establish your connection with your IDE.

Step 2: Set Up Google Colab

  1. Open Google Colab: Go to Google Colab in your browser.
  2. Create a new Notebook: Click the “New Notebook" button to initialize a Python environment.
  3. Set the API keys: ALPACA_API_KEY, ALPACA_SECRET_KEY in Google Colab's Secrets from the left sidebar.

Step 3: Initialize the Trading Client and Verify Connection

Install Dependencies and Import Libraries

We’ll use the uv Python package manager to install all the necessary packages before starting the backtesting process.

import os
import sys

import requests
from dotenv import load_dotenv

from alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce

Initialize Alpaca's Paper Trading Client

This section sets up the environment configuration keys for each working environment (flexibly adjusting for Google Colab or local IDEs) and initializes Alpaca clients.

The environment configuration automatically detects whether it's running in Google Colab or a local IDE and loads API keys accordingly.

if "google.colab" in sys.modules:
    # In Google Colab environment, we will fetch API keys from Secrets.
    # Please set ALPACA_API_KEY, ALPACA_SECRET_KEY in Google Colab's Secrets from the left sidebar
    from google.colab import userdata

    ALPACA_API_KEY = userdata.get("ALPACA_API_KEY")
    ALPACA_SECRET_KEY = userdata.get("ALPACA_SECRET_KEY")

else:
    # Please safely store your API keys and never commit them to the repository (use .gitignore)
    # Load environment variables from environment file (e.g., .env)
    load_dotenv()
    # API credentials for Alpaca's Trading API
    ALPACA_API_KEY = os.environ.get("ALPACA_API_KEY")
    ALPACA_SECRET_KEY = os.environ.get("ALPACA_SECRET_KEY")


# We use paper environment for this example
ALPACA_PAPER_TRADE = True  # Please do not modify this. This example is for paper trading only.

# Initialize the Alpaca client
trade_client = TradingClient(api_key=ALPACA_API_KEY, secret_key=ALPACA_SECRET_KEY, paper=ALPACA_PAPER_TRADE)

Fetch Account Information

Verify your setup by calling the get_account() method to retrieve your account details. This confirms that your API keys are configured correctly and that you are connected to your paper trading environment.

acct = trade_client.get_account()
acct

If the request succeeds, your account information will be returned, including your account number and status. This confirms a successful connection. 

{   'account_blocked': False,
    'account_number': 'XXXXXXXX',
    'accrued_fees': '0',
    'buying_power': '100000.0',
    'cash': '200000',
    'created_at': datetime.datetime(2024, 1, 3, 10, 00, 00, 40242, tzinfo=TzInfo(0)),
    'crypto_status': <AccountStatus.ACTIVE: 'ACTIVE'>,
    'currency': 'USD',
    'daytrade_count': 1,
    ...,
    'status': <AccountStatus.ACTIVE: 'ACTIVE'>,
    'trade_suspended_by_user': False,
    'trading_blocked': False,
    'transfers_blocked': False
}

If you receive error messages like HTTP 401 Error, it likely means your request was not authorized for the account you are trying to access. 

To resolve this:

  1. Make sure you are using the correct API key/secret pair for the environment you are calling (paper vs live)
  2. Make sure your credentials are sent using the exact required header names.

See the Alpaca’s Trading API Error Cheat Sheet: 30 Common Errors Explained and Troubleshot for details.

Step 4: Place a Paper Trade

Once you confirm the connection, use the Order API to submit a paper trading order. For example, You can buy one share of Apple (AAPL) using a market order by running the following code.

# preparing market order request
market_order_data = MarketOrderRequest(
                    symbol="AAPL",
                    qty=1,
                    side=OrderSide.BUY,
                    time_in_force=TimeInForce.DAY
                    )

# Market order
market_order = trade_client.submit_order(
                order_data=market_order_data
               )

Step 5: Check and Verify Your Paper Trade

To ensure your paper order was executed and to review the rest of your portfolio, you can run the following code.

# Get a list of all of our positions.
portfolio = trade_client.get_all_positions()

# Print the quantity of shares for each position.
for position in portfolio:
    print("{} shares of {}".format(position.qty, position.symbol))

Alternatively, You can check the trade in real time on the Portfolio, Orders, and Activity pages.

You are now ready to start paper trading with Alpaca's Trading API. This setup allows you to test your algorithmic trading strategies risk-free.

Placing Your First Paper Trade via Alpaca’s Dashboard

Step 1: Log in to Your Account

Log in to your account and navigate to the “Home” page.

Step 2. Find Your Desired Trade

On your dashboard in the top left, you can select between using your paper trading or live accounts. It’s important that you select the appropriate trading account before implementing an options strategy. 

Once you’ve selected the desired account within your dashboard, use the search bar to find and select the applicable symbol.

NOTE: We are using SPY as an example and it should not be considered investment advice.

Step 3. Set Order Parameters to Open a Position

On the asset’s page, select your desired order parameters, including:

  • Symbol
  • Side: buy or sell
  • Quantity
  • Order type: market, limit, stop, stop_limit, trailing_stop
  • Time in force (TIF): DAY, GTC (Good-Till-Canceled), OPG (At the Open), CLS (At the Close), IOC (Immediate Or Cancel), FOK (Fill or Kill)

See the Create an Order section in the API reference for detailed field definitions and constraints. Please note that opg and cls orders are only available to Elite Smart Router users.

NOTE: We now offer 24/5 Trading for stocks. Read “How to Use 24/5 Trading with Alpaca’s Trading API and Dashboard” for more information. 

When selecting certain order types, such as Limit, you will also need to choose your trading session from "24 hour market" or "Regular hours".

Press the "Buy" button to place the “Buy” order and your paper trading account will then mimic the execution of the order as though it were a real transaction.

Step 4. Close Your Position

Closing a position involves selling the symbol that you previously bought (in a long position) or buying back the assets that you previously sold (in a short position). Either action terminates, or “liquidates”, your associated position.

If you’d like to close your position, find the desired asset on your “Home” page or under “Positions.” Click on the appropriate contract symbol and select the “Liquidate” button.

You’ll then be prompted to confirm. Confirm you want to close (liquidate) the position.

You are now ready to start paper trading from Alpaca's dashboard. The paper account allows you to test your manual trading strategies risk-free.

Key Differences Between Paper Trading API vs Live Trading API

While paper trading can be used to become familiar with the codebase and test a platform, there are several differences to be aware of before transitioning to live trading, if you choose to do so.

  • Real Market vs Simulation: Live orders match against actual market liquidity. Paper orders are filled by a simulation model.
  • Slippage and Partial Fills: In live trading, execution price and fill size depend on real time supply and demand. Paper trading does not fully reflect those constraints.
  • Borrow Fees and Margin Interest: Short positions and margin balances generate real costs in live accounts. Paper accounts do not apply these charges.
  • Single Live Account vs Multiple Paper Accounts: Paper Trading allows up to 3 distinct simulated accounts with separate balances and positions, while live trading runs through a single approved brokerage account.

Please note that paper trading does not reflect actual market conditions, and results may differ significantly from live trading outcomes. Live trading involves risk, including the potential loss of principal.

Read our complete list of the differences between paper trading and live trading among Alpaca's Trading API users.

Conclusion

With your Paper Trading API account, you can simulate trading U.S. stocks, ETFs, crypto, and options in a test environment. Paper trading does not reflect actual market conditions and may not account for factors such as slippage, liquidity, or execution delays.

If you choose to transition to live trading, you can open a live trading account and fund it. All investing involves risk, including the possible loss of principal.

We’ve included guides below that explain this process for informational purposes only.

Additionally, if you are trading via python, there are some common errors that you might experience. To understand what they mean, read Alpaca’s Trading API Error Cheat Sheet: 30 Common Errors Explained and Troubleshot.

If you’d like to learn more about setting up your account and trading with Alpaca’s Trading API or TradingView, explore the resources below.

Frequently Asked Questions

How do I enable paper trading in Alpaca?

Log in to your Alpaca's Trading API account, switch to the Paper Trading account, generate your paper API keys, and if you are using the Python SDK, set paper=True when creating TradingClient.

How do I get my Alpaca's paper Trading API key?

Create or sign in to your account at https://app.alpaca.markets/account/login, select the Paper Trading account, then use the dashboard API Keys panel to generate and copy your Key and Secret.

How do I start API trading?

You need Alpaca's Trading API keys from the Alpaca dashboard at https://app.alpaca.markets/account/login. Then use Google Colab or your own IDE to start trading with your API keys. You can find the tutorials at https://alpaca.markets/learn and example code at https://github.com/alpacahq/alpaca-py/tree/master/examples

Is the Alpaca's Trading API free?

Commission free trading is available to Alpaca's retail customers. Commission free trading means that there are no commission charges for Alpaca self-directed individual cash brokerage accounts that trade U.S.-listed securities and options through an API. However, certain arrangements with authorized business partners or the use of the Elite Smart Router as part of the Alpaca Elite offering may preclude commission free trades by Alpaca Securities. Please refer to the Brokerage Fee Schedule for more information. Relevant regulatory fees may apply. Alpaca reserves the right to charge additional fees if it is determined that order flow is non-retail in nature. Fee details: https://alpaca.markets/disclosures/commission-fees Docs: https://docs.alpaca.markets/docs/trading-api

Is Alpaca good for beginners?

If you want to start algorithmic trading, Alpaca can be a good starting point. See the API docs at https://docs.alpaca.markets/docs/trading-api, Learn articles at https://alpaca.markets/learn, and example code at https://github.com/alpacahq/alpaca-py/tree/master/examples.


Please note that this article is for educational and informational purposes only. All screenshots are for illustrative purposes only. Alpaca does not recommend any specific securities or investment strategies.

The Paper Trading API is offered by AlpacaDB, Inc. and does not require real money or permit a user to transact in real securities in the market. Providing use of the Paper Trading API is not an offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, given or in any manner endorsed by AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate and the information made available through the Paper Trading API is not an offer or solicitation of any kind in any jurisdiction where AlpacaDB, Inc. or any AlpacaDB, Inc. affiliate (collectively, “Alpaca”) is not authorized to do business.

Commission free trading is available to Alpaca's retail customers. Commission free trading means that there are no commission charges for Alpaca self-directed individual cash brokerage accounts that trade U.S.-listed securities and options through an API. However, certain arrangements with authorized business partners or the use of the Elite Smart Router as part of the Alpaca Elite offering may preclude commission free trades by Alpaca Securities. Please refer to the Brokerage Fee Schedule for more information. Relevant regulatory fees may apply. Alpaca reserves the right to charge additional fees if it is determined that order flow is non-retail in nature.

Past hypothetical backtest results do not guarantee future returns, and actual results may vary from the analysis.

All investments involve risk, and the past performance of a security, or financial product does not guarantee future results or returns. There is no guarantee that any investment strategy will achieve its objectives. Please note that diversification does not ensure a profit, or protect against loss. There is always the potential of losing money when you invest in securities, or other financial products. Investors should consider their investment objectives and risks carefully before investing.

Options trading is not suitable for all investors due to its inherent high risk, which can potentially result in significant losses. Please read Characteristics and Risks of Standardized Options before investing in options.

Cryptocurrency is highly speculative in nature, involves a high degree of risks, such as volatile market price swings, market manipulation, flash crashes, and cybersecurity risks. Cryptocurrency regulations are continuously evolving, and it is your responsibility to understand and abide by them. Cryptocurrency trading can lead to large, immediate and permanent loss of financial value. You should have appropriate knowledge and experience before engaging in cryptocurrency trading. For additional information, please click here.

Securities brokerage services are provided by Alpaca Securities LLC (dba "Alpaca Clearing"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.

Cryptocurrency services are made available by Alpaca Crypto LLC ("Alpaca Crypto"), a FinCEN registered money services business (NMLS # 2160858), and a wholly-owned subsidiary of AlpacaDB, Inc. Alpaca Crypto is not a member of SIPC or FINRA. Cryptocurrencies are not stocks and your cryptocurrency investments are not protected by either FDIC or SIPC. Please see the Disclosure Library for more information.

This is not an offer, solicitation of an offer, or advice to buy or sell securities or cryptocurrencies or open a brokerage account or cryptocurrency account in any jurisdiction where Alpaca Securities or Alpaca Crypto, respectively, are not registered or licensed, as applicable.