Created
May 4, 2020 23:03
-
-
Save alexpghayes/17a97918cc63941bc9279fd25e6070f1 to your computer and use it in GitHub Desktop.
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(riingo) | |
library(tidyverse) | |
riingo_browse_signup() | |
# tweeted at 2020-05-01 15:11:26 UTC | |
# https://twitter.com/elonmusk/status/1256239815256797184 | |
tweet <- rtweet::lookup_statuses("1256239815256797184") | |
tweet$created_at | |
getSymbols("TSLA") | |
data <- riingo_iex_prices(c("TSLA", "SPY"), resample_frequency = "1min") | |
write_rds(data, "~/../Desktop/TLSA-data.rds") | |
tidy <- data %>% | |
pivot_wider( | |
id_cols = date, | |
names_from = ticker, | |
values_from = close | |
) %>% | |
dplyr::select(date, TSLA, SPY) | |
min(tidy$date) | |
max(tidy$date) | |
library(zoo) | |
zood <- read.zoo(tidy) | |
head(zood) | |
pre_tweet <- as.POSIXct( | |
c("2020-05-01 13:35:00", "2020-05-01 15:11:00"), | |
tz = "UTC" | |
) | |
post_tweet <- as.POSIXct( | |
c("2020-05-01 15:12:00", "2020-05-01 17:49:00"), | |
tz = "UTC" | |
) | |
ci <- CausalImpact(zood, pre_tweet, post_tweet) | |
plot(ci) | |
tidy | |
spread(ticker, close) | |
is_supported_ticker("SPY") | |
tsla %>% | |
arrange(desc(date)) | |
library(CausalImpact) | |
?CausalImpact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment