Get the "Applied Data Science Edge"!

The ViralML School

Fundamental Market Analysis with Python - Find Your Own Answers On What Is Going on in the Financial Markets

Web Work

Python Web Work - Prototyping Guide for Maker

Use HTML5 Templates, Serve Dynamic Content, Build Machine Learning Web Apps, Grow Audiences & Conquer the World!

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!

Purchasing Managers' Index (PMI), The Most Powerful Indicator - Hands-On Market Analysis with Python

Introduction

Lets look at one of the most important financial indicators - The PMI (PURCHASING MANAGERS INDEX). This is a fundamental indicator that is closely followed, published at the beginning of every month, and with the power of moving markets. MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=O2mTR00-MNc Signup for my newsletter and more: http://www.viralml.com Connect on Twitter: https://twitter.com/amunategui My books on Amazon: The Little Book of Fundamental Indicators: Hands-On Market Analysis with Python: Find Your Market Bearings with Python, Jupyter Notebooks, and Freely Available Data: https://amzn.to/2DERG3d Monetizing Machine Learning: Quickly Turn Python ML Ideas into Web Applications on the Serverless Cloud: https://amzn.to/2PV3GCV Grow Your Web Brand, Visibility & Traffic Organically: 5 Years of amunategui.github.Io and the Lessons I Learned from Growing My Online Community from the Ground Up: Fringe Tactics - Finding Motivation in Unusual Places: Alternative Ways of Coaxing Motivation Using Raw Inspiration, Fear, and In-Your-Face Logic https://amzn.to/2DYWQas Create Income Streams with Online Classes: Design Classes That Generate Long-Term Revenue: https://amzn.to/2VToEHK Defense Against The Dark Digital Attacks: How to Protect Your Identity and Workflow in 2019: https://amzn.to/2Jw1AYS Transcript Welcome to the anohter hands-on market analysis with python. My name is Manuel Amunategui - As usual, the code for this video is included in the videos description and this talk will be filed under the channel finance on the ViralML.com website. Please signup for my newsletter, subscribe to the channel and give it big thumbs up! This is a critical fundamental report, released monthly and it will move the markets. Its a diffusion index, meaning it tells you if its improving by being over 50 or worsening if its below 50 It is interesting to understand a bit about what is behind the PMI. It is a series of monthly surveys based on questionnaires - it looks at both orders, backlog, employment and how these things compare to the previous month. And these are sent out to the manufacturing and non-manufacturing leaders. ISM surveys - institute for supply management https://www.instituteforsupplymanagement.org/ISMReport/content.cfm?ItemNumber=10745&SSO=1 https://www.markiteconomics.com/Public/Release/ReleaseDates 85% correlation to GDP and use it to measure how the economy will change in the future. https://research.stlouisfed.org/publications/economic-synopses/2016/03/25/pmi-and-gdp-do-they-correlate-for-the-united-states-for-china/ it is a bit different between us and China, a small PMI increase translates to a big GDP change, on the other hand, US is much closer together. Lets dig into some code! If you are interested in more of this kind of analysis, 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! CATEGORY:Finance HASCODE:ViralML-Hands-On-Market-Analysis-Purchasing-Managers-Index.html



If you liked it, please share it:

Code

ViralML-Hands-On-Market-Analysis-Purchasing-Managers-Index.html

title

Institute for Supply Management: PMI Composite Index

FREQUENCY: Monthly

The Purchasing Managers Index (PMI) is a measure of the prevailing direction of economic trends in manufacturing. The PMI is based on a monthly survey of supply chain managers across 19 industries, covering both upstream and downstream activity.

DESCRIPTION:

The PMI (R) is a composite index based on the diffusion indexes of five of the indexes with equal weights: New Orders (seasonally adjusted), Production (seasonally adjusted), Employment (seasonally adjusted), Supplier Deliveries (seasonally adjusted), and Inventories.

The Little Book of Fundamental Market Indicators

ViralML.com

In [128]:
%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



