knitr::opts_chunk$set(collapse = T, comment = "#>")
options(tibble.print_min = 4L, tibble.print_max = 4L)
library(dplyr)
library(data.table)
library(tidyoptions)

When creating tidy options data you must:

The tidyoptions package makes these steps fast and easy:

This document introduces you to tidyoptions's functions and shows you how to apply them.

Raw options data:

Sample of the data retrieved from iVolatility.com read in from the raw .csv files

knitr::kable(raw_example[, 1:10])
knitr::kable(raw_example[, 11:22])

As you can see the dataset is not quite ready for use in studies:

Functions included in the package:

Create tidy options data with tidy_options()

tidy_options() creates the final tidy output data.frame. The first arguement is the name of the underlying you are processing, for example "XLE". The second and third arguements are the folder holding the raw options .csv files, and the iv file with the root being your working directory.

Example call:

tidy_options("XLE", "data/raw_files/options", "data/volatility/vx.xle.daily.prices.RData")

Output is saved to "data/options/symbol.options.RData"

Sample output:

knitr::kable(processed_example[, 1:7])
knitr::kable(processed_example[, 8:16])
knitr::kable(processed_example[, 17:23])

Create data.frames of dates to open trades:

each function takes the arguements start_yr and end_yr

Market closed:

market_closed creates data.frame of all dates the market was closed from start_yr to end_yr market_closed.RData is included in the package with start and end dates of 2010 - 2016.

Calculate monthly expiration dates third_friday()

third_friday calculates the monthly expiration dates for the arguements start_yr, end_yr which is then used in studies to limit opening trades to monthly expirations. These values are not exported as a dataset but rather added to the processed option dataset.

Earnings dates:

earnings_dates() creates a data.frame of the earnings dates from csv files that need to be updated manually as the time window of data expands. earnings.RData is included in the package with start and end dates of 2010 - 2016.



themechanicalbear/options.data documentation built on May 31, 2019, 9:48 a.m.