Using Quantum Computers to Price Options

Alexander Yevchenko
Geek Culture
Published in
23 min readJun 20, 2022
Unsplash

While still in its infancy, quantum computing is already showing promising speedups to classically expensive computational problems. And while the industry still faces its fair share of criticism, many financial institutions are realizing the importance of this technology moving into the future and have made significant investments to beat their competitors to market.

With developments in classical computing, a market simulation that would have taken days on a state-of-the-art computer in the 70’s now takes only a few minutes on your home laptop. Quantum computing is seen as the next catalyst for improvement on computation. Bankers might see a massive speedup on computationally complex problems like market simulations and they’re willing to take a bet in early investment in the tech. The earliest adopters, or better put the first to get the tech to market, are sitting on a goldmine.

How might a quantum computer be put to use in the hands of a bank? There are, obviously, many different answers to that question. Some might say credit risk evaluations, others might point to insurance premium calculations, but here I would like to point in the direction of pricing options.

What is an Option?

In essence, an option is a financial contract that gives the holder the right, but not an obligation, to buy (call option) or sell (put option) a financial asset at an established price (strike) in a given timeframe (exercise window).

In the case an investor buys a call option, they believe that the trend of a stock in the exercise window will trend upwards beyond their strike price. For example, if an investor purchased a call option at the $30 strike, and a week later the underlying stock is trading at $40, they can exercise their call option and net the difference between the current price of the stock and the strike. More explicitly, the investor is able to exercise their call option and buy the underlying for $30, and immediately sell for the current $40 market price. Of course, there is a fee (the premium) associated with buying the call option which one must take into account when calculating returns.

Profit and Loss (P/L) graph for a call option with the $102.5 strike price. As the price of the underlying moves above the strike, an investor nets a profit. As the price of the underlying moves downwards, an investor nets a loss. The most an investor risks to lose is the price of the option (the premium). Investopedia

Put options have the same intuition, but in reverse. These options are betting that the price of a stock will fall below a strike price in a given exercise window. In this vein, an investor may purchase a put option and when the stock falls below a given strike, the investor may sell at a higher price than the current market price, netting them the difference between their strike and the market.

P/L graph for a put option. As the underlying stock trades below our strike, an investor stands to make money. However, as the underlying stock trades near and above the strike, the investor stands to lose money, up to the cost of the premium on the put. Investopedia

Why Options?

An intuition or question you may have is this:

Why not just purchase or short the shares I’m interested in? Why do I need an option?

Options provide several advantages that buying equities does not offer. First of all, options give higher leveraging power. An investor can purchase a position in a security at a much lower cost that what if would have cost them to buy an equal position in stock. As such, they give investors more freedom in terms of capital allocation.

Options offer another way to mitigate risk in portfolios, as they are often used as a hedging mechanism. As a hedge, options work to minimize the downside if an investor’s trade goes sour. A put option (where we’re guaranteed to sell at a set price) would help offset any losses an investor might incur in the case that a security’s price went tumbling down.

They also help increase returns when used wisely. Due to the fact that options oftentimes are more receptive to changes in the underlying stock’s movement, they offer higher returns on investment than equity purchases. For example, if the price of the underlying ticks up 1%, my call option may bounce up 10% in value. Of course the inverse, where an investor may lose 10%, is a possibility and a major motivator for due diligence.

Options give investors the option of not only taking positions in equity markets, but also allowing them to make bets on a market’s volatility and the passage of time, no matter what the general movement of the market is. They offer an effective alternative to those seeking additional opportunities to generate returns outside of stocks and bonds.

Financial derivatives, especially options, make up a large part of global markets. In 2021, there were over 33 billion options contracts traded worldwide, up from over 21 billion from the year prior. Ensuring that options are priced correctly is a huge concern for financial institutions to make sure they have validly assessed risk and are maximizing profits on the contracts they offer and trade.

Pricing the Premium

Any attempt at option pricing has to be based in an attempt to price the underlying into the future. Since the option derives its value from the price of the underlying, we must understand how the underlying security will develop to accurately assess how the option will develop.

