Video summary
Python Algorithmic Trading Course – Massive, SnapTrade & Alpaca Integrations
Main summary
Key takeaways
Technological concepts & system overview
- Goal: Build a Python algorithmic trading system from scratch that:
- Retrieves stock market data from Polygon / “Massive” (typo likely; “Massive” appears in subtitles) via API keys.
- Computes 12-month momentum indicators for a universe of ~50 stocks.
- Generates automated trading signals from momentum rankings.
- Executes trades using SnapTrade to connect to Alpaca in paper trading mode (risk-free).
Strategy logic (momentum)
- Calculate momentum using 12-month price performance, explicitly defined as:
- 12-month momentum = 12-month return excluding the last ~30 days
- Often called “12-1 momentum.”
- Rank stocks by momentum and identify:
- Top 10 (best momentum)
- Bottom 10 (worst momentum)
- Example action path in the app:
- Buy top-momentum names
- Shorting bottom-momentum is conceptually possible, but the described run results in buys only
- Signals can be regenerated using “current momentum data.”
Product features / platform integrations
1) SnapTrade integration (as middleware)
- Used for connecting the trading app to broker accounts through OAuth.
- SnapTrade setup steps:
- Create a SnapTrade account, confirm email
- Enable 2FA (Google Authenticator)
- Generate API keys (note: keys can’t be retrieved later)
- SnapTrade is used to:
- Connect the app’s portfolio/briefcase to Alpaca paper trading
- Place orders and query portfolio/order status through a planned SnapTrade SDK client wrapper in Python
2) Alpaca (paper trading broker)
- Configured via Alpaca paper accounts, allowing the strategy to run without depositing real money.
- Key emphasis from subtitles:
- There’s a paper trading balance (example: $100,000)
- Authentication is required (2FA)
- UI sections include positions, orders, balances, etc.
3) Massive (market data provider) integration
- Create a Massive account and obtain an API key.
- Python integration includes a Massive API client that:
- Fetches price data (OHLC-like + VWAP/volume depending on endpoint)
- Implements rate limiting: 5 requests per minute on the free tier
- Uses in-memory caching keyed by ticker + date range to avoid duplicate requests
- Key performance concept:
- Instead of requesting each ticker individually, it uses a bulk method based on Massive’s “Group Daily Aggs” endpoint to fetch many tickers at once
- Includes fallback/backup logic for missing data (e.g., weekends/market holidays) by searching nearby dates
Course guidance: setup, architecture, and implementation steps
A) SnapTrade + Alpaca “hands-on” walkthrough
- Build accounts:
- SnapTrade account + API keys + 2FA
- Massive API key
- Alpaca paper trading account + trading API registration
- Demonstrates an end-to-end loop:
- Create a portfolio/briefcase in the web app
- Connect it to Alpaca via SnapTrade OAuth
- Generate signals
- Submit buy orders (example: $100 notional per top-10 stock)
- Verify orders/positions in Alpaca UI
B) Local development environment (Django + Python)
- Uses Django as the web framework.
- Development flow:
- Clone repo (
nickmcculum/algorithmictrading, per subtitles) - Create Python project structure:
- Django project named “Momentum Trader”
- Django apps: trading and portfolio
- Clone repo (
- Environment tooling:
- Uses UV for dependency installation and virtual environments (UV venv)
- Adds
.gitignoreand avoids committing SQLite DB artifacts
C) Database modeling (Django ORM)
trading app models
Stock- ticker, name, sector, market cap, active flag
- created/updated timestamps
PriceData- FK to stock
- OHLC/volume-like fields; adjusted close; date
- timestamps
MomentumScore- momentum assessment fields + date calculation window bounds
- ranking/quintiles
TradingSignal- signal type (via enumerations)
- FK relationships to shares, momentum estimates
- target quantity/value, reason, performed date
RebalanceEvent- counts of buy/sell signals, total cost, portfolio status
- error messages, timestamps
portfolio app models
Portfolio/ “briefcase”- name/description/cash fields
- SnapTrade identifiers + secret
- timestamps
Position- FK to portfolio + stock
- current value/profit metrics
- uniqueness constraint for (portfolio + stock)
Trade- order representation: type, quantity, price, statuses, external identifiers
- status transition logic
MetricProductivity- performance metrics: daily/total income, winning/unprofitable deal counts
- unique per portfolio+date
D) Admin interface
- Creates a Django superuser and registers models in Django Admin for inspection and management of:
- portfolios/positions/trades
- stocks/price data/momentum scores/signals/rebalance events
- Mentions:
list_display, filtering/searching, andreadonly_fieldsfor better admin UX
Course logic: automation services
1) Massive “data acquisition” service
- Introduces a Massive API client with:
fetch_stock_data(single ticker date range)- cache support
- rate-limit method (sleep when exceeding queries-per-minute)
fetch_bulk_momentum_datausing grouped daily aggregates- backup method for missing dates (weekend/holiday handling)
2) SnapTrade “execution” service
- Introduces a SnapTrade client wrapper (described as “trading executor”) with planned methods:
- synchronization:
- sync portfolio positions
- sync balance sheets/cash
- execution:
- execute buy orders
- execute sell orders
- status updates:
- poll SnapTrade order status and update internal
Traderecords
- poll SnapTrade order status and update internal
- synchronization:
- Emphasizes storing external order IDs vs provider-specific IDs for portability.
3) Momentum strategy services
- Momentum calculator service:
- calculates momentum from prices in the DB (and can also pull from Massive)
- ranks stocks into quintiles/top-bottom groups
- stores momentum scores/ranks in the database
- Motor / strategy runner service:
- determines whether to rebalance (weekly/monthly timing logic)
- generates trade signals (buy top momentum; sell bottom momentum conceptually)
- executes trades through SnapTrade-connected portfolio
- includes a placeholder backtest function (explicitly “not yet built”)
Tutorial/testing and debugging notes
- Subtitles include multiple “app won’t work yet” fixes common to build-from-scratch tutorials, including:
- Migration warnings handled by running
makemigrationsandmigrate - Database reset during model changes (delete/recreate local DB)
- Import path fixes (e.g., trading model imports should come from
portfolio.models) - Added missing portfolio methods required by views (e.g.,
get_current_positions) - Duplicate/typo handling (e.g., “Google” appears twice in the generated buys)
- Migration warnings handled by running
- Testing flow described:
- Fill DB via a command like
backfill_data - Run “Count/List momentum”
- Run “Generate signals”
- Place orders and verify in Alpaca paper trading
- Fill DB via a command like
Key review / evaluation aspects mentioned
- Risk-free demonstration: uses Alpaca paper trading to validate signal generation and order submission.
- Performance/rate-limit compliance:
- implements query throttling (sleep) and caching for Massive free-tier limits
- uses bulk endpoints to reduce API calls for ~50 (and potentially more) tickers
- Extensibility:
- strategy parameters (e.g., “12 minus 1”) are stored in settings to support other momentum window strategies
Main speakers / sources
- Nick McCollum (course creator; leads the walkthrough after the intro)
- Katie (SnapTrade) (walks through SnapTrade account setup and API key/2FA steps)
- Primary documentation/products referenced:
- SnapTrade
- Massive (market data)
- Alpaca (paper trading + APIs)
- Course inspiration mentioned in subtitles:
- Quantitative Momentum / Quantitative Impulse (authors mentioned: Jack Vogel and Wes Gray)
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.