Hot off the Press!

The Little Book of Fundamental Market Indicators

My New Book: "The Little Book of Fundamental Analysis: Hands-On Market Analysis with Python" is Out!

Grow Your Web Brand, Visibility & Traffic Organically

The Little Book of Fundamental Market Indicators

5 Years of amunategui.github.Io and the Lessons I Learned from Growing My Online Community from the Ground Up

Lowest Unemployment Numbers in 49 Years and a Shrinking Labor Pool - What Does That Mean?

Introduction

Were seeing the lowest unemployment numbers in 49 years!! Were all seeing a shrinking labor pool - what does this all mean?

Code

ViralML-Hands-On-Unemployment-Labor-Pool-vs-SP500
In [156]:
from IPython.display import Image
Image(filename='../viralml-book.png')
Out[156]:

Unemployment, Labor Pool and the S&P500

Let's Compare overlay the Unemployment Rates on the S&P500 Let's continue exploring the stock market with Python. We've looked at the VIX, we've looked at the long and short-term bonds, Now let's take into the unemployment numbers.

You can find the unemployment rates directly from the Bureau of Labor Statistics: https://data.bls.gov/timeseries/lns14000000

Civilian Labor Force Participation Rate:

https://fred.stlouisfed.org/series/CIVPART

https://fred.stlouisfed.org/categories/12

And the S&P500 index (^GSPC): https://finance.yahoo.com/quote/%5EGSPC/

In [157]:
%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
In [158]:
# get the SP500 (^GSPC) from Yahoo Finace
sp500_df = pd.read_csv('^GSPC.csv')
sp500_df['Date'] = pd.to_datetime(sp500_df['Date'])
sp500_df = sp500_df[['Date', 'Adj Close']]
sp500_df.columns = ['Date', 'SP500_close']
sp500_df['SP500_pct_change'] = sp500_df['SP500_close'].pct_change()
sp500_df.head()
Out[158]:
Date SP500_close SP500_pct_change
0 1950-01-03 16.66 NaN
1 1950-01-04 16.85 0.011405
2 1950-01-05 16.93 0.004748
3 1950-01-06 16.98 0.002953
4 1950-01-09 17.08 0.005889
In [159]:
# loading employment data
# https://data.bls.gov/timeseries/lns14000000
unemployment_df = pd.read_csv('labor-force-bureau-of-labor-statistics-full.csv',sep='\t')
unemployment_df.head()
Out[159]:
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
0 1948 3.4 3.8 4.0 3.9 3.5 3.6 3.6 3.9 3.8 3.7 3.8 4.0
1 1949 4.3 4.7 5.0 5.3 6.1 6.2 6.7 6.8 6.6 7.9 6.4 6.6
2 1950 6.5 6.4 6.3 5.8 5.5 5.4 5.0 4.5 4.4 4.2 4.2 4.3
3 1951 3.7 3.4 3.4 3.1 3.0 3.2 3.1 3.1 3.3 3.5 3.5 3.1
4 1952 3.2 3.1 2.9 2.9 3.0 3.0 3.2 3.4 3.1 3.0 2.8 2.7
In [160]:
def monthToNum(shortMonth):
    return{'Jan' : 1,
            'Feb' : 2,
            'Mar' : 3,
            'Apr' : 4,
            'May' : 5,
            'Jun' : 6,
            'Jul' : 7,
            'Aug' : 8,
            'Sep' : 9, 
            'Oct' : 10,
            'Nov' : 11,
            'Dec' : 12
    }[shortMonth]

monthToNum('Feb')
Out[160]:
2
In [161]:
# stack the data together to have on row per month
unemployment_df = (unemployment_df.set_index(['Year'])
       .stack().reset_index(name='Unemployment')
                             .rename(columns={'level_1':'Month' }))
       
 
