VibeTradingVibeTrading
Back to Blog
Also available in中文
TutorialsJuly 16, 202610 min read

Paper Trade a YouTube AI Trading Strategy on Alpaca

Take an AI trading strategy from YouTube and paper trade it safely on Alpaca. Setup, data, order logic, tracking, and Python snippets included.

#ai trading#youtube#alpaca#paper trading#tutorial
Risk Disclaimer: This content is for educational purposes only. Trading involves significant risk of loss. Past performance does not guarantee future results. Always do your own research before using any trading tool or strategy.

You found an AI trading strategy on YouTube that actually makes sense. The creator explained the rules clearly, showed some code, and did not promise guaranteed riches. The next safe step is not live trading. It is paper trading. This tutorial shows you how to take that YouTube strategy and run it on Alpaca's free paper trading environment.

Paper trading lets you test execution logic, catch bugs, and see how a strategy behaves under realistic market conditions without risking capital. It is not a perfect simulator, but it is far better than trusting a backtest or a video thumbnail. If you are completely new to this workflow, our AI trading for beginners guide is a good place to start.

What You Will Need

Before writing code, gather the basics:

RequirementRecommended OptionWhy
Broker accountAlpaca paper accountFree, API-first, US equities
API keysGenerated in Alpaca dashboardRequired for automated order submission
Python environment3.10 or newerModern SDK support
Data sourceAlpaca market dataMatches execution venue
Trade journalSpreadsheet or notebookCritical for tracking decisions

Install the required packages in a virtual environment:

python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install alpaca-py pandas python-dotenv

Create a .env file for your keys and add .env to .gitignore:

ALPACA_API_KEY=your_key_here
ALPACA_SECRET_KEY=your_secret_here

Never commit API keys to version control. Even paper trading keys should be treated carefully because they can reveal account information.

Step 1: Define the Strategy Clearly

Assume the YouTube strategy is a simple momentum breakout:

  • Watch the first 30 minutes of the trading day.
  • If price breaks above the 30-minute high, enter long.
  • Stop loss at the 30-minute low.
  • Close position at market close.

This is just an example. Substitute whatever rules the video actually describes. The important part is that every rule is precise enough to code.

Step 2: Fetch Intraday Data

Alpaca provides historical and live bars. Here is how to fetch recent 5-minute bars:

import os
from datetime import datetime, timedelta
from dotenv import load_dotenv
from alpaca.data.historical import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest
from alpaca.data.timeframe import TimeFrame
 
load_dotenv()
 
client = StockHistoricalDataClient(
    os.getenv("ALPACA_API_KEY"),
    os.getenv("ALPACA_SECRET_KEY"),
)
 
request = StockBarsRequest(
    symbol_or_symbols="AAPL",
    timeframe=TimeFrame.Minute,
    start=datetime.now() - timedelta(days=30),
    end=datetime.now(),
)
 
bars = client.get_stock_bars(request)
df = bars.df.reset_index()
print(df.head())

Run this code and inspect the output. Make sure timestamps, open, high, low, close, and volume are all present before moving to order logic.

Step 3: Build the Signal Generator

Now convert the strategy rules into a function. This function returns a target position for each bar:

def generate_signals(df):
    df = df.copy()
    df['date'] = df['timestamp'].dt.date
    
    # Identify first 6 bars of the day (5-min bars -> 30 minutes)
    df['bar_of_day'] = df.groupby('date').cumcount() + 1
    morning = df[df['bar_of_day'] <= 6].copy()
    
    # Calculate morning high and low per day
    morning_high = morning.groupby('date')['high'].max().rename('morning_high')
    morning_low = morning.groupby('date')['low'].min().rename('morning_low')
    df = df.merge(morning_high, on='date').merge(morning_low, on='date')
    
    # Signal: long after morning breakout
    df['signal'] = 0
    df.loc[df['close'] > df['morning_high'], 'signal'] = 1
    df.loc[df['close'] < df['morning_low'], 'signal'] = 0  # exit rule placeholder
    
    return df

This code is intentionally simple. In a real system you would add more rules, handle stop losses, and manage position sizing. The goal here is to show the pattern.

Step 4: Submit Paper Orders

Once you have a signal, submit orders to the Alpaca paper account:

from alpaca.trading.client import TradingClient
from alpaca.trading.requests import MarketOrderRequest
from alpaca.trading.enums import OrderSide, TimeInForce
 
trading_client = TradingClient(
    os.getenv("ALPACA_API_KEY"),
    os.getenv("ALPACA_SECRET_KEY"),
    paper=True,
)
 
def submit_paper_order(symbol, qty, side):
    order = trading_client.submit_order(
        order_data=MarketOrderRequest(
            symbol=symbol,
            qty=qty,
            side=OrderSide.BUY if side == "buy" else OrderSide.SELL,
            time_in_force=TimeInForce.DAY,
        )
    )
    return order

Call this function only when your signal changes. A common mistake is sending an order on every bar. The bot should trade when its target position changes, not every five minutes.

Step 5: Track Every Trade

A paper trade journal is essential. Record at least these fields:

FieldExampleWhy It Matters
Date2026-07-16Identifies market regime
SymbolAAPLTracks which assets you trade
Signal reasonMorning breakoutKeeps strategy honest
Entry price225.50Compare to backtest assumptions
Exit price227.10Computes actual PnL
Quantity10Position sizing data
Slippage estimate0.02Adjust backtest later
NotesLate entry due to gapExplains deviations

At the end of each week, compare your paper journal to your backtest. If live paper results are consistently worse, your backtest assumptions are too optimistic. Read our guide on the backtest vs live PnL gap for common reasons.

Step 6: Add Risk Rules Before Live Trading

Paper trading is safe, but it can create false confidence. Before moving to live capital, enforce these rules:

  • Maximum risk per trade: 1% to 2% of capital
  • Daily loss limit: stop trading after losing 3% in a day
  • Maximum open positions: avoid overconcentration
  • No overnight risk unless the strategy specifically requires it
  • Review every losing week before increasing size

These rules protect you from yourself. Automated execution does not remove the need for discipline.

Common Mistakes in Paper Trading

MistakeWhy It HurtsFix
Ignoring slippagePaper fills are unrealisticAdd slippage assumptions to results
Trading too oftenFees and noise eat edgesLimit trades to clear signals
Changing rules mid-testInvalidates the experimentDefine rules before the first trade
Using unrealistic sizeDistorts psychologyMatch paper size to planned live size
Quitting too earlyOne week is not a regimePaper trade across multiple conditions

Moving from Paper to Live

If your paper results are stable and realistic, you might consider a tiny live account. Increase size gradually:

  1. Trade 10% of planned live size for one month.
  2. Compare live PnL to paper PnL weekly.
  3. Only scale up if the live edge remains after costs.
  4. Keep a reserve for drawdowns.

For help building the full bot, see our first AI trading bot with EMA crossover and Alpaca paper trading tutorial.

Bottom Line

Paper trading a YouTube strategy on Alpaca is the responsible next step after watching a promising video. It turns vague inspiration into measurable execution. Most strategies will look worse on paper than in the video, and that is valuable information. The goal is not to confirm the video was right. The goal is to find out whether the idea survives contact with reality.


Related reading: Convert YouTube Strategy to Python Backtest, Backtest vs Live PnL Gap, First AI Trading Bot with Alpaca