We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 9.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"sicD","sic2","sic3","sic4","division","major_group","industry_group","industry" | |
"A","01","011","0111","Agriculture, Forestry, And Fishing","Agricultural Production Crops","Cash Grains","Wheat" | |
"A","01","011","0112","Agriculture, Forestry, And Fishing","Agricultural Production Crops","Cash Grains","Rice" | |
"A","01","011","0115","Agriculture, Forestry, And Fishing","Agricultural Production Crops","Cash Grains","Corn" | |
"A","01","011","0116","Agriculture, Forestry, And Fishing","Agricultural Production Crops","Cash Grains","Soybeans" | |
"A","01","011","0119","Agriculture, Forestry, And Fishing","Agricultural Production Crops","Cash Grains","Cash Grains, Not Elsewhere Classified" | |
"A","01","013","0131","Agriculture, Forestry, And Fishing","Agricultural Production Crops","Field Crops, Except Cash Grains","Cotton" | |
"A","01","013","0132","Agriculture, Forestry, And Fishing","Agricultural Production Crops","Field Crops, Except Cash Grains","Tobacco" | |
"A","01","013","0133","Agriculture, Forestry, And Fishing","Agricultural Pro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(scales) | |
scrapy_stocks <- function(stock){ | |
if ("rvest" %in% installed.packages()) { | |
library(rvest) | |
}else{ | |
install.packages("rvest") | |
library(rvest) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(lubridate) | |
library(leaflet) | |
# https://www.fakenamegenerator.com/order.php | |
# go there to generate fake addresses, don't forget to select to include longitude and latitude | |
addresses <- read_csv("FakeNameGenerator.com_f201506b.csv") | |
addresses <- addresses %>% mutate(Birthday = mdy(Birthday), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What is PCA? | |
# - PCA is a form of multi-dimensional scaling. | |
# - It transforms the data into a lower dimensional space while keeping the maxiumum of information. | |
# Book: Multi-Dimensional Diversification | |
# get data https://www.msci.com/end-of-day-data-search | |
library(tidyverse) | |
library(tidyquant) | |
library(readxl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyquant) | |
ty10 <- tq_get("DGS10", get = "economic.data", from = as.Date("1950-01-01")) | |
mod_dur <- function(yield) { | |
# out <- (1-(1/(1+0.5*yield/100)^(2*10)))/(yield/100) | |
out <- (1-(1/(1+0.5*yield)^(2*10)))/(yield) | |
return(out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(jsonlite) | |
get_earnings <- function(symbol, av_key, get = "quarterly", cache_dir = "cache") { | |
if (!(cache_dir %in% list.dirs(full.names = F, recursive = F))) { | |
dir.create(cache_dir) | |
} | |
if (!(paste0(symbol, ".json") %in% list.files(cache_dir))) { | |
print("downloading") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(tidyquant) | |
library(lubridate) | |
# get data from Yahoo ---- | |
spx <- tq_get("^GSPC") | |
# calculate returns ---- | |
ret_daily <- spx %>% | |
mutate(ret = adjusted/lag(adjusted)-1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
ui <- fluidPage( | |
fluidRow( | |
column(width = 12, | |
tabsetPanel( | |
tabItem("main", "MENU"), | |
tabItem("more", uiOutput("hello")) | |
)) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(shinyWidgets) | |
library(tidyverse) | |
# read persistent data or create a new file if it does not exist yet | |
if ("favs.csv" %in% list.files()) { | |
favs <- read_file("favs.csv") %>% | |
strsplit(", ") %>% | |
.[[1]] %>% | |
as.numeric() %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(ggplot2) | |
periods <- 10 | |
trend <- 0 | |
vola <- 0.1 | |
leverage <- 2 |
NewerOlder