Binary Option
Calculate the price of a Binary (Digital) Option using the Black-Scholes framework.
A binary option pays out a fixed amount if the option expires in-the-money and nothing otherwise. Two variants are supported through the option_type parameter:
- “cash-or-nothing”: pays a fixed cash amount if the option expires in-the-money.
- Call = cash_payout * e^(-r * t) * N(d2)
- Put = cash_payout * e^(-r * t) * N(-d2)
- “asset-or-nothing”: pays the value of the underlying asset if the option expires in-the-money.
- Call = S * e^(-q * t) * N(d1)
- Put = S * e^(-q * t) * N(-d1)
Where S is the stock price, r is the risk-free rate, q is the dividend yield, t is the time to expiration, N(d1) is the cumulative normal distribution of d1 and N(d2) is the cumulative normal distribution of d2.
Also known as: digital option, all-or-nothing option, cash-or-nothing option, asset-or-nothing option.
Binary Option in Python
get_binary_option is part of the Options module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_binary_option as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AMZN", "AAPL"], api_key="FINANCIAL_MODELING_PREP_KEY")
binary_option = toolkit.options.get_binary_option()
binary_option.loc['AMZN']
Parameters
get_binary_option accepts the following parameters:
- start_date (str | None, optional): The start date which determines the stock price. Defaults to None which means it will use the most recent date.
- put_option (bool, optional): Whether to calculate the put option price. Defaults to False which means it will calculate the call option price.
- option_type (str, optional): Either “cash-or-nothing” or “asset-or-nothing”. Defaults to “cash-or-nothing”.
- cash_payout (float, optional): The fixed cash amount paid out by a cash-or-nothing option when it expires in-the-money. Ignored for asset-or-nothing options. Defaults to 1.0.
- strike_price_range (float): The percentage range to use for the strike prices. Defaults to 0.25 which equals 25% and thus results in strike prices from 75 to 125 if the current stock price is 100.
- strike_step_size (int): The step size to use for the strike prices. Defaults to 5 which means that the strike prices will be 75, 80, 85, 90, 95, 100, 105, 110, 115 and 120 if the current stock price is 100.
- expiration_time_range (int): The number of days to use for the time to expiration. Defaults to 30 which equals 30 days.
- risk_free_rate (float, optional): The risk free rate to use for the calculation. Defaults to None which means it will use the current risk free rate.
- dividend_yield (float, optional): The dividend yield to use for the calculation. Defaults to None which means it will use the dividend yield as obtained through annual historical data.
- show_input_info (bool, optional): Whether to show the input information. Defaults to False.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
- standardize (bool, optional): Whether to standardize (Z-Score) the result across the time to expiration columns for each ticker and strike price. Defaults to False.