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

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.

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)