Publications by Henry Joyce
Code Along 5
# 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_get()...
297 sym R (2200 sym/9 pcs) 2 img
Apply 3
# Load packages library(tidyverse) library(tidyquant) 1 Get stock prices and convert to returns Ra <- c("AAPL", "GOOG", "TSLA") %>% tq_get(get = "stock.prices", from = "2010-01-01") %>% group_by(symbol) %>% tq_transmute(select = adjusted, mutate_fun = periodReturn, period = "month...
203 sym R (3072 sym/11 pcs)
Apply 4
# Load packages library(tidyverse) library(tidyquant) 1 Import stock prices of your choice # Choose stocks symbols <- c("AAPL", "GOOG", "TSLA") prices <- tq_get(x = symbols, get = "stock.prices", from = "2012-01-01", to = "2017-01-01") 2 Convert prices to returns by quarterly asset_returns...
346 sym R (1466 sym/5 pcs) 1 img
Apply 4
# Load packages library(tidyverse) library(tidyquant) 1 Import stock prices of your choice # Choose stocks symbols <- c("AAPL", "GOOG", "TSLA") prices <- tq_get(x = symbols, get = "stock.prices", from = "2012-01-01", to = "2017-01-01") 2 Convert prices to returns by quarterly asset_returns...
332 sym R (1466 sym/5 pcs) 1 img
Code Along 4
# Load packages # Core 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 ...
218 sym R (3902 sym/8 pcs) 1 img
Code Along 3
# 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 ✔ tid...
142 sym R (5205 sym/12 pcs)
Apply Week 3
# Load packages library(tidyverse) library(tidyquant) 1 Get stock prices and convert to returns Ra <- c("AAPL", "GOOG", "TSLA") %>% tq_get(get = "stock.prices", from = "2010-01-01") %>% group_by(symbol) %>% tq_transmute(select = adjusted, mutate_fun = periodReturn, period = "month...
203 sym R (3082 sym/11 pcs)
Apply 2
Import stock prices stocks <- tq_get(c("AAPL", "GOOG"), get = "stock.prices", from = "2016-01-01") stocks ## # A tibble: 3,872 × 8 ## symbol date open high low close volume adjusted ## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 AAPL 2016-01-04 25.7 26.3 25.5 26.3 27...
388 sym Python (8841 sym/34 pcs) 2 img
Code Along 2
Coding basics R as a calculator 1000 / 10 ## [1] 100 x <- 1000 / 10 # x assignment symbol What’s in a name? Calling functions Use of TAB seq(from = 1, to = 10, by = 1) ## [1] 1 2 3 4 5 6 7 8 9 10 continuation character, + seq(from = 1, to = 10) ## [1] 1 2 3 4 5 6 7 8 9 10 Printing to screen y <- seq(from = 1, to = 10) y...
171 sym Python (229 sym/9 pcs)
Code Along 2 Chapter 5
Import data flights ## # A tibble: 336,776 × 19 ## year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time ## <int> <int> <int> <int> <int> <dbl> <int> <int> ## 1 2013 1 1 517 515 2 830 819 ## 2 2013 1 1 533 529 ...
523 sym Python (19789 sym/51 pcs) 1 img