Skip to content
All library documents

Replicating Piecewise Option P&L with Linear Equations

Article Quant Q&A · Author: wrt

Summary

The document describes how to turn a piecewise linear profit-and-loss graph at expiration into a portfolio of calls, puts, and possibly cash or the underlying. It proposes placing option strikes at the graph’s breakpoints, then solving a linear system whose unknowns are the position sizes. The equations match the portfolio’s value at each breakpoint, with extra points beyond the outermost breakpoints to constrain the slopes of the payoff tails.

The method can fail when the chosen set of instruments cannot span the target payoff. Including both calls and puts at the breakpoints or adding the underlying can make a solution possible, though it may leave multiple portfolios that replicate the same graph. The discussion gives a general construction rather than a worked example, and it does not address practical constraints such as discrete contract sizes, transaction costs, or whether quoted premiums make the proposed positions economically attractive.

Key ideas

  • A piecewise linear expiration payoff can be matched by solving for option position sizes in a linear system.
  • Place candidate strikes at the payoff graph’s breakpoints and match portfolio values there.
  • Additional points outside the breakpoints are needed to constrain the slopes of the payoff tails.
  • Adding both puts and calls or the underlying can expand the set of replicable payoffs, but may produce multiple solutions.

Tags

Full text
# Algorithmical replication of a profit and loss function using different options


# Algorithmical replication of a profit and loss function using different options












I often see questions like "Given this payoff graph (example below), construct a portfolio that replicates it." I want to know if there is an efficient method/algorithm to find the individual pieces that comprise it (long/short puts/calls/stock).

So to pose this more mathematically, given profit and loss function below where $x$ is the stock price at expiration and given that each option type has a fixed premium (not necessarily the same, but maybe an easy assumption to start with), can you efficiently recreate this from individual options?

$$ P(x)= \begin{cases} p_0(x), & x \le \beta_0 \\ p_1(x), & \beta_0 \le x \le \beta_1 \\ \qquad. \\ \qquad. \\ \qquad. \\ p_n(x), & \beta_{n-1} \le x \le \beta_n \\ \end{cases} $$

We know that each $p_i(x)$ is either constant or linear and every basic option type has a function associated with it. For example shorting one call with strike price k and premium p gives the function: $$ \begin{cases} p, & x \le k \\ -x+k+p, & x \ge k \\ \end{cases} $$

## Answer by sashkello (score 5, accepted)

https://quant.stackexchange.com/a/10409

Assume $p_i(x)$ is a payoff of one particular option. You can try to reproduce the diagram using a bunch of options with strikes on the breakpoints (underlying is useless, because its payoff can always be modelled by buy&sell of a certain call and put). Then you can create a system of `k` equations with `n` unknowns (number of each kind of option). All other things can be fixed, such as strikes are at breakpoints; everything over ATM will be calls, everything below will be puts.

$\sum w_i p_i(X) = Y$

where $X$ is a breakpoint and $Y$ is return at $X$; $w_i$ are coefficients you are trying to find. In addition, you will need two points anywhere to the right from the rightmost breakpoint and one to the left from the leftmost one, otherwise you are not fixing the slopes of the far OTM tails. All in all, this is a system of linear equations (because $p_i(X)$ is either 0, or some linear return if an option is ITM) and as such should be easy to solve. As an additional parameter, to account for cash you can add another same variable to each of the equations - this will basically shift PnL up or down.

The problem is the system described above won't always have solutions. To ensure you'll always have one in general, you will have to either include both puts and calls for each of the breakpoints, or add the underlying. This will likely produce infinite number of solutions, but that's relatively easy to handle. I'm quite sure many standard PnL's will be resolvable without this amendment.

## Answer by vonjd (score 8)

https://quant.stackexchange.com/a/10416

You can find an exact algorithm with a step-by-step explanation here: https://www.dropbox.com/s/t4fq067kzx26mhw/project_paper.pdf

As you can see from the URL it is an archived document because the original site is unfortunately long gone and the tool referenced in the paper with it :-(

But it should be helpful anyway to understand what is going on.

Notice to the owner of the paper: I put up this paper because it is no longer available on the web and it is a great piece of work. If you are the owner and have a problem with that: Please contact me and I will delete it immediately - Thank you

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.