Skip to content

Welcome to the Virtual Project Gallery

OF GRACE CHURCH SCHOOL'S CLASS OF 2023

  • Home
  • Class of 2022 Projects
  • Class of 2023 Projects

The Algorithm That Beats the Market?

Posted on May 3, 2021 by Eleanor Semel 1 Comment on The Algorithm That Beats the Market?


Project Summary

Joel Greenblatt, an investor, published a book titled “The Little Book That Beats the Market.” This book details a quantitative investment formula he developed which he claims, as implied by the title, beats the market. For my March Madness project, I wanted to test the accuracy of this formula by coding his algorithm in Python, answering the question, “does Joel Greenblatt’s formula beat the market?” This project would explore an intersection between finance and computer programming, two topics which I have an interest in. This past summer, I attended a summer class where I learned about the stock market. This class furthered my interest in finance, specifically quantitative investment strategies involving computer algorithms, another topic I am interested in and have been for a few years. In order to answer my driving question, I coded an algorithm in Python that would take as an input most of the 500 stocks in the S&P 500 index, which more or less reflects the performance of the market, and outputs the ten best stocks according to Greenblatt’s formula. The algorithm then compares the return of the best ten stocks to that of the index over the course of two holding periods: one year and ten years. If the return of the best ten stocks is higher than the index, the formula works and beats the market. In order to gain a more accurate perception, I made it so that the algorithm would run on the data of each day since 1997. I started the project with an optimistic mindset. I was expecting that The Little Book That Beats the Market would beat the market, considering the book’s good reputation. However, after running my code, I was surprised to find that Greenblatt’s formula did not beat the market. Despite most of the returns from 1998 to present day being positive, the returns were, on average, lower than the market (as shown in the charts). This result was consistent across both one year and ten years period. Confused, I went back and checked for any errors in my code. Errors are hard to catch and even the smallest of errors could throw off your entire code. After a lot of patience and trial and error, I fixed a lot of my errors. I ran the code again only to find that the algorithm still hadn’t beat the market. Right before my project was due, I developed a hypothesis: the reason my code may not have beat the market was because it was tested on the current S&P 500 index rather than a yearly updated version of the index. In the future, I plan on adjusting my code to fit this hypothesis. Maybe this code will beat the market! From the data I gathered, I concluded that Greenblatt’s formula, on average, does not beat the current S&P 500. However, although it does not beat the market, it may be less risky than longing the market. For example, during the financial crisis and the market crash in 2008, the best 10 stocks according to Greenblatt’s formula saw a significantly lower decrease in value when compared to the entire index. Overall, completing my March Madness project was a pleasant experience which I enjoyed a lot. I would like to continue learning about investment strategies as well as become a better computer programmer. I hope that, in the future, I can eventually develop an algorithm that more accurately beats the market.

Project Images

Missing Attachment
Posted in Uncategorized Tagged coding, eleanor, finance, investing, programming, python, semel, stocks, tech

Post navigation

← The World of Mechanical Keyboards
The Halo Effect – The Psychology of First Impressions →

Author: Eleanor Semel

1 thought on “The Algorithm That Beats the Market?”

  1. Mr. Leonard says:
    May 10, 2021 at 11:44 am

    Very cool that you were able to do this Eleanor! I’m very impressed!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 Welcome to the Virtual Project Gallery | Design by ThemesDNA.com