Skip to content

Instantly share code, notes, and snippets.

View gwd999's full-sized avatar
🕶️

Walter D. gwd999

🕶️
View GitHub Profile
@xiaodaigh
xiaodaigh / gist:46e3edad9c72dd10ae415e08ac2953c3
Created October 20, 2021 12:50
Simple demonstration of writing Parquet to S3
# to run this firstly set up the MinIO server
# on Windows download this https://dl.min.io/server/minio/release/windows-amd64/minio.exe
# download("https://dl.min.io/server/minio/release/windows-amd64/minio.exe")
# to run minio make sure the executable is in the PATH
# then run
# ;minio.exe server /path/to/minio/data
# e.g. minio.exe server c:/minio-data/
using Minio, Parquet, Parquet2, DataFrames, AWSS3
@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"
library(armacmp)
# Arnold, T., Kane, M., & Lewis, B. W. (2019). A Computational Approach to Statistical Learning. CRC Press.
# logistic regression using the Newton-Raphson
log_reg <- armacmp(function(X, y) {
  beta <- rep.int(0, ncol(X))
  for (i in seq_len(25)) {
    b_old <- beta
    alpha <- X %*% beta
    p <- 1 / (1 + exp(-alpha))
@whizzzkid
whizzzkid / XPS-15 9560 Getting Nvidia To Work on KDE Neon
Last active December 3, 2022 15:43
[XPS 15 Early 2017 9560 kabylake] Making Nvidia Drivers + (CUDA 8 / CUDA 9 / CUDA 9.1) + Bumblebee work together on linux ( Ubuntu / KDE Neon / Linux Mint / debian )
# Instructions for 4.14 and cuda 9.1
# If upgrading from 4.13 and cuda 9.0
$ sudo apt-get purge --auto-remove libcud*
$ sudo apt-get purge --auto-remove cuda*
$ sudo apt-get purge --auto-remove nvidia*
# also remove the container directory direcotory at /usr/local/cuda-9.0/
# Important libs required with 4.14.x with Cuda 9.X
$ sudo apt install libelf1 libelf-dev
@abarbour
abarbour / rlpspec_allbench.R
Last active December 10, 2015 08:48
Add rowwise summary lines to ggplot2::facet_grid style plots.
# Add rowwise summary lines to ggplot2::facet_grid style plots.
# Andy Barbour
# geokook.wordpress.com
# December 2012
## clear workspace
rm(list=ls())
library(multitaper)
library(rbenchmark)
@gwd999
gwd999 / e1071.R
Created December 2, 2012 21:01 — forked from ivannp/e1071.R
Back-testing SVM with e1071
svmComputeOneForecast = function(
id,
data,
response,
startPoints,
endPoints,
len,
history=500,
trace=FALSE,
kernel="radial",
@dsparks
dsparks / Binarize_categories.R
Created September 18, 2012 22:39
Categorical data to indicator matrix to log odds ratios
# Starting with categorical data, ending with a table of log odds ratios
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("plyr", "reshape2")
if(doInstall){install.packages(toInstall,
repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Canonical example of categorical data
HEC <- melt(HairEyeColor)
@dsparks
dsparks / str example.R
Created September 10, 2012 02:46
Illustrating the use of str()
# Let's say you want to display a table of model coefficients
# in order of their significance,
# and you want to plot the distribution of model residuals,
# but you don't know how to access these values.
# Use str().
# Generate some random data
NN <- 1000
theData <- data.frame(Alpha = rnorm(NN),
Beta = rnorm(NN))
require(PerformanceAnalytics)
require(quantmod)
getSymbols("^GSPC", from = "1900-01-01")
#get return series from closing price
ret.bh <- ROC(GSPC[,4],n = 1,type = "discrete")
#change first value from NA to 0
ret.bh[1,] <- 0
@timelyportfolio
timelyportfolio / spainallocation.r
Created July 24, 2012 18:28
spain stocks and bonds
#analyze asset allocation experience in Spain
require(lattice)
require(latticeExtra)
require(reshape2)
require(directlabels)
require(quantmod)
require(PerformanceAnalytics)
require(RQuantLib)