Pricing the underlying, and thereby the option, relies on three main factors: the price of the underlying, the time value of the option, and the implied volatility of the underlying.

As may be inferred, the price of the underlying is the main factor behind the premium of the option. To have the right to buy or sell a stock that is currently trading at $1000, the premium paid must be higher than to have the same rights on a $10 stock. Otherwise, there would be no incentive for investors to buy options on the cheaper stock as there would be more opportunity in the more expensive one.

The time value of an option refers to the amount of time between the time of purchase and the expiry of the option. The more time there is until the expiration of the option, the more opportunity there is for the underlying asset to reach the designated strike. As such, an option expiring 6 months from the time of purchase is more expensive than an option expiring in 3 months at the same strike.

Another factor that must be considered is the implied volatility of the underlying asset. The price of an option increases as the seller’s perception of the volatility of the underlying increases. The price increases because the the buyer stands to make more money on an asset that fluctuates 10% in comparison to a more established security that may fluctuate 1%. The seller stands to lose more money in a more volatile security, and the risk they take on in selling an option on that security is priced into the premium.

The Bottom Line

When considering whether or not to purchase an option, the essential question can be boiled down to:

Do I make money by buying this option?

Of course, this is a very difficult question to answer. A concrete answer would entail knowing the future price action of the market, a fairytale to most bankers. But, how do they currently try to answer this question?

One valid approach to answer this question is an analytical approach, taking advantage of the stochastic nature of markets to boil down their evolution into a formula which we can solve. I’m of course making reference to the Black-Scholes-Merton Formula, which is perhaps the most famous formula of modern finance.

BSM model, which encapsulates options into a concrete mathematical formula, taking into account cost of the underlying, time value, and the implied volatility of an underlying to predict the profitability of an option. Suhail Saqan

The BSM model was revolutionary because it was the first mathematical grounding of pricing options, despite the basic intuitions driving derivative markets decades beforehand. It incorporated Brownian Motion into the movement of markets, which was a powerful realization that acknowledged that markets acted like a random walk as they progressed through time.

Various limitations exists in the formula, including assuming a constant risk-free rate over time, a constant volatility over time, and stocks not paying dividends, to name a few. Despite these setbacks, bankers have adapted the formula to help accurately price options over time using partial derivatives, referred to as the Greeks.

Monte Carlo

Another approach is simulating the market many times over until convergence on a good estimate for an option’s payoff. This method is referred to as a Monte Carlo simulation, and is especially useful in pricing options that would be difficult or impossible to price using an analytical method like BSM.

Monte Carlo simulation of a commodity. Each path represents a different simulation of a random walk in the price of a security. As we continue adding paths, they begin to converge, giving investors a estimate of the future price dynamics. Supply Chain Data Analytics

Monte Carlo remains the most effective (classical) way to price complex, path-dependent options. These options, as the name implies, derive their value at various points throughout the option contract’s exercise window, and thus complete knowledge of the market dynamics of the underlying are often required to price them. Path-dependent options include barrier options, lookback options, and Asian options.

Example of a path-dependent barrier option, where the option contract is only exercisable when the price of the underlying has crossed a ‘barrier’. Investopedia

Running a simulation of the option’s payoff to a point where an investor feels confident enough to make an investment is a computationally expensive task. With modern advances in computer technology, the time it takes to run all of these paths has been drastically reduced, but nonetheless, pricing a portfolio of millions of options often takes several hours to complete, and thus is used to analyze portfolios overnight.

Quantum Amplitude Estimation

Quantum computing holds significant promise in options pricing, using the Quantum Amplitude Estimation algorithm to propose a quadratic speedup when compared to classical Monte Carlo methods of pricing options.

Quadratic speedup achieved when using Quantum Amplitude Estimation to price options, where M is the number of quantum samples used.

Since this speedup can be applied to classically hard-to-price options, quantum computers may very well be the future of efficient options pricing.

Laying Out the Groundwork

There are 3 steps outlined to achieve option pricing on a quantum computer:

We capture the random walk evolution of a set of underlyings in set X. We compute the payoff of this set in the second step. In the third step, we compute the expectation value of the probability distribution of the payoff function to find a fair price for the option.

