# Calculating Probability

The bots assume the Black-Scholes-Merton (BSM) model when calculating probability, which (imperfectly) implies a Gaussian or normal distribution. The bots use a fast polynomial approximation for calculating the probability that's derived from BSM.

## Background

The payoff to a European call option, for example, with a strike price ** K** at the maturity date

**is**

*T*where ** S(T)** is the price of the underlying asset at the maturity date. At maturity, if

**the option to buy the underlying at**

*S(T) > K***can be exercised and the underlying asset immediately sold for**

*K***to give a net payoff of**

*S(T)***. Since the option gives only the right and not the obligation to buy the underlying asset, the option to buy the underlying will not be exercised if doing so would lead to a loss,**

*S(T)−K***. The BSM formula for the price of the call option at date**

*S(T) − K < 0***prior to maturity is given by**

*t = 0*where ** N(d**) is the

**cumulative probability distribution**for a variable with a

**standard normal distribution**with a mean of zero and a standard deviation of one. It is the area under the standard normal density function from

**and therefore gives the probability that a random draw from the standard normal distribution will have a value less than or equal to**

*−∞ to d***. Therefore, we have**

*d***with**

*0 ≤ N(d) ≤ 1***, and**

*N(−∞) = 0, N(0) = 0.5***. The term**

*N(+∞) = 1***is the continuously compounded risk-free rate of interest, and variables**

*r***and**

*d1***must satisfy the respective constraints**

*d2*where σ is the volatility of the underlying asset. For more information on the BSM model, see here.

## Polynomial Approximation

The cumulative standard normal distribution is the probability that a number arising from a standard normal distribution lies between −∞ and x. The cumulative standard normal distribution function, P(x), does not have a simple (read fast, in computing terms) analytical solution. Instead, the bots use a **polynomial or rational approximation** of the standard normal (26.2.17; National Bureau of Standards, 1972). The equation is:

where,

This function does not describe the probability of observing value ** x**, but the probability of observing any value

** ≤x**. As a result, the cumulative normal distribution function is sometimes described as a normal integral function.

The **probability density function**, ** Z(x)**, is equivalent to the slope of the cumulative distribution - in other words, the rate of increase of

**for a given**

*P***.**

*x*The normal probability density function is often confused with the normal distribution function, or is assumed to provide the probability of observing some value, ** x**. In fact, this function only approximates the probability of observing a value within a very small range about

**. As a result, when considered over a finite interval, that value can be very much greater than 1, which a probability, by definition, cannot exceed. The function can be described as:**

*x*where ** μ** is the location parameter and

**is the scale parameter. The case where**

*σ***and**

*μ = 0***is called the**

*σ = 1***standard normal distribution**. We can therefore simplify the equation for the standard normal distribution:

## Probability of Future Price

Bot automations may contain various decisions surrounding the probability of the underlying's price being a specific value at some date in the future. All of these recipes are derived from the same probability formula, ** P(x)**.

The probability function takes the current price, strike price, annual volatility of the underlying, the risk-free rate, and days to maturity as inputs to calculate ** d1**, as described above. The bots will then effectively calculate

**from BSM by first solving the**

*N(d1)***probability density function**,

**before using all values as inputs to the**

*Z(x***cumulative probability distribution function**,

**.**

*P(x)*The outputs of ** P(x)** and

**are then used to solve a variety of sub-problems relevant to the specific decision recipes: probability above price**

*Z(x)***, below price**

*x***, between prices**

*x***and**

*x***, etc.**

*y*### On the Underlying

There are two probability-related decisions available when analyzing the security object.

- Chance of being above/below
price in*m*days is more/less than*n*%.*x* - Chance of being between
and*a*prices in*b*days is more/less than*n*%*x**.*

Both decisions use variations of fast polynomial approximation to calculate the final probability of the event occurring. The first use case, the chance of being **below m** price in

**days, is the output of**

*n***. The opposite decision, the chance of being**

*P(x)***above m**price in

**days, is simply**

*n***.**

*1 - P(x)*In the case of price between prices ** a** and

**, recall that the cumulative standard normal distribution polynomial describes the probability of observing any value**

*b*** ≤x**. Therefore, to calculate the chance of falling within a range in

**days, we subtract**

*n***with**

*P(x)***from**

*S(T) = a***with**

*P(x)*

*S(T) = b**to determine the final probability.*

### On the Opportunity

There is one probability-related decision available when analyzing Opportunities:

- Chance of
is more/less than*{profit, max loss, being ITM}*%.*x*

Unsurprisingly, we are again calculating the probability of ending up at some price in the future. The only relevant question is, which price and when? For Opportunities, calculations are always made using the number of days to expiration as the input, i.e., we're answering the question, "What is the chance of these things happening *at expiration*?"

The determination of underlying price in relation to profit, max loss, or being ITM is fully dependent on both the strategy type in question and the composite value of the opportunity, given its individual legs (assuming an options strategy).

In the case of a short put spread, for example, the "chance of profit" is determined by the probability the underlying price will be above the break-even price of the spread. In other words, the probability the spread will make at least a $1 profit. The max loss chance is then determined by the underlying price being below the break-even, and the being ITM chance is determined by the underlying price being below the short strike.

The same principles are applied to each strategy type. In the case of more complex, multi-legged strategies like iron condors, we use the same probability formula for calculating the chance of price between prices ** a** and

**to determine the likelihood of the profit range in between the short strikes, max loss range, etc.**

*b*