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

San Francisco Exodus! Companies Leaving For Greener Pastures - Hands-On Market Analysis with Python

Introduction

Its the San Francisco Exodus!!! You all knew that day was coming! Companies are all leaving and taking their employees with them -- or at least theyre offering to relocate them. Scott Sanborn, CEO of Lending Club sends a memo out to employees stating that rent is just too high - highest in the country and that its time to move out. Lets analyze these numbers using great datasets, Python and a Jupyter notebook.

Code

CPPI vs S&P500
In [29]:
from IPython.display import Image
Image(filename='viralml-book.png')
Out[29]:

CPPI Composite Index

FREQUENCY: Monthly

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


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.tail()
Out[30]:
Date SP500_close SP500_pct_change
17439 2019-04-25 2926.169922 -0.000369
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
In [31]:
sp500_df.head()
Out[31]:
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

Green Street Commercial Property Price Index

https://www.greenstreetadvisors.com/insights/CPPI

In [32]:
cppi_df = pd.read_csv('green_street_cppi.csv', sep='\t')
cppi_df['Date'] = pd.to_datetime(cppi_df['Date'])
cppi_df['CPPI_pct_change'] = cppi_df['CPPI'].pct_change()
cppi_df.head()
Out[32]:
Date CPPI CPPI_pct_change
0 1997-12-01 47.8 NaN
1 1998-01-01 48.0 0.004184
2 1998-02-01 48.7 0.014583
3 1998-03-01 51.0 0.047228
4 1998-04-01 51.0 0.000000
In [33]:
cppi_df.tail()
Out[33]:
Date CPPI CPPI_pct_change
251 2018-11-01 132.1 0.003037
252 2018-12-01 132.1 0.000000
253 2019-01-01 132.1 0.000000
254 2019-02-01 132.5 0.003028
255 2019-03-01 132.7 0.001509
In [34]:
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(cppi_df['Date'], cppi_df['CPPI'])
plt.title('CPPI vs S&P 500')
plt.grid()
ax.legend(loc='upper left', frameon=False)
 

# 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 [35]:
# time range available
print('cppi_df:', np.min(cppi_df['Date']), np.max(cppi_df['Date']))
print('SP500:', np.min(sp500_df['Date']), np.max(sp500_df['Date']))
cppi_df: 1997-12-01 00:00:00 2019-03-01 00:00:00
SP500: 1950-01-03 00:00:00 2019-05-01 00:00:00
In [36]:
cut_off_date = '1997-12-01' 

cppi_df = cppi_df[cppi_df['Date'] >= cut_off_date]
sp500_df = sp500_df[sp500_df['Date'] >= cut_off_date]
 
print('cppi_df.shape():',cppi_df.shape)
print('sp500_df.shape():',sp500_df.shape)
cppi_df.shape(): (256, 3)
sp500_df.shape(): (5388, 3)
In [37]:
fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(cppi_df['Date'], cppi_df['CPPI'])
plt.title('CPPI vs S&P 500')
plt.grid()
ax.legend(loc='upper left', frameon=False)
 

# 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()

Run percent change

In [28]:
# color chart
cppi_df['CPPI_pct_change_slow'] = cppi_df['CPPI_pct_change'].rolling(window=5).mean().values
cppi_df['i'] = range(1,len(cppi_df)+1)


fig, ax = plt.subplots(figsize=(16, 8))
plt.plot(cppi_df['Date'], cppi_df['CPPI_pct_change_slow'], 
         color='blue', label='PMI_pct_change')
plt.grid()
plt.axhline(0)
plt.title('CPPI PCT CHANGE vs S&P 500')
ax.legend(loc='upper left', frameon=False)
 
# 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)



# color chart
# track whenever the percentage change is above or b
pos_1 = cppi_df[cppi_df['CPPI_pct_change_slow'] >= 0]['i'] 
neg_1 = cppi_df[cppi_df['CPPI_pct_change_slow'] < 0]['i']

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

plt.show()

Show Notes

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

Its the San Francisco Exodus!!! You all knew that day was coming! Companies are all leaving and taking their employees with them -- or at least theyre offering to relocate them. Scott Sanborn, CEO of Lending Club sends a memo out to employees stating that rent is just too high - highest in the country and that its time to move out. Lets analyze these numbers using great datasets, Python and a Jupyter notebook. MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=mE4vOwgRHLc 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 Data: https://www.greenstreetadvisors.com/insights/CPPI https://finance.yahoo.com/quote/%5EGSPC Articles: United States office outlook - Q1 2019 https://www.us.jll.com/en/trends-and-insights/research/office-market-statistics-trends Lending Club joins Bay Area exodus as it moves hundreds of jobs out of San Francisco https://www.bizjournals.com/sanfrancisco/news/2019/05/01/lending-club-lc-bay-area-exodus-real-estate-utah.html?ana=yahoo&yptr=yahoo Transcript Its the San Francisco Exodus!!! You all knew that day was coming! Companies are all leaving and taking their employees with them -- Or at least theyre offering to relocate them This image was taken in 1971 in Seattle WA during the recession of 1971, and its not quite whats going on in SF. Here is a quote from the bizjournals about a memo sent by Scott Sanborn, CEO of Lending Club (in bizjournals.com) ...rents in San Francisco have increased 140 percent since 2010 and are now “some of the highest in the country... Growing exclusively in San Francisco simply doesnt make financial sense. Instead, we now have plenty of headroom to grow affordably in Lehi and access a new talent base in Utah. So, I imagine the conversation going like, Hey, were gonna move to Lehi Utah, you should come with, really, its just like here, right by the water too - well its a lake. Oh, and bring a sweater or 10, gets like the 15 degrees in January, but you should really come. yadda yadda yadda Do you think theyll get to keep their SF salaries or will there be a 3 for 1 special on developers? like 3 Utah developers for the price of one sf developer! But can we blame them? Heck no! Thats the one thing I hear from people who live in sf is that the city is dirty, the commute horrible, and brutally expensive. so, lets break out our trusted Jupyter notebook and dig into some numbers. Welcome to the ViralML show my name is Manuel Amunategui, and this is another market analysis hands-on with Python video - . I am the author of a few books including this one - The Little Book of Fundamental Indicators - in it 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! The first exhibit is to see if CEO Scott Sanborn is speaking the truth about SF being the highest in the country... Look at $ per square foot New York $81.05 San Francisco $81.78 Oh my god, he is right! So, what data do we have to look at? Lets use the CPPI (Green Street Commercial Property Price Index) CATEGORY:StateOfIndustry HASCODE:ViralML-Hands-On-Market-Analysis-CPPI-SF-Exodus.html