To achieve these steps, we may take advantage of pre-existing quantum algorithms to implement in our circuit.

  1. Loading the Probability Distribution

In the first step, we may take advantage of various quantum machine learning algorithms to efficiently load probability distribution onto a quantum register. Various approaches exist, including Artificial Neural Networks (ANN) and quantum Generative Adversarial Networks (QGAN).

ANNs are generally more computationally expensive to conduct on quantum registers, but are still of use in overnight options risk calculations, especially across larger models and portfolios. The computational cost mainly comes from training the ANN models, which requires both high processing power and relatively large periods of time.

QGANs are also useful when considering options pricing. This is because of their ability to learn the random distribution X by observing price paths and directly loading that probability distribution onto a quantum register.

Visualization of a QGAN. The generator does its best to create a perfect replica of the real data, while the discriminator determines which data is fake (generator created) and which is real. The general idea is that the generator will create high-quality fake data, which will reach the exact representation of the random distribution of the underlyings on a quantum computer. Pennylane

QGANs are useful when considering time- and hardware-constrained problems, particularly on NISQ-era computers with low fidelities. This is due to the fact that we can leverage their form to construct short-depth (ie. low gate-count) circuits to minimize the amount of error introduced into the system.

In addition, the business usefulness of QGANs can’t be discounted. As new market data comes as the business day closes, QGANs don’t need to be completely retrained. The previous day’s training is used as an initial distribution for the most current model, which allows for quicker convergence of the model.

For experimental purposes, we can still use the simplified price mechanics of Black-Scholes, which require relatively few gates and offers more options when considering loading options.

Loading isn’t the main focus of this article, but I refer you to the various resources that exist on qGANs and ANNs.

2. Circuits that Compute the Payoff

In the second step, computing the payoff, most of the work consists of quantum logic gates and comparator circuits. We encode the strike value of the option in binary and compare each digit to the qubits encoding the probability distributions of the underlying to find the fair price. We’ve covered how to encode the probability distribution of a set of options already, so the only component still needed is a way to compute the payoff function of the option on a quantum computer.

While considering this problem, it’s necessary to remember that an operator compatible with Amplitude Estimation (AE) is required, since that is the final tool used to calculate the expectation value and thus the fair value of the option. An operator A is constructed:

By acting on a register of n + 1 qubits in the zero state, the A operator creates a superposition over the n qubits, controlled on the last qubit (the +1). As can be seen from the equation, little a is isolated in the right term, allowing for perfect integration with AE.

To be able to use AE to deduce a fair value, we encode a to be the expectation value of the linear function of a random variable,

where X is our set of random price paths from the previous section.

You might remember that from earlier in the article we found a lot of the options observed had a piece-wise linear payoff — that is to say the payoff is 0 when the market moves to the opposite direction of our prediction, and increases the payoff linearly as the difference between strike and spot price increases.

The payoff for the option can be encoded as a piecewise linear function, which maps to [0, 1]:

Where f₀ represents the constant term.

The result of this function can be encoded on a single qubit on a quantum computer. This is visualized as a quantum register i encoding the probability distribution and a single qubit onto which we will encode the linear function, with this qubit initialized to the state 0:

The final qubit in a superposition representing the result of the linear function over each qubit (represented by i) in the quantum register.

To create this state, one can take advantage of controlled-Y rotations. We will use these gates to encode the linear part of the payoff function. Each qubit encoding in the i register (the one encoding the probability distribution) will be used as a control for the Controlled-Y, encoding a rotation of

onto the ancilla qubit. That is, if there’s a controlled-Y rotation being controlled on a qubit with index 3, the ancilla qubit is rotated

This may seem rather arbitrary, but this is just converting the binary representation of the strike represented by the i register back into base-10 to ensure accurate rotations. As an example, a quantum state with three qubits in the |111⟩ state corresponds to the base-10 value of 7 after applying the controlled-Y rotations:

Looking back at the original linear function f(i), there is still a constant term to implement. This can be easily achieved by using a Y-rotation on the ancilla qubit, without a control.

After implementing both of these steps, the output circuit might look something like:

The constant term is implemented by the first RY, and the subsequent CRYs implement the linear rotation onto the qubit at index 3, the ancilla.

For a more concrete example, we can examine how to obtain the expectation value of a linear function of a set of random variables. To achieve this, we use the controlled-Y procedure above to implement an operator that maps:

In the above equation, a few changes are made, namely:

This may seem like a rather arbitrary change to make, but it becomes useful in practice. When taking probabilities in quantum mechanics, the Born rule comes into play. Thus, during the measurement of the amplitude of the |1⟩ state, the entire function is squared. This square creates an anti-symmetric function around f(i) = 0. In this case, an anti-symmetric function can be understood as a function in which the exchange of our two variables results in a change in the sign, as can be seen in change 1.

Our measurement probability of finding our final ancilla qubit in the |1⟩ state is given as:

Based off of the structuring of our problem and other approximations that don’t tie into the purposes of this article, the probability is well estimated by the equation:

where

With first-order approximation, the convergence of Amplitude Estimation is given as:

To recover the full (1/M) convergence, more circuit depth is needed. It must be noted that to achieve these speed-ups accurate values of c are required, which turns into a matter of minimizing the number of gates for a set error in the estimation of the expectation value.

The expectation value E[f(x)] can be recovered from probability measurement above because we know the values of fmax, fmin, and c.

3. Amplitude Estimation

Referring back to some of our earlier clarifications, our use of Amplitude Estimation serves to find the a value in the amplitude of the |1⟩ state of the ancilla qubit after application of the A operator:

While traditional approaches to Quantum Amplitude Estimation could be used, NISQ era quantum computers are still limited in their qubit counts, interconnectivity, fidelity and coherence. As such, a simplification of AE can be used to lower circuit depth and make results more accurate. This simplification of AE comes from the work of Suzuki et al., who have proven that AE can be performed without Quantum Phase Estimation, which contributed additional gates and sampling qubits.

AE is represented by the quantum operator Q, which acts as

where

This entire equation corresponds to a rotation of angle 2θₐ in the two-dimensional vector space spanned by |Ψ₀⟩ and |Ψ₁⟩. For a more visual and intuitive approach, make sure to read my article on Grover’s Algorithm for added learning.

Using the trick outlined by Suzuki et al., namely that

and by measuring

for a given number of additional sampling qubits m, applying maximum likelihood approximation will lead to a good estimate for θₐ and therefore a good estimate for a, which encodes the fair, undiscounted value of the option in the amplitude of |1⟩ in the ancilla qubit!

Practical Applications

With various free-to-use quantum computing SDKs available to use right now, it’s easier than ever to run quantum algorithms and visualize the results. It’s useful to program these circuits to understand how they work in practice. I’ll be using Qiskit’s Finance module to visualize some of these quantum circuits. Their website has great tutorials on all of these types of options, which I highly encourage you to explore.

Pricing European Call Options

As mentioned earlier, these are some of the easiest options to price, since they have a set exercise date and have a linear payoff. They do not require any knowledge of the entire price movement of the underlying, just the price at the expiry. Call options are constructed so that if the price of the underlying is higher than the strike price, the option pays the difference between the strike and the spot (current trading) price. Else, the options pays nothing.

Putting this intuition into mathematical notation:

Where f꜀ is the call option, S is spot price at time T, and K is the strike.

Looking back, we know how to compute the payoff at a given spot price using piece-wise linear functions, but we still need to check whether the spot price is greater than the strike. This will determine whether to apply just the constant term of the function if the spot is lower than the strike, or to apply both the constant and linear terms in the case that the spot is greater than or equal to the strike. The first thing that pops into mind is using a qubit as a comparator to check which of the two conditions is true.

A comparator qubit |c⟩ is initialized to state|0⟩. It is converted to state |1⟩ if the spot price is greater than the strike, and stays in |0⟩ otherwise. The transformation looks like:

To implement this circuit, we can use Toffoli and CNOT gates to complete bitwise addition over the qubits. A classical array of the binary bitstring of the strike price is created, which is used to compute the carries in the quantum circuit. A quantum register with an equal number of qubits is added to the circuit to help with the bitwise addition, and a final comparator qubit is added to the circuit to store the end result.