unemployment_df['Month'] = [monthToNum(m) for m in unemployment_df['Month'].values ]
unemployment_df.tail()
Out[161]:
Year Month Unemployment
851 2018 12 3.9
852 2019 1 4.0
853 2019 2 3.8
854 2019 3 3.8
855 2019 4 3.6
In [162]:
# format the year and the month into an actual date
unemployment_df['Date'] = [str(y) + '-' + str(m) + '-' + '01' for y,m in zip(unemployment_df['Year'].values, unemployment_df['Month'].values)]
unemployment_df = unemployment_df[['Date','Unemployment']]
unemployment_df['Unemployment_pct_change'] = unemployment_df['Unemployment'].pct_change()
unemployment_df['Date'] = pd.to_datetime(unemployment_df['Date'])
unemployment_df.head()
Out[162]:
Date Unemployment Unemployment_pct_change
0 1948-01-01 3.4 NaN
1 1948-02-01 3.8 0.117647
2 1948-03-01 4.0 0.052632
3 1948-04-01 3.9 -0.025000
4 1948-05-01 3.5 -0.102564
In [163]:
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(unemployment_df['Date'], unemployment_df['Unemployment'], color='blue')
plt.legend()
plt.grid()
plt.title('Labor Force Statistics from the Current Population Survey and the S&P 500')

# add second axis
ax2 = ax.twinx()
plt.plot(sp500_df['Date'], 
         sp500_df['SP500_close'], color='green', label='SP500_close', linestyle= 'dotted')
 
ax2.legend(loc='lower right', frameon=False)
plt.show()
In [164]:
# cut off data for further analysis
cut_off_date = '1980-01-01'
unemployment_df = unemployment_df[unemployment_df['Date'] >= cut_off_date]
sp500_df = sp500_df[sp500_df['Date'] >= cut_off_date]
 
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(unemployment_df['Date'], unemployment_df['Unemployment'], color='blue')
plt.legend()
plt.grid()
plt.title('Labor Force Statistics from the Current Population Survey and the S&P 500')

# add second axis
ax2 = ax.twinx()
plt.plot(sp500_df['Date'], 
         sp500_df['SP500_close'], color='green', label='SP500_close', linestyle= 'dotted')
 
ax2.legend(loc='lower right', frameon=False)
plt.show()
In [149]:
unemployment_df['Diff'] = unemployment_df['Unemployment_pct_change']
unemployment_df['Diff'] = unemployment_df['Diff'].rolling(window=50).mean().values 

fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(unemployment_df['Date'], 
         unemployment_df['Diff'],
         color='black', label='Unemployment_pct_change')
plt.axhline(0)
plt.title('Unemployment_pct_change vs SP500')
plt.legend()
plt.grid()




# background colors
unemployment_df['i'] = range(1,len(unemployment_df)+1)

# track whenever the percentage change is above or b
pos_1 = unemployment_df[unemployment_df['Diff'] >= 0]['i'] 
neg_1 = unemployment_df[unemployment_df['Diff'] < 0]['i']

for x in pos_1:
    ax.axvline(unemployment_df[unemployment_df['i']==x]['Date'].values, color='blue',linewidth=1,alpha=0.3)
for x in neg_1:
     ax.axvline(unemployment_df[unemployment_df['i']==x]['Date'].values, color='red',linewidth=1,alpha=0.3)

# add second axis
ax2 = ax.twinx()
plt.plot(sp500_df['Date'], 
         sp500_df['SP500_close'], color='green', label='SP500_close', linestyle= 'dotted')
 
ax2.legend(loc='lower right', frameon=False)
plt.show()

Comparing Unemployment VS Labor Force

In [165]:
# https://fred.stlouisfed.org/series/CIVPART
labor_df = pd.read_csv('CIVPART.csv')
labor_df.columns = ['Date', 'Labor_Participation']
labor_df['Date'] = pd.to_datetime(labor_df['Date'])
labor_df['Labor_Participation_pct_change'] = labor_df['Labor_Participation'].pct_change()
labor_df.head()
Out[165]:
Date Labor_Participation Labor_Participation_pct_change
0 1948-01-01 58.6 NaN
1 1948-02-01 58.9 0.005119
2 1948-03-01 58.5 -0.006791
3 1948-04-01 59.0 0.008547
4 1948-05-01 58.3 -0.011864
In [166]:
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(labor_df['Date'], labor_df['Labor_Participation'], color='blue')
plt.legend()
plt.grid()
plt.title('Labor Participation and the S&P 500')

