Stock prices analysis with Python
Introduction
This page contains analysis of S&P500 stock prices with Python, collection of interesting findings and fun charts.
This data is only for fun purpose and should not be used for as main criteria for buying/selling stocks.
If you need more detailed analysis — check pdfs and Jupyter notebooks on my GitHub.
There will be two screenshots:
- first one is where all stock prices are compared with base price which is the first price in history
- second one is where stock prices are compared with base price which is first price within specific period(If we want to analyze weekdays then dataset is split into weeks/period and each Monday is base price for each week/period)
Which month do stock prices raise or fall in?
Period: 10 years, 2011–01–01 to 2021–01–01
Code example(If you need full code check GitHub link above):
Stocks go down in April, May and September.
Stock go up in August, October, November and December
Which week do stock prices raise or fall in?
Period: 10 years, 2011–01–01 to 2021–01–01
Stocks go down in weeks 22-23, 44, 52.
Stocks go up in weeks 7, 24, 46, 49
Which weekday do stock prices raise or fall in?
Period: 10 years, 2011–01–01 to 2021–01–01
Stocks go down on Wednesdays.
Stocks go up unknown.
Which day of a month do stock prices raise or fall in?
Period: 10 years, 2011–01–01 to 2021–01–01
Stocks go down on days 15, 23, 31.
Stocks go up on days 13, 20, 27, 30.
Which hour of a day do stock prices raise or fall in?
Period: 2019–06–01 to 2021–05–01 (Yahoo Finance is limited to 2 year history for 1 hour interval)
Stocks go down at 11, 14.
Stocks go up at 10, 13.
Which time of a day do stock prices raise or fall in?
Period: 2021–03–14 to 2021–05–11 (Yahoo Finance is limited to 2 months history for 15 mins interval)
NOTE: 0.25 means 15 mins, 0.5 means 30 mins, 0.75 means 45 mins
Stocks go down at 14:30.
Stocks go up at 12:45, 14:15, 15:00.
Short summary
You cannot predict prices and even strategy “Sell in May and go away” seems to contradict to this analysis.
Long summary
Here is a table with summary of my findings: