knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of ROptionsStrategies is to utilize the flexibilities of R and its vast libraries to analyze options data provided through TDAmeritrade API. Although the only available strategy is short put (The Wheel,) strategies such as spread, iron condor, and butterfly are in the development roadmap.
You can install the released version of ROptionsStrategies from CRAN WHEN IT IS AVAILABLE with:
#install.packages("ROptionsStrategies") Not available yet
And the development version from GitHub with:
# install.packages("devtools") devtools::install_github("pohnson/ROptionsStrategies")
The most important data point in this package is the TDAmeritrade's Consumer Key. If you haven't had one yet, please follow this thorough guideline to obtain one: link.
Now, let's assume that you already have one and save it in a csv file. We then can read it like this.
library(ROptionsStrategies) library(tidyverse) consumer_key <- read_csv("consumer_key.csv") %>% as.character()
Let's assume that you can only execute one Wheel trade and wonder if the option should be AMD or XLF. You can use wheel_extractor
to get underlying data as follows:
data <- wheel_extractor( ticker = c('AMD', 'XLF'), expiration_date = '2021-08-06', consumer_key = consumer_key, sleep_second = 1 ) head(data)
But you can also parse data from another data frame using $
:
data_ticker <- data.frame( ticker = c('AMD', 'XLF') ) data2 <- wheel_extractor( ticker = data_ticker$ticker, expiration_date = '2021-08-06', consumer_key = consumer_key, sleep_second = 1 ) head(data2)
Then you can use wheel_visualizer
to inspect which stock at a given risk (Probability OTM) has the highest return.
wheel_visualizer( data = data, include_in_the_money = FALSE )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.