Publications by Henry Joyce

Apply 13

07.12.2023

# Load packages # Core library(tidyverse) library(tidyquant) # Source function source("../00_scripts/simulate_accumulation.R") 1 Import stock prices Revise the code below. Replace symbols with your stocks. Replace the from and the to arguments to date from 2012-12-31 to present. symbols <- c("AAPL", "GOOG", "TSLA") prices <- tq_get(x = sym...

1088 sym R (4608 sym/25 pcs) 2 img

Code Along 13

06.12.2023

# Load packages # Core library(tidyverse) library(tidyquant) # time series library(timetk) Goal Simulate future portfolio returns five stocks: “SPY”, “EFA”, “IJS”, “EEM”, “AGG” market: “SPY” from 2012-12-31 to 2017-12-31 1 Import stock prices symbols <- c("SPY", "EFA", "IJS", "EEM", "AGG") prices <- tq_get(x = symbol...

415 sym R (8091 sym/36 pcs) 2 img

Apply 12

04.12.2023

# Load packages # Core library(tidyverse) library(tidyquant) Goal Examine how each asset contributes to portfolio standard deviation. This is to ensure that our risk is not concentrated in any one asset. 1 Import stock prices Choose your stocks from 2012-12-31 to present. symbols <- c("AAPL", "GOOG", "TSLA") prices <- tq_get(x = symbols, ...

716 sym R (10757 sym/19 pcs) 1 img

Code Along 12

29.11.2023

# Load packages # Core library(tidyverse) library(tidyquant) library(readr) # Time series library(lubridate) library(tibbletime) # modeling library(broom) Goal Examine how each asset contributes to portfolio standard deviation. This is to ensure that our risk is not concentrated in any one asset. five stocks: “SPY”, “EFA”, “IJS”, �...

607 sym R (14262 sym/30 pcs) 4 img

Apply11

16.11.2023

Import your data data(flights) flights %>% skimr::skim() Data summary Name Piped data Number of rows 336776 Number of columns 19 _______________________ Column type frequency: character 4 numeric 14 POSIXct 1 ________________________ Group variables None Variable type: character skim_variable n_missing complete_rate min max empty n_uni...

523 sym 4 tbl

Code Along 11

14.11.2023

Ch19 Functions Introduction When should you write a function? set.seed(1234) df <- tibble::tibble( a = rnorm(10), b = rnorm(10), c = rnorm(10), d = rnorm(10) ) df$a <- (df$a - min(df$a, na.rm = TRUE)) / (max(df$a, na.rm = TRUE) - min(df$a, na.rm = TRUE)) df$b <- (df$b - min(df$b, na.rm = TRUE)) / (max(df$b, na.rm = TRUE) - min(df$b...

290 sym

Apply 10

09.11.2023

# Load packages # Core library(tidyverse) library(tidyquant) Goal Calculate and visualize your portfolio’s beta. Choose your stocks and the baseline market. from 2012-12-31 to present 1 Import stock prices symbols <- c("AAPL", "GOOG", "TSLA") prices <- tq_get(x = symbols, get = "stock.prices", from = "2012-12...

639 sym R (2382 sym/11 pcs) 1 img

Code along 10

07.11.2023

library(tidyverse) library(tidyquant) Goal Measure portfolio risk using kurtosis. It describes the fatness of the tails in probability distributions. In other words, it measures whether a distribution has more or less returns in its tails than the normal distribution. It matters to investors because a distribution with excess kurtosis (kurtosis > ...

851 sym R (2998 sym/17 pcs) 2 img

Apply 9

06.11.2023

# Load packages # Core library(tidyverse) library(tidyquant) Goal Visualize and examine changes in the underlying trend in the performance of your portfolio in terms of Sharpe Ratio. Choose your stocks. from 2012-12-31 to present 1 Import stock prices symbols <- c("AAPL", "GOOG", "TSLA") prices <- tq_get(x = symbols, get = "sto...

851 sym R (3097 sym/11 pcs) 1 img

Code along 9

01.11.2023

library(tidyverse) library(tidyquant) Goal Measure portfolio risk using kurtosis. It describes the fatness of the tails in probability distributions. In other words, it measures whether a distribution has more or less returns in its tails than the normal distribution. It matters to investors because a distribution with excess kurtosis (kurtosis > ...

831 sym R (4569 sym/18 pcs) 3 img