-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Olá, professor.
Baixei os dados de Cosan desde 2010, mas não veio o ano de 2021.
O que está acontecendo?
Código abaixo:
rm(list = ls())
graphics.off()
if (!require("pacman")) install.packages("pacman")
p_load(
GetDFPData2,
tidyverse,
janitor,
here,
lubridate,
tiqyquant
)
select_company <- "cosan"
data_search <-
search_company(select_company) |>
as_tibble() |>
clean_names() |>
filter(sit_reg == "ATIVO")
company_code <-
data_search |>
pull(cd_cvm)
first_year <- 2010
income <-
get_dfp_data(
companies_cvm_codes = company_code,
type_docs = "DRE",
type_format = "con",
first_year = first_year,
last_year = year(Sys.Date())
) |>
pluck(1) |>
clean_names()
select_income <- c(
"Receita de Venda de Bens e/ou Serviços",
"Resultado Bruto",
"Resultado Antes do Resultado Financeiro e dos Tributos",
"Lucro/Prejuízo Consolidado do Período",
)
income_subset <-
income |>
select(
date_start = dt_ini_exerc,
index = cd_conta,
item = ds_conta,
value = vl_conta
) |>
filter(item %in% select_income)
income_subset |>
filter(str_detect(item, "Receita")) |>
tq_mutate(
select = value,
mutate_fun = periodReturn,
period = "annually",
col_rename = "return"
)