Publications by Sondre Asheim

CodeAlong6

08.10.2023

# Load packages # Core library(tidyverse) library(tidyquant) Goal Collect individual returns into a portfolio by assigning a weight to each stock five stocks: “SPY”, “EFA”, “IJS”, “EEM”, “AGG” from 2012-12-31 to 2017-12-31 1 Import stock prices # Choose stocks symbols <- c("SPY", "EFA", "IJS", "EEM", "AGG") # Using tq...

343 sym R (6905 sym/17 pcs) 6 img

Apply5

05.10.2023

# Load packages # Core library(tidyverse) library(tidyquant) Goal Collect individual returns into a portfolio by assigning a weight to each stock Choose your stocks. “ROKU”, “AAPL”, “CL=F” from 2012-12-31 to 2017-12-31 1 Import stock prices # Choose stocks symbols <- c("ROKU", "AAPL", "CL=F") # Using tq_get() ---- prices <- ...

498 sym R (2231 sym/8 pcs) 1 img

CodeAlong5

01.10.2023

# Load packages # Core library(tidyverse) library(tidyquant) Goal Collect individual returns into a portfolio by assigning a weight to each stock five stocks: “SPY”, “EFA”, “IJS”, “EEM”, “AGG” from 2012-12-31 to 2017-12-31 1 Import stock prices # Choose stocks symbols <- c("SPY", "EFA", "IJS", "EEM", "AGG") # Using tq...

300 sym R (2527 sym/10 pcs) 3 img

Apply4

28.09.2023

1 Import stock prices of your choice 2 Convert prices to returns by quarterly ## # A tibble: 48 × 3 ## asset date returns ## <chr> <date> <dbl> ## 1 NFLX 2020-03-31 0.130 ## 2 NFLX 2020-06-30 0.192 ## 3 NFLX 2020-09-30 0.0943 ## 4 NFLX 2020-12-31 0.0783 ## 5 NFLX 2021-03-31 -0.0359 ## 6 NFLX 2021-06-30...

292 sym 1 img

CodeAlong4

25.09.2023

# Load packages # Core library(tidyverse) library(tidyquant) Goal Take raw prices of five individual stocks and transform them into monthly returns five stocks: “SPY”, “EFA”, “IJS”, “EEM”, “AGG” 1 Import stock prices ## Choose stocks symbols <- c("SPY", "EFA", "IJS", "EEM", "AGG") prices <- tq_get(x = symbols, ...

214 sym R (1504 sym/5 pcs) 1 img

CodeAlong3PerformanceAnalysis

18.09.2023

# Load packages library(tidyverse) ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr 1.1.3 ✔ readr 2.1.4 ## ✔ forcats 1.0.0 ✔ stringr 1.5.0 ## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1 ## ✔ lubridate 1.9.2 �...

142 sym R (5282 sym/12 pcs)

CodeAlong3ReproducibleFinance

18.09.2023

Provide major takeaways from Chapter 1 in 50 words. “Reproducible finance is a philosophy about how to do quantitative, data science-driven financial analysis”. This book focuses on three universes, which are “xts”, “tidyverse”, and “tidyquant”. Data visualization is where we translate numbers into shapes and colors, and it wil...

489 sym

CodeAlong3tq

19.09.2023

# Load packages library(tidyverse) ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr 1.1.3 ✔ readr 2.1.4 ## ✔ forcats 1.0.0 ✔ stringr 1.5.0 ## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1 ## ✔ lubridate 1.9.2 �...

118 sym R (3223 sym/14 pcs)

Apply3

21.09.2023

# Load packages library(tidyverse) library(tidyquant) 1 Get stock prices and convert to returns Ra <- c("AAPL", "ROKU", "CL=F") %>% tq_get(get = "stock.prices", from = "2022-01-01") %>% group_by(symbol) %>% tq_transmute(select = adjusted, mutate_fun = periodReturn, perio = "monthly", ...

447 sym R (3047 sym/11 pcs)

Code3ChartingTidyquant

13.09.2023

# Load packages library(tidyverse) # core functions ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr 1.1.3 ✔ readr 2.1.4 ## ✔ forcats 1.0.0 ✔ stringr 1.5.0 ## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1 ## ✔ lubri...

64 sym R (5101 sym/13 pcs) 3 img