Options Models

Pricing

Introduction

Option price models compute the theoretical price of Option contracts, their implied volatility, and their Greek values. Theoretical prices can help you detect undervalued and overvalued contracts, implied volatility can provide you insight into the upcoming volatility of the underlying security, and Greek values can help you hedge your portfolio.

What are Greeks?

Option Greeks measure the exposure of Option price or Option delta to the movement of different factors such as the underlying price, time, and volatility. The Greeks are a function of implied volatility. For more information about them, see The Greek Letters.

What Is Implied Volatility?

Implied volatility is the forecasted future volatility of a security. The Option price model uses the realized volatility to calculate the implied volatility. By default, it uses the formula from Brenner and Subrahmanyam (1988) as the initial guess for implied volatility.

\[ \frac{P}{S} \sqrt{\frac{2\pi}{T}} \]

where \(P\) is the Option contract price, \(S\) is the underlying price, and \(T\) is the time until Option expiration.

If the volatility model of the underlying security is ready, the price model uses its value as the initial guess for implied volatility and as an input to calculate the theoretical contract prices.

Set Models

To set the pricing model of an Option, set its PriceModel property.

If you have access to the Option object when you subscribe to the Option universe or contract, you can set the price model immediately after you create the subscription.

// In Initialize
var option = AddOption("SPY");
option.PriceModel = OptionPriceModels.CrankNicolsonFD();
# In Initialize
option = self.AddOption("SPY")
option.PriceModel = OptionPriceModels.CrankNicolsonFD()

Otherwise, set the price model in a security initializer.

// In Initialize
SetSecurityInitializer(new MySecurityInitializer(BrokerageModel, new FuncSecuritySeeder(GetLastKnownPrices)));

// Outside of the algorithm class
class MySecurityInitializer : BrokerageModelSecurityInitializer
{
    public MySecurityInitializer(IBrokerageModel brokerageModel, ISecuritySeeder securitySeeder)
        : base(brokerageModel, securitySeeder) {}
    
    public override void Initialize(Security security)
    {
        // First, call the superclass definition
        // This method sets the reality models of each security using the default reality models of the brokerage model
        base.Initialize(security);

        // Next, overwrite the price model
        if (security.Type == SecurityType.Option) // Option type
        {
            security.PriceModel = OptionPriceModels.CrankNicolsonFD();
        }
    }
}
# In Initialize
self.SetSecurityInitializer(MySecurityInitializer(self.BrokerageModel, FuncSecuritySeeder(self.GetLastKnownPrices)))

# Outside of the algorithm class
class MySecurityInitializer(BrokerageModelSecurityInitializer):

    def __init__(self, brokerage_model: IBrokerageModel, security_seeder: ISecuritySeeder) -> None:
        super().__init__(brokerage_model, security_seeder)

    def Initialize(self, security: Security) -> None:
        # First, call the superclass definition
        # This method sets the reality models of each security using the default reality models of the brokerage model
        super().Initialize(security)

        # Next, overwrite the price model
        if security.Type == SecurityType.Option: # Option type
            security.PriceModel = OptionPriceModels.CrankNicolsonFD()

Supported Models

LEAN supports the following Option price models. QLNet provides the underlying implementation of these models.

ModelAmerican StyleEuropean Style
AdditiveEquiprobabilitiesgreen checkgreen check
BaroneAdesiWhaleygreen check
BinomialCoxRossRubinsteingreen checkgreen check
BinomialJarrowRuddgreen checkgreen check
BinomialJoshigreen checkgreen check
BinomialLeisenReimergreen checkgreen check
BinomialTiangreen checkgreen check
BinomialTrigeorgisgreen checkgreen check
BjerksundStenslandgreen check
BlackScholes
green check
CrankNicolsonFDgreen checkgreen check
Integral
green check

If you set the price model of an Option to a model with an incompatible style, LEAN throws an exception.

Default Behavior

The default Option pricing model is the BjerksundStensland for American Options or BlackScholes for European Options.

To turn off the Option price model, use the CurrentPriceOptionPriceModel. This model sets the Greeks to 0, sets the implied volatility to 0, and sets the theoretical price to the current price.

option.PriceModel = new CurrentPriceOptionPriceModel();
option.PriceModel = CurrentPriceOptionPriceModel()

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: