class test

Published

October 4, 2023

library(tidyquant)
Loading required package: lubridate

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
Loading required package: PerformanceAnalytics
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: 'PerformanceAnalytics'
The following object is masked from 'package:graphics':

    legend
Loading required package: quantmod
Loading required package: TTR
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
== Need to Learn tidyquant? ====================================================
Business Science offers a 1-hour course - Learning Lab #9: Performance Analysis & Portfolio Optimization with tidyquant!
</> Learn more at: https://university.business-science.io/p/learning-labs-pro </>
library(simfinapi)
library(gt)
library(tidyverse)
-- Attaching packages --------------------------------------- tidyverse 1.3.1 --
v ggplot2 3.3.5     v purrr   0.3.4
v tibble  3.2.1     v dplyr   1.1.2
v tidyr   1.2.0     v stringr 1.5.0
v readr   2.1.2     v forcats 0.5.1
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x lubridate::as.difftime() masks base::as.difftime()
x lubridate::date()        masks base::date()
x dplyr::filter()          masks stats::filter()
x dplyr::first()           masks xts::first()
x lubridate::intersect()   masks base::intersect()
x dplyr::lag()             masks stats::lag()
x dplyr::last()            masks xts::last()
x lubridate::setdiff()     masks base::setdiff()
x lubridate::union()       masks base::union()
AMZN <- tq_get("AMZN", from = "2022-01-01", to = "2022-12-31")
AMZN
# A tibble: 251 x 8
   symbol date        open  high   low close   volume adjusted
   <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
 1 AMZN   2022-01-03  168.  171.  166.  170. 63520000     170.
 2 AMZN   2022-01-04  170.  171.  166.  168. 70726000     168.
 3 AMZN   2022-01-05  167.  167.  164.  164. 64302000     164.
 4 AMZN   2022-01-06  163.  165.  162.  163. 51958000     163.
 5 AMZN   2022-01-07  164.  165.  162.  163. 46606000     163.
 6 AMZN   2022-01-10  161.  162.  156.  161. 87798000     161.
 7 AMZN   2022-01-11  162.  166.  161.  165. 62806000     165.
 8 AMZN   2022-01-12  167.  167.  164.  165. 50030000     165.
 9 AMZN   2022-01-13  165.  166.  161.  161. 52188000     161.
10 AMZN   2022-01-14  160.  162.  160.  162. 45974000     162.
# i 241 more rows
AMZN %>%
    ggplot(aes(x = date, y = volume)) +
    geom_segment(aes(xend = date, yend = 0, color = volume)) + 
    geom_smooth(method = "loess", se = FALSE)
`geom_smooth()` using formula 'y ~ x'