Peer 6-9 Months Into the Future with the CLI - a World Economic Health Leading Indicator
Introduction
Let's look at an incredible indicator called the CLI, Composite Leading Indicators (but I am dubbing it the World Economic Economic Leading Health Index). It purportedly can foretell turns in the economy 6-9 months in advance according to the OECD's brochure. It is made up of business confidence surveys, manufacturing orders, and inventories levels, share prices, trading trends, etc.
Code
from IPython.display import Image
Image(filename='cli-thumbnail.png', width='80%')
https://www.economy.com/dismal/indicators/definition/oecd_cli
Established in 1961, the Organisation for Economic Co-operation and Development (OECD) is composed of 30 member nations. The OECD acts as a forum to coordinate economic policies and promote growth and stability. The OECD Composite Leading Indicators are selected from a wide range of key short-term economic indicators (170 in total, or between 5 and 10 for each country), which reflect different sectors of the economy, and provide a gauge of future economic activity.
https://data.oecd.org/leadind/composite-leading-indicator-cli.htm
S&P 500 (^GSPC)¶
https://finance.yahoo.com/quote/%5EGSPC
Direct pull:¶
Google Trends¶
And just for fun, try pulling somthing from Google Trends
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import io, base64, os, json, re, math
import pandas as pd
import numpy as np
import datetime
import warnings
warnings.filterwarnings('ignore')
## Building a good world representation of the CLI
cli_df = pd.read_csv('DP_LIVE_19012020143246784.csv')
set(cli_df['LOCATION'])
cli_df.head()
import calendar
full_date_list = []
for tm in cli_df['TIME']:
year = int(tm.split('-')[0])
month = int(tm.split('-')[1])
full_date_list.append(tm + '-' + str(calendar.monthrange(year, month)[1]))
cli_df['Date'] = full_date_list
cli_df['Date'] = pd.to_datetime(cli_df['Date'])
cli_df = cli_df[['Date', 'LOCATION', 'Value']]
cli_df = cli_df.sort_values('Date', ascending=True)
print(min(cli_df['Date']), max(cli_df['Date']))
cli_df.tail()
# min date for each location
for ct in set(cli_df['LOCATION']):
print(ct)
cli_tmp = cli_df[cli_df['LOCATION']==ct]
print(np.min(cli_tmp['Date']))
cli_df = cli_df[cli_df['Date'] >= '1992-09-30']
cli_df = cli_df[['Date', 'Value']]
cli_df = cli_df.groupby('Date').mean().reset_index()
cli_df.head()
Load S&P 500 Index for Comparison and Data Exploration¶
# load the S&P 500
sp500_raw = pd.read_csv('^GSPC.csv')
sp500_raw.tail()
sp500_raw = sp500_raw[['Date','Adj Close']]
sp500_raw['Date'] = pd.to_datetime(sp500_raw['Date'])
sp500_raw = sp500_raw.sort_values('Date', ascending=True)
print(min(sp500_raw['Date']), max(sp500_raw['Date']))
sp500_raw.head()
Plot both together¶
sp500_tmp = sp500_raw.copy()
sp500_tmp = sp500_tmp[sp500_tmp['Date'] >= '1992-09-30']
fig, ax = plt.subplots(figsize=(16, 10))
plt.plot(sp500_tmp['Date'], sp500_tmp['Adj Close'], label='SP500',
color='green')
plt.legend(loc='lower left')
second_axis = ax.twinx()
plt.plot(cli_df['Date'], cli_df['Value'], label='CLI',
color='blue')
second_axis.axhline(y=100, color='gray')
plt.title('CLI-World vs SP&500')
plt.legend(loc='upper left')
plt.grid()
Playing with Google Trends¶
google_trends = pd.read_csv('google-trends-refi-rates.csv', skiprows=1)
google_trends.head()
import calendar
full_date_list = []
for tm in google_trends['Month']:
year = int(tm.split('-')[0])
month = int(tm.split('-')[1])
full_date_list.append(tm + '-' + str(calendar.monthrange(year, month)[1]))
google_trends['Date'] = full_date_list
google_trends['Date'] = pd.to_datetime(google_trends['Date'])
google_trends = google_trends[['Date', 'refinance: (Worldwide)', 'interest rates: (Worldwide)']]
print(min(google_trends['Date']), max(google_trends['Date']))
google_trends.tail()
cli_tmp = cli_df.copy()
cli_tmp = cli_tmp[cli_tmp['Date'] >= '2004-01-31']
fig, ax = plt.subplots(figsize=(16, 10))
plt.plot(google_trends['Date'],
google_trends['refinance: (Worldwide)'],
label='Refinance',
color='blue')
plt.legend(loc='lower left')
second_axis = ax.twinx()
plt.plot(google_trends['Date'],
google_trends['interest rates: (Worldwide)'],
label='Interest Rates',
color='green')
plt.legend(loc='upper left')
third_axis = ax.twinx()
plt.plot(cli_tmp['Date'], cli_tmp['Value'], label='CLI',
color='black')
second_axis.axhline(y=100, color='gray')
plt.title('CLI-World vs Google Trends')
plt.legend(loc='upper right')
plt.grid()
Show Notes
(pardon typos and formatting -these are the notes I use to make the videos)
Let's look at an incredible indicator called the CLI, Composite Leading Indicators (but I am dubbing it the World Economic Economic Leading Health Index). It purportedly can foretell turns in the economy 6-9 months in advance according to the OECD's brochure. It is made up of business confidence surveys, manufacturing orders, and inventories levels, share prices, trading trends, etc.