Skip to content

Instantly share code, notes, and snippets.

View page1's full-sized avatar

Scott Page page1

View GitHub Profile
@page1
page1 / add_lag_variables.R
Last active October 22, 2017 05:39
Function to easily add lagged variables to a data.table timeseries
# data must be a data.table
# lags is a vector of positive integer lags
add_lag_variables <- function(data, lags){
setkey(data, ticker_id, timestamp)
setorder(data, ticker_id, timestamp)
col_to_lag <- names(data)
col_to_lag <- col_to_lag[!(col_to_lag %in% c('ticker_id', 'timestamp'))]
for(lag in lags){
lag_col_names <- paste(col_to_lag, "lag", lag, sep = "_")
data[,(lag_col_names) := shift(.SD, n = lag, type = 'lag'), by = ticker_id, .SDcols = col_to_lag]
@page1
page1 / poloniexlendingfeegist.py
Last active October 22, 2017 05:40
Get Poloniex Lending Fees
#Poloniex api doesn't give the lending fees that are needed to reconcile accounts.
#Poloniex trade history export also doesn't give the lending fees
#Scraping is the only way I could get this data
#Hope this helps you, no warrenty :)
#Env Vars - POLONIEX_USER, POLONIEX_PASS, POLONIEX_OTP
#Incase you didn't catch that - POLONIEX_OTP - Is the one time password secret needed to make it through 2 factor auth
import os
from xvfbwrapper import Xvfb
@page1
page1 / 0_reuse_code.js
Last active August 29, 2015 14:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
### Keybase proof
I hereby claim:
* I am page1 on github.
* I am scottpage (https://keybase.io/scottpage) on keybase.
* I have a public key whose fingerprint is F81A 8C0E 6161 724D 9C11 1667 2BC9 CD34 814A 6EA5
To claim this, I am signing this object: