Coder Social home page Coder Social logo

mayest / market-timing Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 626 KB

A Jupyter Notebook that reproduces a Barron's article showing the results of being able to be out of the market for the worst five days of each year.

License: MIT License

Jupyter Notebook 100.00%

market-timing's Introduction

Market-Timing

Rewards of Perfect Market Timing

Timothy R. Mayes, Ph.D. (http://www.tvmcalcs.com)
1 January 2019


This code will calculate the rewards that can be had given great skill at market timing. It shows the value of a portfolio where the trader is good enough to be out of the market on the worst N days between the start and end dates. Obviously, this is not possible in reality, but it is interesting.

The impetus for this idea was “The Truth About Timing,” by Jacqueline Doherty, Barron’s (November 5, 2001). In order to replicate those results, load the data and then call the total_returns function as:

total_returns(data['1/1/1966':'10/29/2001'],5,invest=1).round(2)

Actually, the exact dates that were used isn't clear. The chart in the article says that it starts in Feb 1966, but the table implies that it starts at the beginning of 1966 (3 January 1966). Also, there may be some slight rounding or data issues that cause the results here to vary a bit from the results reported in the Barron's article.

Finally, note that you can substitute your own data (different index or stock, different time frame, whatever), but this is probably best used if you have complete data for each calendar year. That is because the calculations drop the n worst/best days by calendar year.

Data is from Yahoo! Finance as of 1 January 2019, and includes the daily adjusted close of the S&P 500 each day from 1 January 1950 to 31 December 2018. Reproduced Barron's Chart

You can run the Jupyter notebook in your browser without having Python or Jupyter installed on your computer by clicking the Binder button below.

Binder

market-timing's People

Contributors

mayest 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.