Publications by Daniel Lee
Apply 13
# Load packages # Core library(tidyverse) library(tidyquant) 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("NVDA", "TSLA", "AMD", "MSFT") prices <- tq_get(x = symbols, get = "stock.prices", ...
1469 sym R (10226 sym/36 pcs) 1 img
Document
# 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("TSLA", "NFLX", "COST", "GOOG", "AMZN") prices <- t...
1222 sym R (5100 sym/24 pcs) 1 img
Code Along 13
# 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...
466 sym R (8999 sym/38 pcs) 2 img
Apply to your Data 12
Import your data data2 <- read_excel("../00_data/MyData.xlsx") data("mtcars") mtcars <- as_tibble(mtcars) Repeat the same operation over different columns of a data frame Case of numeric variables mtcars %>% map_dbl(.x = ., .f = ~mean(x = .x)) ## mpg cyl disp hp drat wt qsec ## 20.090625 6.187500...
381 sym Python (10357 sym/50 pcs) 1 img
Document
# 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("COST", "TSLA", "NFLX", "GOOG") prices <- tq_get(x = symb...
962 sym R (23712 sym/22 pcs) 1 img
Code Along 12
# Load package library(tidyverse) library(tidyquant) Chapter 20 Vectors Introduction Vector basics Importatant types of atomic vectors 4 Using atomic vectors sample(10) + 10 ## [1] 15 16 12 13 14 20 19 11 17 18 1:10 + 1:2 ## [1] 2 4 4 6 6 8 8 10 10 12 1:10 + 1:3 ## [1] 2 4 6 5 7 9 8 10 12 11 data.frame(a = 1:10, b = 1:2) ## ...
346 sym R (2041 sym/51 pcs)
Document
# 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”, �...
672 sym R (15576 sym/23 pcs) 2 img
Document
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_u...
587 sym Python (3254 sym/24 pcs) 4 tbl
Apply to your Data 12
# 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. 1 Import stock prices Choose your stocks from 2...
1180 sym R (23445 sym/23 pcs) 2 img
Code Along 12
# 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”, �...
687 sym R (15512 sym/23 pcs) 2 img