contango_hedged: Backtest a Hedged Contango-Based Volatility Trading Strategy

Description Usage Arguments Details Value References

View source: R/contango_hedged.R

Description

Implements the following strategy: Each day, hold XIV/SPXU (weighted for zero beta) if contango > xiv.spxu.cutpoint, hold VXX/UPRO (weighted for zero beta) if contango < vxx.upro.cutpoint, and hold cash otherwise. Perhaps not very useful since XIV closed on Feb. 20, 2018.

Usage

1
2
3
4
contango_hedged(contango, xiv.spxu.gains = NULL, vxx.upro.gains = NULL,
  xiv.spxu.cutpoint = 6.36, vxx.upro.cutpoint = 5.45,
  xiv.allocation = 0.46, vxx.allocation = 0.46, xiv.beta = NULL,
  vxx.beta = NULL, initial = 10000)

Arguments

contango

Numeric vector of contango values at the end of each trading day.

xiv.spxu.gains

2-column numeric matrix with gains for XIV and SPXU. Should have the same number of rows as contango and be date-shifted one value to the right. For example, the first row should have the XIV and SPXU gains for the day AFTER the first contango value.

vxx.upro.gains

2-column numeric matrix with gains for VXX and UPRO. Should have the same number of rows as contango and be date-shifted one value to the right. For example, the first row should have the VXX and UPRO gains for the day AFTER the first contango value.

xiv.spxu.cutpoint

Numeric value giving the contango cutpoint for XIV/SPXU position. For example, if xiv.spxu.cutpoint = 5, XIV/SPXU will be held whenever contango is greater than 5%.

vxx.upro.cutpoint

Numeric value giving the contango cutpoint for VXX/UPRO position. For example, if vxx.upro.cutpoint = -5, VXX/UPRO will be held whenever contango is less than -5%.

xiv.allocation

Numeric value specifying XIV allocation for XIV/SPXU position. For example, if set to 0.46, 46% is allocated to XIV and 54% to SPXU when contango > xiv.spxu.cutpoint.

vxx.allocation

Numeric value specifying VXX allocation for VXX/UPRO position. For example, if set to 0.46, 46% is allocated to VXX and 54% to UPRO when contango < vxx.upro.cutpoint.

xiv.beta

Numeric value specifying XIV's beta. If specified, the function figures out what xiv.allocation needs to be for zero-beta XIV/SPXU positions. For example, if set to 3.5, then 46.2% XIV/53.8% SPXU achieves zero beta.

vxx.beta

Numeric value indicating VXX's beta. If specified, the function figures out what vxx.allocation needs to be for zero-beta VXX/UPRO positions. For example, if set to -3.5, then 46.2% VXX/53.8% UPRO achieves zero beta.

initial

Numeric value giving the initial value of the portfolio.

Details

You can find historical contango values from The Intelligent Investor Blog. You can click the first link at http://investing.kuchita.com/2012/06/28/xiv-data-and-pricing-model-since-vix-futures-available-2004/ to download a zip file containing an Excel spreadsheet. Then, you will need to calculate whatever version of "contango" you prefer. I typically define contango as what percent higher the second-month VIX futures are acompared to the first-month futures, i.e. dividing the "2nd mth" column by the "1st mth" column, subtracting 1, and then multiplying by 100.

To load daily gains for XIV, SPXU, VXX, and UPRO, you can use load_gains, which uses the quantmod package to load data from Yahoo! Finance. You will have to specify the from and to inputs to match the date range for your contango values.

Value

List containing:

  1. Character vector named holdings indicating what fund was held each day (XIV/SPXU, VXX/UPRO, or cash).

  2. Numeric vector named port.gains giving the portfolio gain for each day, which will be 0 for days that cash was held and the weighted XIV/SPXU or VXX/UPRO gain for days that one of those positions was held.

  3. Numeric vector named port.balances giving the portfolio balance each day.

  4. Numeric value named trades giving the total number of trades executed.

References

Ryan, J.A. and Ulrich, J.M. (2017) quantmod: Quantitative Financial Modelling Framework. R package version 0.4-12, https://CRAN.R-project.org/package=quantmod.


vandomed/stocks documentation built on Sept. 2, 2018, 10:10 a.m.