Table of Contents

Class BlackScholesPricer

Namespace
ATAS.DataFeedsCore.Pricing
Assembly
ATAS.DataFeedsCore.dll

Closed-form Black-Scholes-Merton pricer for European options with an implied volatility solver. Single implementation shared by the options board greeks, the options PnL calculator and custom indicators (via the public indicator API). Time to expiration is fractional (intraday), so 0DTE options keep a decreasing positive time value during their last trading session. Passing dividendYield == rate gives zero cost-of-carry (Black-76), the correct convention for options on futures.

Added in ATAS 8.0.15.

public static class BlackScholesPricer
Inheritance
object
BlackScholesPricer

Fields

DaysPerYear

Calendar days per year used for year fractions and the daily theta.

public const double DaysPerYear = 365

Field Value

double

MaxVolatility

1000% - short-dated options can trade at extreme implied volatility.

public const double MaxVolatility = 10

Field Value

double

MinTimeToExpiration

Floor for time to expiration: 15 minutes in years. Keeps the model defined up to the very end of the expiration day.

public const double MinTimeToExpiration = 2.8538812785388127E-05

Field Value

double

MinVolatility

Lower volatility bound of the implied volatility solver: 0.01%.

public const double MinVolatility = 0.0001

Field Value

double

Methods

CalculateGreeks(OptionTypes, double, double, double, double, double, double)

Calculates the Black-Scholes-Merton price and greeks of a European option. When any of spot, strike, timeToExpiration or volatility is not positive, returns the discounted intrinsic value with all greeks 0.

public static BlackScholesPricer.GreeksResult CalculateGreeks(OptionTypes type, double spot, double strike, double timeToExpiration, double volatility, double rate = 0, double dividendYield = 0)

Parameters

type OptionTypes

The option type.

spot double

The price of the underlying.

strike double

The strike price.

timeToExpiration double

The time to expiration in years, for example from GetTimeToExpiration(DateTime, DateTime).

volatility double

The annualized volatility as a fraction (0.2 is 20%).

rate double

The annualized continuously compounded risk-free rate as a fraction.

dividendYield double

The annualized continuously compounded dividend yield as a fraction; pass rate for options on futures.

Returns

BlackScholesPricer.GreeksResult

The price and greeks.

GetTimeToExpiration(DateTime, DateTime)

Converts an expiration timestamp to a year fraction relative to now. Date-only expirations (as delivered by Rithmic and IB) are treated as the end of that trading day, so an option expiring "today" still prices during its last session.

public static double GetTimeToExpiration(DateTime expiration, DateTime now)

Parameters

expiration DateTime
now DateTime

Returns

double

ImpliedVolatility(OptionTypes, double, double, double, double, double, double)

Solves Black-Scholes implied volatility by bisection. Returns null when the price is outside the arbitrage bounds (below intrinsic or above the spot/strike cap), or when it cannot be matched within the volatility limits.

public static double? ImpliedVolatility(OptionTypes type, double optionPrice, double spot, double strike, double timeToExpiration, double rate = 0, double dividendYield = 0)

Parameters

type OptionTypes
optionPrice double
spot double
strike double
timeToExpiration double
rate double
dividendYield double

Returns

double?

IsExpired(DateTime, DateTime)

True when the option's last trading day is already over - greeks must not be calculated anymore.

public static bool IsExpired(DateTime expiration, DateTime now)

Parameters

expiration DateTime
now DateTime

Returns

bool

Price(OptionTypes, double, double, double, double, double, double)

Calculates the Black-Scholes-Merton price of a European option. When any of spot, strike, timeToExpiration or volatility is not positive, returns the discounted intrinsic value instead.

public static double Price(OptionTypes type, double spot, double strike, double timeToExpiration, double volatility, double rate = 0, double dividendYield = 0)

Parameters

type OptionTypes

The option type.

spot double

The price of the underlying.

strike double

The strike price.

timeToExpiration double

The time to expiration in years, for example from GetTimeToExpiration(DateTime, DateTime).

volatility double

The annualized volatility as a fraction (0.2 is 20%).

rate double

The annualized continuously compounded risk-free rate as a fraction.

dividendYield double

The annualized continuously compounded dividend yield as a fraction; pass rate for options on futures.

Returns

double

The theoretical option price, in the price units of spot and strike.