knitr::opts_chunk$set(echo = FALSE)
library(tidymas)
library(Rblpapi)
library(tidyverse)
blpConnect()
emu_cycles <- read.table(text = "
  from         to
1 1993-07-01 2008-04-01
2 2009-04-01 2011-10-01
3 2013-01-01 2018-12-31", 
  colClasses = c("Date", "Date")) 

df_pe <- bdh("MXEM Index", "PE_RATIO", as.Date("1990-01-01"))

df_pe %>% 
  plot_cycles(emu_cycles, title = "PE Ratio, MSCI EMU, CEPR Business Cycles (Trough to Peak)", ylab = "PE Ratio") +
  theme_strat() +
  scale_color_strat() + 
  coord_cartesian(ylim = c(10, 40))
df_div_yld <- bdh("MXEM Index", "EQY_DVD_YLD_12M", as.Date("1990-01-01"))

df_div_yld %>% 
  plot_cycles(emu_cycles, title = "Dividend Yield, MSCI EMU, CEPR Business Cycles (Trough to Peak)", ylab = "Dividend Yield (%)") +
  theme_strat() +
  scale_color_strat() 
df_prof_margin <- bdh("MXEM Index", "PROF_MARGIN", as.Date("1990-01-01"))

df_prof_margin %>% 
  plot_cycles(emu_cycles,  title = "Profit Margin, MSCI EMU, CEPR Business Cycles (Trough to Peak)", ylab = "Profit Margin (%)") +
  theme_strat() +
  scale_color_strat() 


yunching/tidymas documentation built on Feb. 5, 2023, 1:42 p.m.