
Explore Alpaca's commission-free, API-only platform and see how API trading replaces terminals with direct broker-to-exchange connections. Learn about paper trading, US stocks focus, and benefits of faster, scalable execution.
Sign up for Alpaca to access commission-free API, free testing, real market data, and paper trading with $100,000 fake money; verify via email and generate API keys.
Explore how http and WebSocket connections establish sessions, the pull-versus-push data flow, and how Alpaca's API delivers static and streaming market data.
Install the Anaconda distribution, use the Anaconda Prompt or terminal to install packages with pip or conda, and open Spyder or Jupiter notebook to write and run Python code.
Connect to Alpaca api with Python requests and the proper endpoint. Create and store headers from your api key and secret, then authenticate.
Explore the differences between Alpaca API v1 and v2 for historical and streaming market data, with introductions, updated code, and guidance for navigating both endpoints.
Explore how to extract historical data with Alpaca's data API, compare five-exchange coverage with Polygon data, and preview available market data such as candles and last trade for algorithmic strategies.
Explore extracting historical bar data with Alpaca's data API by configuring the correct endpoint, time frame, symbols, and parameters like limit, then format the JSON response for analysis.
Convert json data to a pandas data frame, rename columns to time, open, high, low, close, and volume, parse unix timestamps, and set time as index with New York time.
Create a reusable function to fetch required bar data from Alpaca, accepting symbols, time frame, and limit to return a dictionary of per-symbol data frames in a clean format.
Learn to fetch the last traded price and volume for a symbol using Alpaca's last trade API, build the endpoint, and parse the JSON response.
Explore how the last quote API mirrors the last data endpoint, returning level one data with bid price, ask price, bid size, and ask size, but no depth.
Fetch historical data iteratively for symbols using a time-based loop and Python's time module. Use start time, timeout, and sleep to align data updates with regular intervals for indicator-based strategies.
Explore Alpaca's historical data v2 API for bars, including the new limit parameter and next page token, and understand the differences from v1 data and plan implications.
Implement historical data v2 API workflow on Alpaca by fetching symbol bars with start time. Loop with next page tokens, convert JSON to pandas, and convert timestamps to Eastern Time.
Build a v2 API data extractor for multiple symbols, returning a dict of dataframes with open, high, low, close, and volume; resample 1-minute candles to 5-minute bars with pandas.
Place market and limit orders with Alpaca's API using post requests, including symbol, quantity, side, type, time in force, and limit price, and learn to manage orders.
Understand stop orders and stop limit orders on Alpaca, including stop price and limit price, and how triggers affect market or limit executions for stop loss strategies.
Learn how trailing stop loss orders on Alpaca automatically adjust your stop level as prices move, preserving upside while protecting downside, using trail price or percentage parameters.
Explore bracket orders that combine take profit and stop loss in a single order, creating a three-leg setup (main order, take-profit sell, stop-loss) with cancellation if any leg is canceled.
Learn to retrieve Alpaca orders with a simple GET call, filter by status (default open) and symbol, set limits, and convert results into a data frame for easy analysis.
Cancel open or specific orders on Alpaca's platform using the delete endpoint. Learn to cancel all open orders or a single order by ID, and test with limit orders.
Replace an open Alpaca order by patching it with a dictionary of updated parameters (quantity, time and force, limit price, stock price, trailing stop) and use the order id.
Fetches position information from Alpaca's API using a simple get call, returning all open positions or a symbol-specific position, and explains unrealized PNL, BNL, and long/short indicators.
Learn how to delete or close all or specific positions on Alpaca without the order API, enabling intraday close with a kill switch using cancel_orders, symbol, and quantity parameters.
Learn to fetch your Alpaca account information with the get_account API call, and read equity, long/short values, and the pattern day trader flag.
Introduction to alpaca's python api library, comparing the native client with python requests, highlighting official support and predefined functions like get_position and place_order, and noting limited python documentation.
Install the Alpaca trade API for Python, authenticate with your key id and secret, create an API object, and retrieve your account information and positions, including equity.
Fetch Alpaca historical data using get_basehead to retrieve candles and get_last_rate or get_last_code for prices and trades, and handle bar objects while converting to data frames.
Learn to fetch historical data with Alpaca's v2 API using get bars, returning a data frame with open, high, low, close, volume, and vwap, plus time frame and adjustment options.
Place and manage trades with Alpaca's trade api by using submit_order to execute market, limit, stop loss, and trailing stop orders.
Explore Alpaca market data streaming via WebSocket to access last traded price and volume, bid/ask, and minibars (open, high, low, close, volume) with up to 30 trade and quote channels.
Create a Python-based market data streaming client with the WebSocket library, authenticate to Alpaca, and subscribe to trade, quote, and minute streams for Apple, Tesla, Google, and Facebook.
Stream real-time market data with Alpaca's V2 API by connecting via web socket, authenticating, and subscribing to trade, quote, and bar streams for selected symbols.
Store streaming tick data in a sql database to support strategies; create per-ticker tables with timestamp, price, and volume, using a cursor and commits, parsing streams to name tables.
Create a database and blank tables, parse alpaca tick messages to JSON. Extract table name, timestamp, price, and volume, convert nanoseconds to seconds, and resolve duplicate timestamps by adding milliseconds.
Expand the Alpaca streaming app to store both trade and quote data for Apple, Tesla, Google, and Amazon in two databases, capturing timestamp, bid and ask prices and volumes.
Stream text into a lightweight sqlite database, then connect from the terminal to query and explore Apple, Tesla, Google, and Amazon data with sql commands and filters during pre-market.
Learn to convert tick data from a database into candlestick data by resampling with pandas, creating open-high-low-close and volume for one-minute candles.
Implement streaming data based trading strategies with a multithreaded WebSocket setup, mastering signals, position sizing, and risk management while navigating Alpaca’s 30-channel limit and potential lag.
Understand Python memory management and how memory is allocated for objects and the interpreter. Then grasp multithreading basics with a two-thread example and the global interpreter lock.
Explore daemon threads in Python, where background programs run with the main script and terminate when it ends, and learn to set a thread as daemon in the trading module.
Configure multithreading using an event object to run a number-generation function and a greetings function concurrently, using event flags to stop the generation when the greeting completes.
Identify top movers by streaming last traded prices to flag winners and losers with a 2% threshold from the prior close, then place trailing stop orders during open-market momentum.
Implement a 30 tech-stock scanner that streams data via websocket and uses historical data to compare last price with yesterday’s close, computing daily percentage gains or losses.
Build a live top movers scanner on Alpaca's platform by streaming trade data via WebSocket, updating last traded price, previous close, and percentage change across 25 tickers.
Transform the starter code into a real-time strategy using a multi-threaded scanner, real-time price and percentage data, and threshold-driven signals, while addressing alpaca’s order, latency, and time-in-force constraints.
Implement a top movers strategy by tracking traded tickers, applying a two percent threshold, and sizing positions up to three thousand dollars using the Alpaca Python client with trailing stops.
Demonstrates a live Alpaca strategy demo trading Facebook, PayPal, Apple, and Adobe, fixes a short-position quantity bug, and shows a five-minute run with market orders, trailing stops, and websocket streaming.
Explore technical indicators: what they are, why we use them, and how to call them in Python from historical price, volume, and open interest data to confirm trends.
Learn how to integrate Alpaca with the TradingView charting platform, access charts, and apply simple and exponential moving averages to interpret price action on a five-minute chart.
Learn how the MACD uses 12 and 26 day moving averages to form the MACD line and a 9 day signal line, with the histogram highlighting crossovers and trend signals.
Implement macd from a dictionary of bar data (open, high, low, close, volume) across tickers, using fast and slow exponential moving averages and a nine-period signal line in pandas.
Learn Bollinger bands and average true range, volatility indicators using moving averages, standard deviation, and price ranges to quantify volatility and confirm signals, with chart examples and Python demos.
Compute true range as the max of high minus low, high minus previous close, and low minus previous close, then apply a 14 EMA to ADR.
Implement the Bollinger Band function using a 20-day simple moving average and two standard deviations on closing prices. Learn rolling calculations, default period handling, and optional standard deviation parameter.
Learn the basics of the relative strength index (RSI), a momentum oscillator that measures price momentum and flags overbought or oversold conditions with 70/30 levels, and its chart application.
Explore implementing RSI for algorithmic trading on Alpaca, deriving average gain and loss from historical data, applying an exponentially weighted moving average with alpha 1/period to compute RSI.
Learn the adx, the average directional index, to quantify trend strength from 0 to 100 across bands, its non-directional nature, and how directional movement of highs and lows informs trading.
Learn to compute ADX in Excel using true range and directional movement, derive DI plus and DI minus, and apply 14-period smoothing for a clear ADX workflow.
Implement an adx index in python using alpaca's api, computing plus dm and minus dm, applying ema to calculate adx, and align results with trading view methodology.
Analyze how the stochastic oscillator measures price momentum using the highest high and lowest low over a lookback period to compute percent gain, signaling overbought or oversold conditions.
Implement stochastic oscillator on Alpaca data by pulling historical data, computing lowest low and highest high over a look-back, then deriving percent K and its smoothed percent D.
Backtesting uses historical data and interactive brokers to test trading rules under simulated real-world conditions, highlighting slippage, costs, and the need to test before deployment.
Learn to compute CAGR over a standard one-year period from ending and starting values using (ending/beginning)^(1/year)-1, with Python, historical returns, and cumulative product.
Compute and annualize volatility from daily or weekly returns using standard deviation, and use the Sharpey ratio to assess return relative to risk, incorporating a risk-free rate.
Analyze maximum drawdown as the key risk metric by computing cumulative max and drawdown percentage from backtested equity, guiding risk management in algorithmic trading.
Explore intraday performance metrics, including absolute return, win rate, mean return per trade (positive and negative), and maximum consecutive loss, and their role in intraday backtesting.
Implement intraday kpis by tracking trade-level data, recording entry and exit prices, and computing win rate, mean return for winning trades, mean return for losing trades, and max consecutive losses.
Back test a template long-only strategy using EMCDDA and stochastic indicators, focusing on oversold conditions, MACV line crossovers, and trailing stops on Alpaca.
Implement backtesting of a template strategy using technical indicators in Python. Filter historical data to intraday hours, and build structures for signals, returns, trades, and high watermark for KPI analysis.
Backtest a strategy by computing macd crossovers and stochastic indicators on historical data, initializing per-ticker trade data, and using the next period open price for buy signals.
implement backtesting of a long-only strategy with trailing stop loss and high watermark logic, updating signals and trade data, and calculating period returns.
Backtest your strategy with general KPIs like CAGAR, Sharpey, and maximum drawdown, while addressing data consistency and the caveat that these metrics suit longer horizons, not intraday trading.
Compute intraday kpis by calculating per-ticker entry and exit prices, absolute and cumulative returns, and per-ticker win rates and mean/loss metrics in backtesting a long-only strategy.
Convert your backtested intraday strategy into an Alpaca trading routine by pruning code, importing the Alpaca API, and running a main function that generates signals, places trades, and manages positions.
convert a backtested strategy into a deployable Alpaca trading strategy by using historical data, emcd da and stochastic signals, managing positions, and placing market orders with trailing stops.
Explore algorithmic trading on Alpaca's platform with a strategy demo testing one-minute candles and historical data, triggering trades on MSCI crossover and oversold stochastic signals in Google, Apple, and Microsoft.
Alpaca has revolutionized trading by providing a commission free, API only stock trading platform. This course will help you gain thorough understanding about Alpaca's API and learn how to use it to implement trading strategy. The course will help you understand key concepts pertaining to API architecture (REST/HTTPS based API, Websocket connection etc.) and will prepare you well to build complex trading strategies on Alpaca's platform. You do not have to create a trading account with Alpaca to explore their API, as they also provide an excellent paper trading account which can help you test your strategies as well.
You can expect to gain the following skills from this course
What, Why & How of API trading
Alpaca's API fundamentals
Extracting historical data
Harnessing streaming tick level data
Incorporating technical indicators using python
Integrating Alpaca with TradingView charting
Backtesting strategies
End to End strategy design and deployment
Using multithreading to implement streaming data based strategies
Sqlite database management
Backtesting strategies
Deploying and running strategies on cloud (AWS EC2)
#############################################################################################
Important note - Course prerequisites:
Please note that this course requires basic python proficiency. At the minimum, you should be comfortable with:
basic python data types and format
basic python data structures such as list, dictionary, tuple etc.
how to create python functions
how to implement loops in python
installing and importing libraries
In addition, basic familiarity with finance/trading concepts is also required. Although, I have devoted reasonable time explaining concepts like technical indicators, strategy design, KPIs, risk management etc., some prior experience using these concepts would be very beneficial.
#############################################################################################