def plot_compare_with_sp500(index_df, feature, sp500_df, hsplit=50):

    tmp_df = index_df.copy()
    sp500_df_tmp = sp500_df.copy()
    
    cut_off_date = np.min( tmp_df['Date']) 
    sp500_df_tmp = sp500_df_tmp[sp500_df_tmp['Date'] >= cut_off_date]

    fig, ax = plt.subplots(figsize=(16, 8))
    plt.plot(tmp_df['Date'], tmp_df[feature])
    plt.title(feature + ' vs S&P 500')
    plt.grid()
    ax.legend(loc='upper left', frameon=False)
    
    plt.axhline(hsplit, color='black')


    # add second axis
    ax2 = ax.twinx()
    plt.plot(sp500_df_tmp['Date'], 
             sp500_df_tmp['SP500_close'], color='green', label='SP500_close', linestyle= 'dotted')

    ax2.legend(loc='lower right', frameon=False)
    plt.show()

 
In [73]:
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()
print('SP500:', np.min(sp500_df['Date']), np.max(sp500_df['Date']))
sp500_df.tail()
SP500: 1950-01-03 00:00:00 2019-05-02 00:00:00
Out[73]:
Date SP500_close SP500_pct_change
17440 2019-04-26 2939.879883 0.004685
17441 2019-04-29 2943.030029 0.001072
17442 2019-04-30 2945.830078 0.000951
17443 2019-05-01 2923.729980 -0.007502
17444 2019-05-02 2917.520020 -0.002124

Purchasing Managers Index (PMI)

ISM-MAN_PMI

https://www.quandl.com/data/ISM/MAN_PMI-PMI-Composite-Index

