Skip to content

Instantly share code, notes, and snippets.

@flare9x
flare9x / vix_term_structure_.R
Last active April 12, 2018 11:03
VIX Term Structure
# Vix Term Strcuture
require(xts)
require(data.table)
require(ggplot2)
require(lubridate)
require(magrittr)
require(scales)
require(reshape2)
require(dplyr)
@flare9x
flare9x / synthetic_vxx.R
Last active April 11, 2018 21:16
Synthetic VXX
# Vix Term Stucture
# Synthetic VXX
require(xts)
require(data.table)
require(ggplot2)
require(lubridate)
require(magrittr)
require(scales)
require(reshape2)
# Vix Term Stucture
# Synthetic XIV
require(xts)
require(data.table)
require(ggplot2)
require(lubridate)
require(magrittr)
require(scales)
require(reshape2)
@flare9x
flare9x / gist:83753c3f162c41a06779c1b93147e06b
Last active May 31, 2024 20:13
VIX1|VIX2 30 Day Constant Maturity
# VIX1|VIX2 30 Day Constant Maturity
# Andrew Bannerman 12.10.2017
require(xts)
require(data.table)
require(ggplot2)
require(lubridate)
require(magrittr)
require(scales)
require(reshape2)
@flare9x
flare9x / gist:933a482ae55c48d5bd91ea07a3773808
Last active December 30, 2017 20:32
Bootstrap meboot volatility strategy
# Meboot time series resampling
# Andrew Bannerman 12.29.2017
require(xts)
require(data.table)
require(ggplot2)
require(lubridate)
require(magrittr)
require(scales)
require(reshape2)
@flare9x
flare9x / gist:8b1ae9ace2ae6e8e35eec89a1b324ddf
Created December 31, 2017 03:19
Block Bootstrap data frame
# Block Bootstrap Time Series
# Andrew Bannerman 12.30.2017
require(xts)
require(data.table)
require(ggplot2)
require(lubridate)
require(magrittr)
require(scales)
require(reshape2)
@flare9x
flare9x / time_series_cross_validation.R
Last active April 11, 2018 21:17
Time Series Cross Validation
# Train / Test Set VXV / VXMT Strategy
# Andrew Bannerman
################################################
# Procedure
# 1. Split data into train / test sets
# 2. Select 1 year look back for each train set (252 days)
# 3. Select 6 months test set (126)
# 4. Re-calibrate on a moving window through entire time series
#################################################
@flare9x
flare9x / Invest each month vs Each year - Average Cost S&P500.r
Last active July 28, 2021 12:54
Invest each month vs Each year - Average Cost S&P500
# Bulk Buy 1x a year Vs investing every month
# Andrew Bannerman 1.3.2018
require(xts)
require(data.table)
require(ggplot2)
require(lubridate)
require(magrittr)
require(scales)
require(reshape2)
@flare9x
flare9x / optimal_f_.R
Last active August 21, 2018 19:40
Optimal F Simulation In R
# Optimal F Simulation In R
# Make random returns
# Adjust $ return output by varying fractional (f)
#######################################################################
# Calculations
# Calculation 1 = Optimal F calculation Start calculation = 1 + fractional amount * trade gain/loss (-/+) / abs(worst.loss)
# Calculation 2 = Optimal F Calculation = prev equity * (1+fractional (f) amount * trade gain/loss (-/+) / abs(worst.loss)
#####################################################################
# Required Packages
@flare9x
flare9x / es.trend.days.R
Created March 27, 2018 17:15
ES Trend Days
# Es Up / Down Trend Isolation
# 2.26.2018
# Andrew Bannerman
###############################################################################################
# Steps
# 1. Define a trend day when the close price was within 25% of the high / low
# 2. Save all dates
# 3. Subset 5 minutes bars, save each day into a list
# 4. Output price plots