Giter VIP home page Giter VIP logo

webclinic017 / price-momentum-backtesting Goto Github PK

View Code? Open in Web Editor NEW

This project forked from timrivoli/price-momentum-trader

0.0 0.0 0.0 1.28 MB

This project uses Stock-Price-Trade-Analyzer to back-test the permformance of an investment strategy of picking only the top 9 performing stocks from the S&P 500 over a period of 35 years to answer the question "How well does past performance predict future returns?"

License: GNU General Public License v3.0

Python 100.00%

price-momentum-backtesting's Introduction

This project demonstrates how to use https://github.com/TimRivoli/Stock-Price-Trade-Analyzer to evaluate a trading idea by backtesting the results with historical data.

We are all familiar with the saying "Past results are no guarantee of future returns." While that is definitely true, I wanted to see how well a trading model would do if it only took into consideration a stocks price performance for the past 12 months. For my selection of stocks I am picking from the largest 70 stocks on the S&P 500. I will pick nine stocks from that list that have had the greatest price gain in the past year, and only stocks that have increased by at least 5% in the past year. The model will buy those stocks, hold them for 30 days, then sell them all, select another set of 9 stocks, and buy those stocks repeating until the end of the testing period. Each testing period is one year. Every year from 1982 to 2017 will be tested and then the results evaluated.

For a benchmark to compare my model against, I use hypothetical model of shares of the ^SPX index and which are held for the duration of the test. My estimate is that this would yield an average annual return of 9.6% from 1982 to 2017. In the long run, it is very hard to beat a Buy and Hold strategy of good stocks held for the long term, particularly if they are large capital stocks from the S&P 500.

So, how does my model compare? In the best year (1999), it makes 136% more than the benchmark, the worst year (1996) it loses 12.74% more, on average it makes 19.34% more than the benchmark of 9.6%. If I adjust to to only hold the top 5 stocks, then it makes another 3.51% per year on average. If I drop it to two stocks the returns go even higher. While past returns are not an guarantee of future returns, they are a very good indicator of future returns.

Have fun and keep programming!

-Tim

price-momentum-backtesting's People

Contributors

timrivoli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.