Python and Alpaca API

Automated Stock Trader

3.36% increase in 10 days
0.38% average S&P 500 increase

Live paper trading

Alpaca paper trading dashboard showing portfolio performance.
Alpaca dashboard during the live strategy6 test.

Project snapshot

I used Alpaca's API and my personal strategies written in Python.

I built an automated stock trader that gathered historical market data, tested strategies against that data, and then connected the final version to live Alpaca data.

The materials I used are:

  • Alpaca's API
  • Python
  • Historical stock data
  • Strategy backtesting
  • Live paper trading data

Code

Python code

I began with learning the basics of stocks and stock trading.

Then I began with gathering past data from Alpaca to see if I could find any patterns. This is when I began creating strategies to test on historical data.

Apple stock chart used while gathering past market data.
Apple stock data used while looking for patterns.

I compared my results from different strategies.

Backtesting results chart used to compare strategy performance.
Backtesting results from the different strategies.

Once I chose my final strategy (strategy6) I connected it to live data. I was able to earn a 3.8% increase in 10 days, while the average increase is 0.38% on the S&P 500.

Alpaca orders page showing filled buy and sell orders from the automated trader.
Filled orders from the live paper-trading run.