DataViz - Exploring and Fitting Option Strategies


Previously, I had put together a data visualization that let you explore the Black-Scholes model, which is sometimes used to price stock options. That visualization lets you explore "The Greeks" and see how these change with respect to stock price, strike price, time to expiration, volatility, and the risk-free interest rate.

I've now added more stuff involving stock option strategies and their associated profit/loss curves (with valuations estimated from the Black-Scholes model itself). This is implemented as an additional "tab" added to the previous visualization.

In addition to trying to make it pretty easy to play with different option strategies - custom or standard - I've started playing with being able to fit an option strategy to a set of desired profit/loss points.

Note - not included in the calculations are commission charges, and "slippage" that might occur when trying to exit the positions. For the crazier strategies, there may in fact be no practical way to even exit out all of the positions and capture the profit: that is an area for later research.

As before, this visualization has not yet been optimized much for mobile devices (screenwise or cpu-wise), so for now a desktop is still highly recommended.

Main part of the new "Option Strategies" Tab


Exploring Option Strategies
Some of the preset
option strategies you can quickly select.

Investors implement some option strategies that consist of the purchasing or selling of Call and/or Put options, each with potentially different strike prices. The Profit/Loss curve displays the profit or loss for the strategy as a function of the final stock price. Some of these strategies have colorful names that are (roughly) based on the shape of the Profit/Loss curve for the strategy.

I have tried to make it easy to play with a number of preset option strategies or create your own. A full list of the current preset strategies are shown in the table below. For each one, there is a link that will take you to the app with that strategy automatically loaded. In all cases, the profit/loss curve is based on calculations using the Black-Scholes formula.

Incorporating Stock Price Distribution

In addition to showing the profit/loss curve for a given strategy, I wanted to somehow indicate and incorporate the distribution of stock price at the end of the period (this is for European options). A standard assumption - consistent with the Black-Scholes model itself - is that the stock price follows a geometric Brownian process. So, the resulting distribution is shown at the top (it is actually a lognormal distribution, with parameters based on the initial stock price, the time to expiration, and the volatility). Whether or not you think much of this assumption, the shaded pdf can look pretty nice for some (likely impactical) option strategies.

Interactively Viewing Profit/Loss

As you move your mouse across the profit/loss region, a little (qtip) popup shows the profit/loss at that stock price.

Table of Details on the Strategy
Hovering on the information icon
shows a popup with details on
what the individual buy/sell call/put means.

The table of individual buy/sell call/puts that comprise the strategy are shown in the table on the right side of the visualization. There are buttons that let you copy the strategy info to the clipboard, or download this information in csv or Excel format (trivially made possible via the excellent Datatables jquery plugin). If you hover over the little information icon, details on that particular buy/sell call/put is shown.

Moving your mouse over a row will highlight that component's profit/loss curve.

List of Included Preset Strategies
If you want, you can let it pick a "random" strategy that will consist of a random number of buy/sell calls/puts. An example is shown here - some can have pretty odd profit/loss curves.
See a Random Strategy in App
(opens in new window)
Short Butterfly See this Strategy in App
(opens in new window)
Short Kaleidoscope
This consists of several short butterfly strategies. A group of butterflies is called a "kaleidoscope".
See this Strategy in App
(opens in new window)
Krazy Kaleidoscope
This consists of many, many short butterfly strategies.
See this Strategy in App
(opens in new window)
Iron Butterfly See this Strategy in App
(opens in new window)
Long Butterfly See this Strategy in App
(opens in new window)
Christmas Tree See this Strategy in App
(opens in new window)
Flock of Christmas Trees
This consists of several short Christmas tree strategies. A group of Christmas is called a "flock" (also sprach the Internet).
See this Strategy in App
(opens in new window)
Short Condor See this Strategy in App
(opens in new window)
Long Condor See this Strategy in App
(opens in new window)
Long Strangle See this Strategy in App
(opens in new window)
Short Straddle See this Strategy in App
(opens in new window)
Long Straddle See this Strategy in App
(opens in new window)
Bear Put Spread See this Strategy in App
(opens in new window)
Bull Call Spread See this Strategy in App
(opens in new window)
Fitting a Strategy to Specified Profit/Loss Points

Given a set of points for the profit/loss curve, can you find an option strategy that hits those points? As a first attempt at this interesting problem, I've made use of the jsfit nonlinear least-squares routine by Joseph Meiring (which implements the Levenberg-Marquardt algorithm). Of course, it will probably ultimately be best to exploit the specific underlying structure of the buy/sell call/put curves themselves, but nevertheless it seemed like a fun thing to do to see if the (fairly general) nonlinear curve fitting approach could work.

One major assumption made for these initial attempts is that the number of contracts purchased does not have to be an integral value. I guess you could scale them all by a power of ten to get things integral and still fit the points (after scaling them as well) if you wanted to use the fitted strategy, but such practicality is not part of the focus to date. Instead, I just wanted to see if this would work at all.

With the experimental option fitting component, you can:

  • specify arbitrary profit/loss points
  • specify how many different buy/sell calls/puts to use in the fitting

You add points by clicking anywhere in the profit/loss region. You can move the points around after creating them. Delete individual points by right-clicking on them. Delete all points by clicking the 'Clear Points' button.

You click the 'Fit It' button to perform/update the fit. There may be no fit based on the points selected, the number of buy/sell call/puts selected, and/or the initial points used to start the fitting procedure.

I also played with having the fit automatically update as you added/deleted/moved points. This is currently disabled, but I might reenable that - it is kind of cool as well.

Some examples - good and bad - are shown below.

A pretty good fit...

Not such a great fit, but the difference in iterations
was small enough to cause the fitting procedure to stop...
And Next...

This has been a really fun little project.

Besides some optimization that definitely needs to happen, the primary next step is to look into exploiting the structure of the buy/sell call/put profit curves to have a more reliable fitting procedure, rather than naively throwing a nonlinear curve-fitting approach at it. I've used the Levenberg-Marquardt method before, but not using javascript, and it was a bit satisfying to have that work (thanks to the jsfit routine by Joseph Meiring).

Blancmange fractal curve - currently trying to find a
strategy that has this
as a profit/loss curve (img via wikipedia)

I'm currently trying to replicate the "Blancmange" fractal via butterflies, but this hasn't panned out yet - we're at the mercy of the Black-Scholes-calculated values that complicates things a bit. And maybe a gazillionaire will try to actually implement it. Simply because.

It's easy to get distracted and simply play around with strategies and their parameters, and see what feature might next make sense based on getting the visualization to a certain point. I recently learned of the term "bricoleur" after reading the work of Nassim Taleb, and it resonated with me.

The bricoleur resembles the painter who stands back between brushstrokes, looks at the canvas, and only after this contemplation, decides what to do next.

S. Turkle (via wikipedia)

No comments:

Post a Comment

Popular Posts