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.
LEAN also provides indicator implementations of Option Greeks. It provides higher flexibility on Option price model selection, volatility modeling, and allows IV smoothing through call-put pair. For details, see Option Indicators.
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.
LEAN also provides an indicator implementation of implied volatility. It provides higher flexibility on Option price model selection, volatility modeling, and allows IV smoothing through call-put pair. For details, see Implied Volatility.
Set Models
To set the pricing model of an Option, set its PriceModel
price_model
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 UniverseSettings.Asynchronous = true; var option = AddOption("SPY"); option.PriceModel = OptionPriceModels.CrankNicolsonFD();
# In Initialize self.universe_settings.asynchronous = True option = self.add_option("SPY") option.price_model = OptionPriceModels.crank_nicolson_fd()
Otherwise, set the price model in a security initializer.
// In the Initialize method, set the security initializer to seed initial the prices and models of assets. SetSecurityInitializer(new MySecurityInitializer(BrokerageModel, new FuncSecuritySeeder(GetLastKnownPrices))); 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 the Initialize method, set the security initializer to seed initial the prices and models of assets. self.set_security_initializer(MySecurityInitializer(self.brokerage_model, FuncSecuritySeeder(self.get_last_known_prices))) # 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.price_model = OptionPriceModels.CrankNicolsonFD()
Supported Models
LEAN supports the following Option price models. QLNet provides the underlying implementation of these models.
Model | American Style | European Style |
---|---|---|
AdditiveEquiprobabilities | ||
BaroneAdesiWhaley | ||
BinomialCoxRossRubinstein | ||
BinomialJarrowRudd | ||
BinomialJoshi | ||
BinomialLeisenReimer | ||
BinomialTian | ||
BinomialTrigeorgis | ||
BjerksundStensland | ||
BlackScholes | ||
CrankNicolsonFD | ||
Integral |
If you set the price model of an Option to a model with an incompatible style, LEAN throws an exception.
Disable Pricing
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.price_model = CurrentPriceOptionPriceModel()