As we pass through each qubit in the circuit, we compute whether or not there is a carry from qubit |i⟩ and corresponding binary digit t[i] in the classical array, the result of which is then stored in the ancilla qubit |aᵢ⟩.

As you may imagine, there are a variety of cases that could occur, with carries from previous qubits, states of current qubits and the binary from the classical array needing to be taken into account. Each case requires a different quantum gate, which can be adjusted depending on the classical bit string.

After computing all of the carries the final qubit, |Ψ⟩ₙ, will only be greater than or equal to the strike if there is a carry in the last and most significant qubit.

Let’s take a look at an example. Assume we have a strike price of $5, which converted to binary corresponds to [101]. 3 qubits encoding the probability distribution are required, as well as 3 ancilla qubits and 1 comparator to hold the end result, meaning that a quantum circuit containing 7 qubits is required.

The 0th index of the classical array is a 1, which results in a CNOT on the 0th ancilla qubit controlled by the 0th register qubit.

The 1st index of the classical array is a 0, which results in a Toffoli gate on the 1st index ancilla controlled by the 1st index qubit on the register and the 0th ancilla.

The 2nd index in the array is a 1, which result in a logical OR applied to the 2nd index ancilla qubit, controlled by the 2nd index register qubit and the 1st index ancilla qubit. The logical OR can be implemented using X and Toffoli gates.

Finally, the result of the computation is stored on the comparator qubit using a CNOT.

The final circuit looks something like this:

Note that the X gate on the second register appears early.

We now have a comparator circuit that is able to check whether the spot price is greater than or equal to the strike. To actually implement the linear payoff function, a second ancilla qubit is added to Φ₁. This extra qubit corresponds to the last qubit in the transformation function defined above. The piece-wise linear payoff function of the option can be written as:

For a European call option, the variables would take the values:

Referring back to the section on computing the payoff for use with AE, the payoff is tailored as:

Where g(i) is a linear function of i and g₀ is an angle to be selected.

A payoff in the form of the aforementioned equation can be created from the state |Φ₁⟩|0⟩ by rotating implementing cos(g₀)|0⟩ + sin(g₀)|1⟩ on the last ancilla qubit, and then adding a rotation of g(i) controlled by both the comparator qubit and qubits in the probability register. This means that the rotation by that angle only occurs if i ≥ K.

The above can be implemented with this quantum circuit:

The state of the qubits after this transformation becomes:

As can be observed, the probability for finding the second ancilla in state |1⟩ is given as:

All that is left to do is figure out which values of g₀ and g(i) to use. We’ve already defined a P₁ approximation earlier in the section on computing the payoff, and we’ll use that as a reference point to recover the payoff E[f(X)].

To satisfy both of the following conditions:

g(i) must be set to

where

Following this selection for g(i), g₀ takes on

From these definitions, E[max(0, i-K)] can be recovered from P₁ up to a scaling factor and a constant, from which it’s then possible to recover the expectation value E[f(i)].

Of course, this process yields the undiscounted price of the option. To know the option’s present value, discounting by future interest rates would be required, but this can be easily done on classical hardware.

Loading the probability distribution of an option with spot price of $3, 20% volatility, and 100 days until expiry on onto a quantum register with the help of the Qiskit Finance module, the probability distribution is visualized as:

Buying a call for the underlying at a $3.40 strike price, the payoff function has the following form:

As calls are easy to price on classical hardware, we obtain an ‘exact value’ of the option computed classically, as well as a quantum estimate and confidence interval.

Note that the accuracy is relatively low due to the fact that the ‘estimated value’ was computed on just 3 qubits, which can be increased for a higher degree of accuracy.

Pricing European Put Options

Pricing European puts can be achieved in the same way as outlined above, just changing a few equations to properly represent the payoff of the put. The payoff of a put can be modelled as:

This payoff denoted in the piecewise notation shown above corresponds to values of:

Implementing this payoff on the same probability distribution as the previous section with a $3.40 strike price, the payoff function changes to:

