US Bankruptcies and the S&P 500 - Market Analysis Hands-On with Python
Introduction
Lets look at US non-business bankruptcies and its relationship to the S&P 500. Welcome to another market analysis hands-on with Python video. MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=f0Krmmo2mAw Signup for my newsletter and more: http://www.viralml.com Connect on Twitter: https://twitter.com/amunategui Check out my book on Amazon The Little Book of Fundamental Market Indicators https://amzn.to/2DERG3d Transcript Hello YouTube Friends This is another market analysis hands-on with Python video. In this episode, we are going to look at US non-business bankruptcies - it isnt a super fun data set, like cancer or crime but there is an interesting relationship with the market that I think is interesting to note. This is the final product, the final chart I will show you how to create. Welcome to the ViralML Show, my name is Manuel Amunategui. I am the author of a few books including a new one that will be out at the end of the month The Little Book of Fundamental Indicators where I share my favorite hands-on market analysis fundamental indicators and data sets. Things like the S&P500, unemployment, real estate, CPI, VIX, etc. Please signup for my newsletter to get early access to my material. Subscribe to the channel - and give it a big thumbs up, pretty please! As usual, the link to the Jupiter notebook is included in the description of this video. There is some manual labor involved in gathering all the needed data. I already did all that work for you up to 2018 and included it in the corresponding Jupyter notebook for this chapter. Navigate to the “Caseload Statistics Data Tables” page on the United States. Courts website1. Follow the same selections as per the screenshots below.1 https://www.uscourts.gov/statistics-reports/caseload-statistics-data-tables CATEGORY:Finance HASCODE:ViralML-Hands-On-Market-Analysis-Bankruptcy-Filings.html
Code
from IPython.display import Image
Image(filename='viralml-book.png')
US Bankruptcy and the S&P 500¶
https://www.uscourts.gov/statistics-reports/caseload-statistics-data-tables
And the S&P500 index (^GSPC):
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import io, base64, os, json, re
import pandas as pd
import numpy as np
import datetime
from random import randint
# get the SP500 (^GSPC) from Yahoo Finace
gspc_df = pd.read_csv('^GSPC.csv')
gspc_df['Date'] = pd.to_datetime(gspc_df['Date'])
gspc_df = gspc_df[['Date', 'Adj Close']]
gspc_df.columns = ['Date', 'SP500_Value']
gspc_df['SP500_pct_change'] = gspc_df['SP500_Value'].pct_change()
gspc_df.head()
Create Bankruptcy Filings data set and assign actual date¶
year_ls = [str(y) + '-12-31' for y in range(2001, 2019)]
total_noncom_filings = [1452030,1539111,1625208,1563145,2039214,597965,822590,
1074225,1412838,1536799,1362847,1181016,1038720,909812,
819760,770846,765863,751186]
bankruptcy_filings = pd.DataFrame({'Date':year_ls, 'Filings': total_noncom_filings})
bankruptcy_filings['Date'] = pd.to_datetime(bankruptcy_filings['Date'])
cut_off_date = '2001-01-01'
gspc_df = gspc_df[gspc_df['Date'] >= cut_off_date]
bankruptcy_filings.head()
# join both datasets together
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(gspc_df['Date'], gspc_df['SP500_Value'], '-b', label='S&P500')
plt.legend()
plt.grid()
ax.tick_params('vals', colors='r')
# Get second axis
ax2 = ax.twinx()
plt.plot(bankruptcy_filings['Date'], bankruptcy_filings['Filings'], linewidth=2, color='black', label='Filings')
plt.legend()
plt.title('Bankruptcy Filings vs S&P 500')
ax2.tick_params('vals', colors='b')
Show Notes
(pardon typos and formatting -these are the notes I use to make the videos)
Lets look at US non-business bankruptcies and its relationship to the S&P 500. Welcome to another market analysis hands-on with Python video. MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=f0Krmmo2mAw Signup for my newsletter and more: http://www.viralml.com Connect on Twitter: https://twitter.com/amunategui Check out my book on Amazon The Little Book of Fundamental Market Indicators https://amzn.to/2DERG3d Transcript Hello YouTube Friends This is another market analysis hands-on with Python video. In this episode, we are going to look at US non-business bankruptcies - it isnt a super fun data set, like cancer or crime but there is an interesting relationship with the market that I think is interesting to note. This is the final product, the final chart I will show you how to create. Welcome to the ViralML Show, my name is Manuel Amunategui. I am the author of a few books including a new one that will be out at the end of the month The Little Book of Fundamental Indicators where I share my favorite hands-on market analysis fundamental indicators and data sets. Things like the S&P500, unemployment, real estate, CPI, VIX, etc. Please signup for my newsletter to get early access to my material. Subscribe to the channel - and give it a big thumbs up, pretty please! As usual, the link to the Jupiter notebook is included in the description of this video. There is some manual labor involved in gathering all the needed data. I already did all that work for you up to 2018 and included it in the corresponding Jupyter notebook for this chapter. Navigate to the “Caseload Statistics Data Tables” page on the United States. Courts website1. Follow the same selections as per the screenshots below.1 https://www.uscourts.gov/statistics-reports/caseload-statistics-data-tables CATEGORY:Finance HASCODE:ViralML-Hands-On-Market-Analysis-Bankruptcy-Filings.html