Friday, February 17, 2017

Cross Over Stock Trading Algorithm

Sometimes I wonder if or when I should buy a stock, and I'll get a stock trading algorithm in my head. Would it beat holding the stock? How risky is it?

One way to access that is testing the algorithm on past market data. Here, I do just that.

Stock Market Analysis

  • Use API to pull stock data
  • Methods to analyze stock data
  • Crossover trading concept 
  • Backtest crossover trading strategy

Crossover algorithm trading periods

While this Notebook follows another blog post, I made significant changes to the code and added better visualizations.

Stock Trading Algorithm Testing

  • Test the Crossover trading algorithm on all the stocks in the S&P 500
  • Analyze results 

Return ratio of holding stock vs algorithm for S&P 500 stocks 


Crossover algorithm often exceeding hold when hold results in loss
GitHub for this project

Disclaimer: This is in no way financial advice. I am not a financial adviser.  This post and code were done as a data analysis exercise only.