# add second axis
ax2 = ax.twinx()
plt.plot(sp500_df['Date'], 
         sp500_df['SP500_close'], color='green', label='SP500_close', linestyle= 'dotted')
 
ax2.legend(loc='lower right', frameon=False)
plt.show()

All Together Now!

In [167]:
cut_off_date = '1980-01-01'
labor_df = labor_df[labor_df['Date'] >= cut_off_date]

fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(labor_df['Date'], labor_df['Labor_Participation'], color='red', 
         label='Labor_Participation')
plt.legend()
plt.grid()
plt.title('Labor Participation 24-54 and the S&P 500')

# add second axis
ax2 = ax.twinx()
plt.plot(sp500_df['Date'], 
         sp500_df['SP500_close'], color='green', label='SP500_close', linestyle= 'dotted')
 
ax2.legend(loc='lower right', frameon=False)

# add third axis
ax3 = ax.twinx()
plt.plot(unemployment_df['Date'], 
         unemployment_df['Unemployment'], color='blue', label='unemployment')
 
ax3.legend(loc='upper left', frameon=False)
plt.show()

Show Notes

(pardon typos and formatting -
these are the notes I use to make the videos)

Were seeing the lowest unemployment numbers in 49 years!! Were all seeing a shrinking labor pool - what does this all mean? MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=85uGWYBDIZ8 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 Articles: https://www.epi.org/news/shrinking-labor-force-explains-drop-unemployment/ https://www.cbo.gov/publication/53452 https://www.cbpp.org/gross-domestic-product-6 Transcript Wow, Were seeing the lowest Unemployment Numbers in 49 Years!! Heck, I dont even remember those days, I was too busy learning how to walk. so what does this mean? are we all busy working away happily? But theres also rumblings of a shrinking labor pool and anemic wage growth. - what does that mean? What Gives? Stong Demand in low paid jobs mixed with Baby boomers retiring? and job seekers giving up, more stay at home parent to raise families? Lets check those numbers for ourselves. All fascinating questions and we can speculate all day - but instead, lets roll up our sleeves, find reliable data - Ill show you where to get it (point with finger), and start charting. This is the Hippocratic Oath of the data analyst and data scientist. We want to keep things simple, transparent and reproducible. What I show you, you will be able to reproduce on your computer and make your own conclusion Welcome to the anohter ViralML show, I am your host, Manuel Amunategui. Rolling out a new look pretty soon. The Little Book of Fundamental Indicators where I share my favorite hands-on market analysis fundamental indicators Signup for my newsletter to get early access to my material. Subscribe to the channel - and give it a big thumbs up, pretty please! Plus I have an exciting announcement to make at the end of this video - so please watch. Center on Budget and Policy Priorities Recessions tend to push labor force participation down relative to its potential, an effect that lingers for several years even after the end, in CBOs judgment. The recovery of labor force participation following the 2007–2009 recession has been especially slow. https://www.cbo.gov/publication/53452 just one factor of the many: Since about 2000, the labor force participation of people without a college degree has declined, but the effect of that decline on the overall labor force participation rate is lessened because the share of the population without a college degree has decreased. Between the end of the recession and 2015, however, the rate fell by 2 percentage points, from 83 percent to 81 percent. Although the rate inched up slightly in both 2016 and 2017, it is likely to stay about the same between 2018 and 2027, CBO estimates. https://www.cbo.gov/publication/53452 CATEGORY:Finance HASCODE:ViralML-Hands-On-Unemployment-Labor-Pool-vs-SP500.html