mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
Adds Intro Guide for the Stock Options SDK Module (#3298)
* Adds Guide for Options SDK Module * Improves One Screenshot * missing a space * typo * makes requested changes. * Removes `s` from `Introduction` Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com>
This commit is contained in:
82
website/content/SDK/stocks/options/_index.md
vendored
82
website/content/SDK/stocks/options/_index.md
vendored
@@ -1,6 +1,82 @@
|
||||
---
|
||||
title: options
|
||||
keywords: ""
|
||||
excerpt: ""
|
||||
title: Introduction to Options
|
||||
keywords: "stocks, options, calls, puts, gamma, delta, iv, theta, rho, greeks, charm, vanna, vomma, derivatives, contracts, ^SPX, ^VIX, ^NDX, chains, oi, vol, volume, open, interest, expiration, dte, volatility, underlying"
|
||||
excerpt: "This guide introduces the Stock Options module, within the context of the OpenBB SDK"
|
||||
geekdocCollapseSection: true
|
||||
---
|
||||
The Stock Options module of the OpenBB SDK wraps the functions of the Options [sub-menu](https://openbb-finance.github.io/OpenBBTerminal/terminal/stocks/options/) within the [OpenBB Terminal](https://openbb-finance.github.io/OpenBBTerminal/terminal/). This allows the user greater flexibility when researching and anlayzing options data. Start a Python script of Notebook file by importing the dependencies:
|
||||
|
||||
```python
|
||||
from openbb_terminal.sdk import openbb
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
%matplotlib widget
|
||||
```
|
||||
|
||||
## How to Use
|
||||
|
||||
All functions within the Options module are printed with: `openbb.stocks.options`
|
||||
|
||||

|
||||
|
||||
The [Unusual Options function](https://openbb-finance.github.io/OpenBBTerminal/terminal/stocks/options/unu/) returns a Tuple containing the DataFrame and a timestamp from when the list was last updated.
|
||||
|
||||
```python
|
||||
unusual_options,timestamp = openbb.stocks.options.unu()
|
||||
unusual_options
|
||||
```
|
||||
|
||||

|
||||
|
||||
Get up to ten years of historical put/call ratios (US equity options only), with the `PCR` function:
|
||||
|
||||
```python
|
||||
pcr_spy = openbb.stocks.options.pcr(symbol = 'SPY', start_date = '2012-11-03')
|
||||
pcr_spy.rename(columns = {'PCR': 'Put/Call Ratio'})
|
||||
```
|
||||
|
||||

|
||||
|
||||
The list of expiration dates is generated with:
|
||||
|
||||
```python
|
||||
openbb.stocks.options.option_expirations('SPY')
|
||||
```
|
||||
|
||||
Get the raw DataFrame for an options chain from yFinance by using:
|
||||
|
||||
```python
|
||||
SPY221111 = openbb.stocks.options.chains_yf(symbol = 'SPY', expiry = '2022-11-11')
|
||||
|
||||
SPY221111
|
||||
```
|
||||
|
||||

|
||||
|
||||
Getting all option chains for the underlying symbol as a single Pandas DataFrame requires a little bit of scripting prior to analysis. This will query Tradier as the data source:
|
||||
|
||||
```python
|
||||
from openbb_terminal.sdk import openbb
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
expirations = openbb.stocks.options.option_expirations(symbol = 'SPY')
|
||||
options_df: pd.DataFrame = []
|
||||
|
||||
for expirations in expirations:
|
||||
options_df.append(openbb.stocks.options.chains(symbol = 'SPY', expiry = expirations))
|
||||
|
||||
options_df = pd.concat(options_df)
|
||||
|
||||
options_df.set_index(keys = 'symbol', inplace = True)
|
||||
|
||||
options_df
|
||||
```
|
||||
|
||||
Depending on the depth of options available, compiling the data may take upwards of thirty seconds.
|
||||
|
||||

|
||||
|
||||
Reference in New Issue
Block a user