Contents

  i. Executive Summary
  ii. Conclusion
  iii. Code

Executive Summary

Using Live Yahoo Finance Data to analyze the E/P ratio relative to the lagged change in percent earnings . The E/P ratio is the earning yields for stock, and is the inverse of /the P/E price to earnings of stocks. The P/E ratio further is the ratio of the market price of a company’s stock compared to earnings per share.

I produce a plot with E/P on the y-axis and the 3-year average of the lagged percentage change in earnings on the x-axis. I do this by first uploading the following data from the WRDS database for S&P 500 companies during the period January 1950 to January 2020: fiscal year, ticker, company name, price, shares outstanding, and EBIT. I chose to use EBIT as a proxy for earnings because it reflects the operating earnings of a company prior to extraordinary one-time gains/losses due to non-operating activities. Also, before plotting, I truncate both the X (E/P ratio) and the Y (3-year average of the lagged percentage change in earnings) variables at the 10th and 90th quantiles.

For each S&P 500 stock, I calculate the market capitalization of the company at any point in time by taking the product of the price and the shares outstanding. Then, I find the E/P ratio by taking the ratio of EBIT divided by the market capitalization. Also, I calculate the percentage change in earnings via the following formula:

To calculate we using the following ratio:

\[Earnings\ Yield\ (E/P) = \frac{Earnings\ per\ Share\ of\ Common\ Stock}{Price}\] \[Log\ firm-Cap=log(Shares\ Outstandings\ \times\ Stock\ Price)\]

The lagged percentage growth change is a measurement of the company past 3 years average growth change. This was provided in yahooQF() and I selected The 200-day moving average. The 200-day moving average is the average price over the past 200 days or 40 weeks.

## downloading set: 1 , 2 , 3 , ...done

Conclusion

The data pulled from Yahoo Finance provided: EPS, Percent Change From 200-day Moving Average, Change in Percent, Earnings/Share, Last Trade (Price Only), Market Capitalization, and Shares Outstanding.

By plotting these two variable, allows us to evaluate growth o the stock compared to it’s earnings. We can see from the first plot that that the majority of change is between -0.025% up to 0.075%. With the largest market cap companies hovering around 0.025. By plotting in the histogram we can further see that 50% of companies lies between 0.025 - 0.075. By understanding growth we are able to set benchmarks.

Most company’s EP ratio are in between [−0.1,0.1]. From the plot, the E/P ratio does not have an impact on lagged change in the percent earnings. The company with -20% loss or 40%+ gain may have same E/P ratio. The clustering are around 0-20% percent change which have a positive E/P. The negative E/P ratios are sparsely distributed for the companies with more than 20% loss or more than 40% growth. The main take away from this may be if your are on a steady growth, you are more likely to have the positive E/P ratio. The possible reason might be belief in consecutive growth indicating a promising future.

## downloading set: 1 , 2 , 3 , ...done

Code

library(BatchGetSymbols)
library(rvest)
library(xml2)
library(GetQuandlData)
library(tidyverse)
library(tidyquant)
library(Quandl)
library(PerformanceAnalytics)
library(dygraphs)
library(quantmod)
library(kableExtra)
library(ggplot2)
library(RColorBrewer)
library(viridisLite) 

df.SP500 <- GetSP500Stocks()
tickers <- df.SP500$Tickers
print(sp500$df.tickers)

# Pull this data Live from Yahoo
what_metrics <- yahooQF(c( "Percent Change From 200-day Moving Average",
                           "Change in Percent",
                           "Earnings/Share",
                           "Last Trade (Price Only)",
                           "Market Capitalization",
                           "Shares Outstanding"
                           ))

metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics, )
colnames(metrics) = c("time", "moving.average", "change.percent","EPS",
                      "last.price", "Marketcap", "shares.out")
#head(metrics)

sp500 = metrics %>%
  mutate(EP = EPS/last.price) %>% 
  mutate(mkt.cap = log(shares.out * last.price)) %>% 
  filter(EP > quantile(EP,0.1,na.rm=T) & EP< quantile(EP,0.9,na.rm=T)) %>%
  drop_na()

EP = ggplot(sp500,aes(x=change.percent, y = EP, size=mkt.cap))+
  geom_point(aes(color = mkt.cap),shape=16)+
  scale_radius(range=c(0,6),breaks = c(0,5,10,15,20,25,30,35,40,45,50))+
  scale_color_gradientn(colours = viridis(10)) +
  ggtitle("SP500 : E/P v Percent Change in Price") +
  xlab("% Change in Price") + 
  ylab("E/P") +
  labs(color = "Market Cap Size", size = "Market Average")+
  theme_classic()

# Modify legend titles & Titles
EP + theme(
    plot.title = element_text(color="black", size=16, face="bold.italic"),
    axis.title.x = element_text(color="black", size=12, face="bold"),
    axis.title.y = element_text(color="black", size=12, face="bold"))
#===============================================================================  

stats = sp500 %>%
  select(EP = EP, change.percent, mkt.cap)
stats_final = do.call(cbind, lapply(stats, summary))
colnames(stats_final) = c("E/P", 'Change in Percent', "Market Cap")

stats_final %>%
  kable(head(stats_final), caption = '<b>Summary Statistics</b>', 
        format = 'html') %>% 
  kable_classic(full_width = F, html_font = "Cambria") %>%
  row_spec(0,bold =TRUE)

#===============================================================================

hist(sp500$EP,breaks = 30,col='blue',main='EP Ratio',
     xlab = 'Ratio')
abline(v=mean(sp500$EP,na.rm=T),col='black',lwd=2)
abline(v=quantile(sp500$EP,0.25,na.rm=T),col='green',lwd=2)
abline(v=quantile(sp500$EP,0.75,na.rm=T),col='red',lwd=2)

REFERENCES

Fernando, J. (2021, February 08). Price-to-earnings ratio – p/e ratio. Retrieved February 24, 2021, from https://www.investopedia.com/terms/p/price-earningsratio.asp