In [129]:
tmp_df = pd.read_csv('ISM-MAN_PMI.csv')
tmp_df['Date'] = pd.to_datetime(tmp_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
tmp_df = tmp_df.iloc[::-1]
print('PMI:', np.min(sp500_df['Date']), np.max(sp500_df['Date']))
tmp_df.tail()
PMI: 1950-01-03 00:00:00 2019-05-02 00:00:00
Out[129]:
Date PMI
4 2018-12-01 54.3
3 2019-01-01 56.6
2 2019-02-01 54.2
1 2019-03-01 55.3
0 2019-04-01 52.8
In [130]:
plot_compare_with_sp500(tmp_df, 'PMI', sp500_df)
In [131]:
plot_compare_with_sp500(tmp_df[tmp_df['Date'] > '1995-01-01'], 'PMI', sp500_df)
In [133]:
tmp_df = pd.read_csv('ISM-NONMAN_INVSENT.csv')
tmp_df['Date'] = pd.to_datetime(tmp_df['Date'])
tmp_df['NONMAN_INVSENT_pct_change'] = tmp_df['Diffusion Index'].pct_change()
# flip order to be just like Yahoo Finance - ascending
tmp_df = tmp_df.iloc[::-1]
tmp_df['NONMAN_INVSENT_pct_change'] = tmp_df['NONMAN_INVSENT_pct_change'].rolling(window=10).mean().values
tmp_df.tail()

 
Out[133]:
Date % Too High % About Right % Too Low Diffusion Index NONMAN_INVSENT_pct_change
4 2018-12-01 22.0 74.0 4.0 59.0 -0.002919
3 2019-01-01 26.0 69.0 5.0 60.5 0.002124
2 2019-02-01 24.0 70.0 6.0 59.0 -0.001837
1 2019-03-01 27.0 71.0 2.0 62.5 -0.003757
0 2019-04-01 24.0 72.0 4.0 60.0 NaN
In [134]:
plot_compare_with_sp500(tmp_df, 'NONMAN_INVSENT_pct_change', sp500_df, hsplit=0)
In [135]:
tmp_df = pd.read_csv('ISM-MAN_BACKLOG.csv')
tmp_df['Date'] = pd.to_datetime(tmp_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
tmp_df = tmp_df.iloc[::-1]
tmp_df.head()
Out[135]:
Date % Greater % Same % Less Net Index % Reporting
315 1993-01-01 27.0 59.0 14.0 13.0 56.5 88.0
314 1993-02-01 28.0 56.0 16.0 12.0 56.0 91.0
313 1993-03-01 26.0 57.0 17.0 9.0 54.5 89.0
312 1993-04-01 23.0 56.0 21.0 2.0 51.0 91.0
311 1993-05-01 23.0 57.0 20.0 3.0 51.5 91.0
In [136]:
plot_compare_with_sp500(tmp_df[tmp_df['Date'] > '2005-01-01'], 'Index', sp500_df)
 
In [137]:
tmp_df = pd.read_csv('ISM-NONMAN_BACKLOG.csv')
tmp_df['Date'] = pd.to_datetime(tmp_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
tmp_df = tmp_df.iloc[::-1]
tmp_df.head()
Out[137]:
Date % Higher % Same % Lower Diffusion Index % Who Do Not Measure
261 1997-07-01 18.0 62.0 20.0 49.0 29.0
260 1997-08-01 26.0 61.0 13.0 56.5 26.0
259 1997-09-01 14.0 71.0 15.0 49.5 28.0
258 1997-10-01 15.0 74.0 11.0 52.0 28.0
257 1997-11-01 21.0 70.0 9.0 56.0 24.0
In [138]:
plot_compare_with_sp500(tmp_df[tmp_df['Date'] > '2005-01-01'], 'Diffusion Index', sp500_df)
In [139]:
tmp_df = pd.read_csv('ISM-MAN_INVENT.csv')
tmp_df['Date'] = pd.to_datetime(tmp_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
tmp_df = tmp_df.iloc[::-1]
tmp_df.tail()
Out[139]:
Date % Higher % Same % Lower Net Index
4 2018-12-01 20.9 60.6 18.4 2.5 51.2
3 2019-01-01 21.5 62.5 16.0 5.5 52.8
2 2019-02-01 20.0 66.8 13.2 6.8 53.4
1 2019-03-01 18.4 66.9 14.7 3.7 51.8
0 2019-04-01 20.5 64.8 14.7 5.8 52.9
In [103]:
plot_compare_with_sp500(tmp_df[tmp_df['Date'] > '2005-01-01'], 'Index', sp500_df)

Comparing inventory vs backlog

In [140]:
cut_off_date = '2005-01-01' 

invent_df = pd.read_csv('ISM-MAN_INVENT.csv')
invent_df['Date'] = pd.to_datetime(invent_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
invent_df = invent_df.iloc[::-1]
 

back_df = pd.read_csv('ISM-MAN_BACKLOG.csv')
back_df['Date'] = pd.to_datetime(back_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
back_df = back_df.iloc[::-1]

# time range available
invent_df = invent_df[invent_df['Date'] >= cut_off_date]
back_df = back_df[back_df['Date'] >= cut_off_date]
 
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(invent_df['Date'], invent_df['Index'], label='invent_df')
plt.plot(back_df['Date'], back_df['Index'], label='back_df')
plt.title('MAN INVENT vs BACK')
plt.grid()
ax.legend(loc='upper left', frameon=False)


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

invent_df = pd.read_csv('ISM-NONMAN_INVSENT.csv')
invent_df['Date'] = pd.to_datetime(invent_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
invent_df = invent_df.iloc[::-1]
 

back_df = pd.read_csv('ISM-NONMAN_BACKLOG.csv')
back_df['Date'] = pd.to_datetime(back_df['Date'])
# tmp_df['PMI_pct_change'] = tmp_df['PMI'].pct_change()
# flip order to be just like Yahoo Finance - ascending
back_df = back_df.iloc[::-1]

# time range available
invent_df = invent_df[invent_df['Date'] >= cut_off_date]
back_df = back_df[back_df['Date'] >= cut_off_date]
 
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(invent_df['Date'], invent_df['Diffusion Index'], label='invent_df')
plt.plot(back_df['Date'], back_df['Diffusion Index'], label='back_df')
plt.title('MAN INVENT vs BACK')
plt.grid()
ax.legend(loc='upper left', frameon=False)


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

invent_df = pd.read_csv('ISM-NONMAN_INVSENT.csv')
invent_df['Date'] = pd.to_datetime(invent_df['Date'])
invent_df['invent_pct_change'] = invent_df['Diffusion Index'].pct_change()
# flip order to be just like Yahoo Finance - ascending
invent_df = invent_df.iloc[::-1]
 

back_df = pd.read_csv('ISM-NONMAN_BACKLOG.csv')
back_df['Date'] = pd.to_datetime(back_df['Date'])
back_df['back_pct_change'] = back_df['Diffusion Index'].pct_change()
# flip order to be just like Yahoo Finance - ascending
back_df = back_df.iloc[::-1]

# join data sets together
# join both datasets together
together = pd.merge(invent_df[['Date', 'invent_pct_change']], 
                    back_df[['Date', 'back_pct_change']], 
                    on= ['Date'], how='inner')

# last valid observation forward
together = together.fillna(method='ffill')
 
# drop NAs
together = together.dropna(axis=0)
together.tail()
Out[141]:
Date invent_pct_change back_pct_change
257 2018-12-01 -0.024793 -0.038095
258 2019-01-01 0.025424 -0.054054
259 2019-02-01 -0.056000 -0.017699
260 2019-03-01 0.041667 0.027273
261 2019-04-01 0.041667 0.027273
In [143]:
together['diff'] = together['invent_pct_change'] - together['back_pct_change']
together['diff'] = together['diff'].rolling(window=5).mean().values

# time range available
together = together[together['Date'] >= cut_off_date]
 
 
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(together['Date'], together['diff'], label='diff') 
plt.title('Non MAN INVENT vs BACK')
plt.grid()
ax.legend(loc='upper left', frameon=False)
plt.axhline(0, color='black')

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

Show Notes

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

Lets look at one of the most important financial indicators - The PMI (PURCHASING MANAGERS INDEX). This is a fundamental indicator that is closely followed, published at the beginning of every month, and with the power of moving markets. MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=O2mTR00-MNc Signup for my newsletter and more: http://www.viralml.com Connect on Twitter: https://twitter.com/amunategui My books on Amazon: The Little Book of Fundamental Indicators: Hands-On Market Analysis with Python: Find Your Market Bearings with Python, Jupyter Notebooks, and Freely Available Data: https://amzn.to/2DERG3d Monetizing Machine Learning: Quickly Turn Python ML Ideas into Web Applications on the Serverless Cloud: https://amzn.to/2PV3GCV Grow Your Web Brand, Visibility & Traffic Organically: 5 Years of amunategui.github.Io and the Lessons I Learned from Growing My Online Community from the Ground Up: Fringe Tactics - Finding Motivation in Unusual Places: Alternative Ways of Coaxing Motivation Using Raw Inspiration, Fear, and In-Your-Face Logic https://amzn.to/2DYWQas Create Income Streams with Online Classes: Design Classes That Generate Long-Term Revenue: https://amzn.to/2VToEHK Defense Against The Dark Digital Attacks: How to Protect Your Identity and Workflow in 2019: https://amzn.to/2Jw1AYS Transcript Welcome to the anohter hands-on market analysis with python. My name is Manuel Amunategui - As usual, the code for this video is included in the videos description and this talk will be filed under the channel finance on the ViralML.com website. Please signup for my newsletter, subscribe to the channel and give it big thumbs up! This is a critical fundamental report, released monthly and it will move the markets. Its a diffusion index, meaning it tells you if its improving by being over 50 or worsening if its below 50 It is interesting to understand a bit about what is behind the PMI. It is a series of monthly surveys based on questionnaires - it looks at both orders, backlog, employment and how these things compare to the previous month. And these are sent out to the manufacturing and non-manufacturing leaders. ISM surveys - institute for supply management https://www.instituteforsupplymanagement.org/ISMReport/content.cfm?ItemNumber=10745&SSO=1 https://www.markiteconomics.com/Public/Release/ReleaseDates 85% correlation to GDP and use it to measure how the economy will change in the future. https://research.stlouisfed.org/publications/economic-synopses/2016/03/25/pmi-and-gdp-do-they-correlate-for-the-united-states-for-china/ it is a bit different between us and China, a small PMI increase translates to a big GDP change, on the other hand, US is much closer together. Lets dig into some code! If you are interested in more of this kind of analysis, 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! CATEGORY:Finance HASCODE:ViralML-Hands-On-Market-Analysis-Purchasing-Managers-Index.html