#### QUANDL API
# Passos necessC!rios antes de continuar com o cC3digoa baixo
# 1. Acesse https://www.quandl.com/
# 2. Crie uma conta no site
# 3. Obtenha uma API Key
# 4. Adicione sua API Key nos parC"metros abaixo
library(GetQuandlData)
library(ggplot2)
library(ggthemes)
library(GetTDData)
<- "Your KEY here"
api_KEY
# Selic BCB/11 or BCB/4390 or BCB/4189
<- '2000-01-01'
first_date <- '2023-01-01'
last_date <- get_Quandl_series(id_in = c('Selic' = 'BCB/4189'),
selic api_key = api_key,
first_date = first_date,
last_date = last_date)
<- get_Quandl_series(id_in = c('CDI' = 'BCB/12'),
cdi api_key = api_key,
first_date = first_date,
last_date = last_date)
<- get_Quandl_series(id_in = c('Inflation' = 'BCB/433'),
inf api_key = api_key,
first_date = first_date,
last_date = last_date)
2 Macro Brazil
This is a book containing all class notes.
2.1 Selic
ggplot(selic, aes( x = ref_date, y= value)) + geom_line() + labs(title = "Selic")+
theme(axis.text.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 15, angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = 0, face = "plain"),
axis.title.y = element_text(color = "grey20", size = 15, angle = 90, hjust = .5, vjust = .5, face = "plain")) + theme_solarized()
2.2 CDI
ggplot(cdi, aes( x = ref_date, y= value)) + geom_line() + labs(title = "CDI")+
theme(axis.text.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 15, angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = 0, face = "plain"),
axis.title.y = element_text(color = "grey20", size = 15, angle = 90, hjust = .5, vjust = .5, face = "plain")) + theme_solarized()
2.3 Inflation
ggplot(inf, aes( x = ref_date, y= value)) + geom_line() + labs(title = "Inflation Brazil (IPCA Mensal)")+
theme(axis.text.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 15, angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = 0, face = "plain"),
axis.title.y = element_text(color = "grey20", size = 15, angle = 90, hjust = .5, vjust = .5, face = "plain")) + theme_solarized()
2.4 Term Structure
= get.yield.curve()
ettj <- subset(ettj, type == "nominal_return" )
ettj ggplot(ettj, aes(x=ref.date, y = value) ) +
geom_line(size=1) + geom_point() + facet_grid(~type, scales = 'free') +
labs(title = paste0('The current Brazilian Yield Curve '),
subtitle = paste0('Date: ', ettj$current.date[1])) +
theme(axis.text.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = .5, face = "plain"),
axis.text.y = element_text(color = "grey20", size = 15, angle = 0, hjust = 1, vjust = 0, face = "plain"),
axis.title.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = 0, face = "plain"),
axis.title.y = element_text(color = "grey20", size = 15, angle = 90, hjust = .5, vjust = .5, face = "plain")) + theme_solarized()