As can be observed, the option makes money when the spot price of the underlying is below the strike, which makes sense as a put is a bet against the stock and predicting a decline in future price.

Once again computing the payoff classically, and on a quantum register with 3 qubits, we get the output:

Pricing Basket Options

A European Basket option is an extension of the previous 2 types of options, with the payoff now depending on a weighted sum of a number of underlyings, opening a combined position on multiple assets.

This type of option depends on a multivariate distribution of random variables, due to the fact that it relies on the price action of multiple underlyings. This distribution represents the spot prices of a basket of underlying assets at expiry, and can be written as:

The quantum state of this probability distribution can be written as:

Where each pᵢ represents the probability that the underlying has taken values id, with d quantum registers representing each asset in the basket of underlying assets. Each register has nⱼ qubits as a sum over all j.

In addition to this state, basket options also require finding the sum of the random variables. To implement quantum adder circuit to find the sum of two registers, an extra qubit register with n’ qubits is needed to serve as an accumulator.

We create a new state through the transformation:

Now that we have an established quantum state, we can take a look at the payoff of the basket call option, which is given as:

where

Where w is a vector of basket weight and S is a vector of spot prices at expiration

In this example, a multivariate log-normal distribution is used to model the underlying asset prices.

The quantum circuit for pricing the European basket call option is similar to the standard single-asset circuit, except an additional unitary is added to compute the weighted sum of each of the asset registers. The comparator and payoff circuits are then applied, being controlled by the additional accumulator register added.

Considering a loaded probability distribution on the i registers, the circuit output would look like:

Where the first operation computes the weighted sum of all of the i registers, and the second operation compares the weighted sum of the basket to the strike. Finally, the linear function is implemented on the last qubit, controlled on both the last i register and the comparator.

But does this actually provide a speedup when compared to classical Monte Carlo methods?

Amplitude Estimation uses a classical mapping as an estimation for a given knowledge about a quantum state. At the end of the process of AE, the qubits are measured and their values result in an integer y ∈ {0, …, M-1}, where M is the number of qubits. This result is classically mapped to an estimate of amplitude a, which looks like:

The maximum distance between any two of these values is:

Essentially, this equation gives how many M times we need to apply the operator Q to get sufficiently close to the amplitude that properly encodes the option price.

Using:

It can be show that:

From the fact that:

and the P₁ estimation given for the earlier European call option amplitude estimation, the estimation value will be within the range of

with the probability of at least 8/π² .

Comparing this to classical Monte Carlo with the corresponding 8/π² confidence interval on three assets, AE is shown to have a quadratic speedup over classical Monte Carlo. It exhibits M^(-1) scaling versus classical M^(-1/2), and becomes more efficient at 2⁹ samples.

Great! We’ve once again observed the quadratic speedup of AE on basket options. Implementing them is much the same as implementing the European call option.

Using a basket of 2 underlying assets is a great introduction to pricing basket options and is the easiest to visualize, so it makes sense to start with them. Loading the probability distribution of 2 identical underlying assets, with a $2 spot, 20% volatility, and 100 days till expiration results in a 3-dimensional graph:

The payoff function looks very similar to the European call option, except it is now a function of 2 variables rather than a single asset:

The total number of qubits in the circuit is 11, with 5 of the qubits representing the spot price of the underlyings at expiration and 6 qubits being used as ancillas for calculations.

Luckily for us, this computation is still viable on classical computers, so an exact value is computed alongside the quantum equivalent and a confidence interval:

Again, the quantum estimated value can be further improved with more qubits and better quantum computers, which will continue to be developed into the NISQ era and beyond.

Acknowledgements

This article was written based off of the work of Stamatopoulos et al., which was critical in providing the math and motivation behind the idea of pricing options using quantum computers.

The simulations in this article were achieved through Qiskit’s Finance module, which offers plenty of tutorials.

If you enjoyed this article or found it helpful, please make sure to leave some claps and share it with a friend!

If you spot a mistake or want to talk about anything tech-related, make sure to add me on LinkedIn and Twitter. For more info about me, here’s my website.

--

--

Alexander Yevchenko
Geek Culture

working on merging qc and finance. other hobbies: programming, philosophy, writing