Extending Option Pricing Models to Binary Option Pricing

 

Quantitative technology house team launched a series of quantitative investment courses in CSDN College

Students who are interested in systematically learning quantitative investment are welcome, click the link below to register:

Quantitative Investment Crash Camp (Introductory Course)

Python stock quantitative investment

Python Futures Quantitative Investment

Python digital currency quantitative investment

C++ Language CTP Futures Trading System Development

Digital currency JavaScript language quantitative trading system development


Review of European Option Pricing

Our model for pricing European options via Monte Carlo simulations can serve as a basis for pricing a variety of exotic options. In our previous simulations, we defined a method for assigning an asset price at expiration, and a method for valuing options at expiration using that price.

This mocking method can generally be thought of like this:

while i < num_iterations:
    S_T = generate_asset_price()
    payoffs += payoff_function(S_T)
    i += 1

option_price = exp(-r*T) * (payoffs / num_iterations)

By changing the way we generate asset prices, and the way we evaluate option payoffs, we can generate prices for some exotic options. For detailed steps, please refer to our history article.

binary options

Binary options (also known as all or nothing, or digital options) are options that pay off a certain amount or nothing at all. The return is usually a fixed amount of cash or the value of an asset.

For our simulation we will look at cash or cashless binary options. The payoffs for binary call and put options are shown below.

The payoff chart for the binary call option tells us that the option pays $1.00 if the stock price is greater than or equal to $40.00 (our strike price). We can write the payoff of a binary call option as a Python function:

def binary_call_payoff(K, S_T):
    if S_T >= K:
        return 1.0
    else:
        return 0.0

Simulation calculation process

Our asset price will still follow geometric Brownian motion, so we can use the generate_asset_price() function from the previous article. The function implementation code is as follows:

def gbm(S, v, r, T):
    return S * exp((r - 0.5 * v**2) * T + v * sqrt(T) * random.gauss(0,1.0))

That's all we need to price a binary cash or non-cash call option. Putting the above together:

import random
from math import exp, sqrt

def gbm(S, v, r, T):
    return S * exp((r - 0.5 * v**2) * T + v * sqrt(T) * random.gauss(0,1.0))

def binary_call_payoff(K, S_T):
    if S_T >= K:
        return 1.0
    else:
        return 0.0

# parameters
S = 40.0 # asset price
v = 0.2 # vol of 20%
r = 0.01 # rate of 1%
maturity = 0.5
K = 40.0 # ATM strike
simulations = 50000
payoffs = 0.0

# run simultaion
for i in xrange(simulations):
    S_T = gbm(S, v, r, maturity)
    payoffs += binary_call_payoff(K, S_T)

# find prices
option_price = exp(-r * maturity) * (payoffs / float(simulations))

print 'Price: %.8f' % option_price

Running the above code, we get a price of 0.48413327, which is approximately equal to 0.484.

test result

Of course, binary options can also be priced using the traditional Black Scholes model, using the following formula:

\begin{equation*} C = e^{-rT}N(d_2) \end{equation*}

where N is the cumulative normal distribution function and d2 is given by the standard Black Scholes formula.

Let's test that the prices we calculated in the previous step are correct by plugging in the parameters from the previous simulation:

>>> from scipy.stats import norm
>>> from math import exp, log, sqrt
>>> S, K, v, r, T = 100.0, 100.0, 0.2, 0.01, 0.5
>>> d2 = (log(S/K) + (r - 0.5 * v**2) * T) / v*sqrt(T)
>>> print exp(-r * T) * norm.cdf(d2)
0.490489409105

As you can see, the Black Scholes formula gives a price of about 0.490. This means that the price calculated by our simulation is only 0.006 different from the price calculated by the BS formula. From this result, it can be verified that our calculation result is relatively accurate.

 Past dry goods sharing recommended reading

The choice of quantitative investment for data sources, backtests, and real platforms

Digital Currency Stablecoin Pair Grid Market Making Strategy

Everything can be done in seconds—Taobao kills Python scripts in seconds, sweeps goods on 618, and prepares for Double 11!

Digital Currency Funding Fee Strategy

The risk-free rate of return of digital currency has doubled again!

Share a risk-free arbitrage opportunity with an annualized rate of more than 15%

[Quantity Technology House | Trading System Development Series Sharing] Grid Trading System Development

Analysis and prediction of stock prices through deep learning stock price cross-section data

Analyzing a Digital Currency High-Frequency Strategy

Digital currency transaction signal real-time early warning push (including group chat)

Omega System Trading and Development Club internal sharing strategy Easylanguage source code

How to choose a cloud server for quantitative transactions, how to develop and debug cloud server programs locally and remotely

A complete machine learning solution for a real dataset (Part 2)

A Complete Machine Learning Solution for a Real Dataset (Part 1)

How to Develop a Digital Currency Strategy Using the Trading Trailblazer (TB)

Stock index futures high-frequency data machine learning forecasting

How to Backtest Digital Currency Trading Strategies Using TradingView (TV)

How to invest in stock funds? When to buy? buy what?

[Quantitative Technology House | Quantitative Investment Strategy Series Sharing] Stock Index Futures Trading Strategy Based on Exponential Moving Average

AMA indicator original author Perry Kaufman 100+ sets of trading strategy source code sharing

[Quantity Technology House | Options Series Sharing] "Dugu Nine Swords" of Options Strategy

How to Get Free Digital Currency Historical Data

[Quantity Technology House | Financial Data Analysis Series Sharing] The calculation of the spread sequence of the arbitrage strategy may not be as simple as you think

[Quantitative technology house | Quantitative investment strategy series sharing] Futures position following strategy for mature traders

[Quantitative technology house | Quantitative investment strategy series sharing] Multi-cycle resonance trading strategy

[Quantity Technology House | Financial Data Analysis Series Sharing] Why China Securities 500 (IC) is the most suitable long-term long-term index

  Is it hard to get the spot data of bulk commodities? Is it difficult to track the seasonality of commodities? The technical house takes you with Python crawlers to solve problems with one click

[Quantity Technology House | Financial Data Analysis Series Sharing] How to Correctly Buy Bottoms in Commodity Futures and Commodities

[Quantitative Technology House | Quantitative Investment Strategy Series Sharing] Stock Index Futures IF Minute Volatility Statistical Strategy

[Quantity technology house | Python crawler series sharing] Python crawler that monitors major stock market announcements in real time

Guess you like

Origin blog.csdn.net/sljsz/article/details/125284022