## Warning: package 'simfinR' was built under R version 4.0.3
## 
## Warning: package 'tidyverse' was built under R version 4.0.2
## Warning: replacing previous import 'vctrs::data_frame' by 'tibble::data_frame'
## when loading 'dplyr'
## -- Attaching packages --------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.3     v dplyr   1.0.0
## v tidyr   1.0.2     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## Warning: package 'ggplot2' was built under R version 4.0.2
## Warning: package 'tibble' was built under R version 4.0.2
## Warning: package 'dplyr' was built under R version 4.0.2
## -- Conflicts ------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## Warning: package 'ggthemes' was built under R version 4.0.2
# get info
df_info_companies <- simfinR_get_available_companies(apikey)

# check it
glimpse(df_info_companies)
## Rows: 2,895
## Columns: 3
## $ simId  <int> 171401, 901704, 994625, 45730, 378251, 987611, 896477, 41886...
## $ ticker <chr> "ZYXI", "ZYNE", "ZUO", "ZUMZ", "ZTS", "ZSAN", "ZS", "ZNGA", ...
## $ name   <chr> "ZYNEX INC", "Zynerba Pharmaceuticals, Inc.", "ZUORA INC", "...
filter(df_info_companies,ticker=="CAKE" |ticker=="DFRG")
##    simId ticker                   name
## 1 817638   CAKE CHEESECAKE FACTORY INC

817638 CAKE CHEESECAKE FACTORY INC

id <- 817638 # Cheesecake factory

cake <- simfinR_get_fin_statements(
  id,
  apikey,
  type_statements = c("pl", "bs", "cf"),
  periods = "FY",
  years = 2016:2020,
  cache_folder = "simfin_cache"
)
## Fetching data for companies: 817638
## Fetching data for years: 2016, 2017, 2018, 2019, 2020
## Periods: FY
## 
## Making sure all company ids are available
##  - all good
## 
## Start grabbing data
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=FY | year=2016
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=bs | period=FY | year=2016
##  Cant find data..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=cf | period=FY | year=2016
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=FY | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=bs | period=FY | year=2017
##  Cant find data..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=cf | period=FY | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=FY | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=bs | period=FY | year=2018
##  Cant find data..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=cf | period=FY | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=FY | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=bs | period=FY | year=2019
##  Cant find data..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=cf | period=FY | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=FY | year=2020
##  Cant find data..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=bs | period=FY | year=2020
##  Cant find data..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=cf | period=FY | year=2020
##  Cant find data..
type_statements <- 'pl' # profit/loss
periods = c('Q1', 'Q2', 'Q3', 'Q4') # final year
years = 2017:2020

quarter <- simfinR_get_fin_statements(817638,
                                     type_statements = type_statements,
                                     periods = periods,
                                     year = years,
                                     api_key = apikey)
## Fetching data for companies: 817638
## Fetching data for years: 2017, 2018, 2019, 2020
## Periods: Q1, Q2, Q3, Q4
## 
## Making sure all company ids are available
##  - all good
## 
## Start grabbing data
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2020
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2020
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2020
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2020
##  Cant find data..
net_income <- quarter %>% 
              filter(acc_name == 'Net Income')



ggplot(net_income,
            aes(x = ref_date, y = acc_value,fill=year)) +
  geom_col()  + 
  labs(title = 'Quarterly Net Income of CHEESECAKE FACTORY',
       x = '',
       y = 'Yearly Profit',
       subtitle = '',
       caption = 'Data from simfin <https://simfin.com/>') + 
  theme_bw()

# Operating Expenses

exp <- quarter %>% 
              filter(acc_name == 'Operating Expenses')



ggplot(exp,
            aes(x = ref_date, y = acc_value,fill=as.factor(year))) +
  geom_col()  + 
  labs(title = 'Operating Expenses of CHEESECAKE FACTORY',
       x = '', y = 'Quarterly',
       subtitle = '',
       caption = 'Data from simfin <https://simfin.com/>') + 
  theme_bw()

id <- 817638

type_statements <- 'pl' # profit/loss
periods = c('Q1', 'Q2', 'Q3', 'Q4') # final year
years = 2016:2020

df_fin_quarters <- simfinR_get_fin_statements(id,
                                     type_statements = type_statements,
                                     periods = periods,
                                     year = years,
                                     api_key = apikey)
## Fetching data for companies: 817638
## Fetching data for years: 2016, 2017, 2018, 2019, 2020
## Periods: Q1, Q2, Q3, Q4
## 
## Making sure all company ids are available
##  - all good
## 
## Start grabbing data
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2016
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2016
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2016
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2016
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2017
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2018
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2019
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q1 | year=2020
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q2 | year=2020
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q3 | year=2020
##  Table found. Fetching it..
## Fetching data for CHEESECAKE FACTORY INC (817638) | type=pl | period=Q4 | year=2020
##  Cant find data..
net_income <- df_fin_quarters %>% 
              filter(acc_name == 'Net Income')

ggplot(net_income,
            aes(x = period, y = acc_value,fill=year)) +
  geom_col() + facet_grid(~year, scales = 'free') + 
  labs(title = 'Quarterly Profit of CHEESECAKE FACTORY',
       x = 'Quarters',
       y = 'Net Profit') + 
  theme_bw()

library(quantmod)
## Warning: package 'quantmod' was built under R version 4.0.2
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## Loading required package: TTR
## Warning: package 'TTR' was built under R version 4.0.2
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## Version 0.4-0 included new data defaults. See ?getSymbols.
getSymbols("CAKE", from = "2020-01-01")
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## [1] "CAKE"
candleChart(CAKE, up.col = "blue", dn.col = "red", theme = "white", 
            TA="addVo();addBBands();addCCI();addCMF();addRSI()")