Skip to content

Instantly share code, notes, and snippets.

View ProbablePattern's full-sized avatar
💭
\m/(-_-)\m/

Stephen ProbablePattern

💭
\m/(-_-)\m/
View GitHub Profile
@joshuaulrich
joshuaulrich / intraday-sp500.R
Last active April 26, 2023 13:02
Track the S&P 500 throughout the trading day
require(quantmod)
do_chart <- function(symbol) {
quote <- getQuote(symbol)
quote$Close <- quote$Last
xts(OHLCV(quote), quote[,"Trade Time"],
pct_change = quote[,"% Change"])
}
filename <- "intraday-sp500.rds"
## Load Packages & Define Theme
library(tidyverse)
library(doParallel)
library(parallel)
library(doSNOW)
library(foreach)
library(lubridate)
# Make function
getEm <- function(x) {
set.seed(2)
x <- 1:100
y <- 20 + 3 * x
e <- rnorm(100, 0, 60)
y <- 20 + 3 * x + e
plot(x,y)
yx.lm <- lm(y ~ x)
lines(x, predict(yx.lm), col="red")