Greeks and Implied Volatility
Option Indicators
Parameters
The following table describes the arguments that the automatic Option indicators methods accept:
Argument | Data Type | Description | Default Value |
---|---|---|---|
symbol | Symbol | The contract to use when calculating the indicator values. | |
mirrorOption mirror_option | Symbol | The mirror contract to use in parity type calculations. | null None |
riskFreeRate risk_free_rate | decimal float | The risk-free interest rate. If you don't provide a value, the default value is the US primary credit rate from the Interest Rate Provider Model. | null None |
dividendYield dividend_yield | decimal float | The dividend yield rate. If you don't provide a value, the default value comes from the Dividend Yield Provider Model. | null None |
optionModel option_model | OptionPricingModelType |
The Option pricing model that's used to calculate the Greeks.
If you don't provide a value, the default value is OptionPricingModelType.BlackScholes for European Options or OptionPricingModelType.BinomialCoxRossRubinstein for American Options.
| null None |
resolution | Resolution | The resolution of the indicator data. If you don't provide a value, the default value is the resolution of the subscription you have for the Option contract(s). | null None |
To perform implied volatility (IV) smoothing with a put-call pair, pass one of the contracts as the symbol
argument and pass the other contract in the pair as the mirrorOption
mirror_option
argument.
The default IV smoothing method uses the one contract in the pair that's at-the-money or out-of-money to calculate the IV.
To change the smoothing function, call the SetSmoothingFunction
set_smoothing_function
method of the ImpliedVolatility
class/property.
Several different Option pricing models are supported to calculate the IV and Greeks. The following table describes the OptionPricingModelType
enumeration members:
Implied Volatility
Implied volatility, , is the market's expectation for the future volatility of an asset and is implied by the price of the assets's Options contracts. You can't observe it in the market but you can derive it from the price of an Option. For more information about implied volatility, see Implied Volatility.
Automatic Indicators
To create an automatic indicator for implied volatility, call the QCAlgorithm.IV
QCAlgorithm.iv
method with the Option contract Symbol
symbol
object(s).
private ImpliedVolatility _impliedvolatility; public override void Initialize() { var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); // Example of using the single-contract IV calculation: _impliedvolatility = IV(option); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _impliedvolatility = IV(option, mirrorOption); }
def initialize(self): option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) # Example of using the single-contract IV calculation: self.impliedvolatility = self.iv(option) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505, datetime(2014, 6, 27)) self.add_option_contract(mirror_option) self.impliedvolatility = self.iv(option, mirror_option)
The follow table describes the arguments that the IV
iv
method accepts in addition to the standard parameters:
Argument | Data Type | Description | Default Value |
---|---|---|---|
period | int | The number of periods to use when calculating the historical volatility for comparison. | 252 |
For more information about the IV
iv
method, see Using IV Indicator.
Manual Indicators
To create a manual indicator for implied volatility, call the ImpliedVolatility
constructor.
private ImpliedVolatility _impliedvolatility; public override void Initialize() { var equity = AddEquity("AAPL").Symbol; var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); var interestRateProvider = new InterestRateProvider(); var dividendYieldProvider = new DividendYieldProvider(equity); // Example of using the single-contract IV calculation: _impliedvolatility = new ImpliedVolatility(option, interestRateProvider, dividendYieldProvider); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _impliedvolatility = new ImpliedVolatility(option, interestRateProvider, dividendYieldProvider, mirrorOption); }
def initialize(self): equity = self.add_equity("AAPL").symbol option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) interest_rate_provider = InterestRateProvider() dividend_yield_provider = DividendYieldProvider(equity) # Example of using the single-contract IV calculation: self.impliedvolatility = ImpliedVolatility(option, interest_rate_provider, dividend_yield_provider) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505m, new DateTime(2014, 6, 27)) self.add_option_contract(mirrorOption) self.impliedvolatility = ImpliedVolatility(option, interest_rate_provider, dividend_yield_provider, mirrorOption)
For more information about the ImpliedVolatility
constructor, see Using IV Indicator.
Volatility Smoothing
The default IV smoothing method uses the one contract in the pair that's at-the-money or out-of-money to calculate the IV.
To change the smoothing function, pass a mirrorOption
mirror_option
argument to the IV
iv
method or ImpliedVolatility
constructor and then call the SetSmoothingFunction
set_smoothing_function
method of the resulting ImpliedVolatility
object.
The follow table describes the arguments of the custom function:
Argument | Data Type | Description |
---|---|---|
iv | decimal float | The IV of the Option contract. |
mirrorIv mirror_iv | decimal float | The IV of the mirror Option contract. |
The method must return a decimal
float
as the smoothened IV.
private ImpliedVolatility _iv; public override void Initialize() { var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _iv = IV(option, mirrorOption); // example: take average of the call-put pair _iv.SetSmoothingFunction((iv, mirrorIv) => (iv + mirrorIv) * 0.5m); }
def initialize(self): option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505m, new DateTime(2014, 6, 27)) self.add_option_contract(mirrorOption) self.iv = self.IV(option, mirrorOption) # Example: The average of the call-put pair. self.iv.set_smoothing_function(lambda iv, mirror_iv: (iv + mirror_iv) * 0.5)
Delta
Delta, , is the rate of change of the Option price with respect to the price of the underlying asset. It measures the first-order sensitivity of the price to a movement in underlying price. For example, an Option delta of 0.4 means that if the underlying asset moves by 1%, then the value of the Option moves by 0.4 × 1% = 0.4%. For more information about delta, see Delta.
Automatic Indicators
To create an automatic indicator for delta, call the QCAlgorithm.D
QCAlgorithm.d
method with the Option contract Symbol
symbol
object(s).
private Delta _delta; public override void Initialize() { var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); // Example of using the single-contract IV calculation: _delta = D(option); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _delta = D(option, mirrorOption); }
def initialize(self): option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) # Example of using the single-contract IV calculation: self.delta = self.d(option) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505, datetime(2014, 6, 27)) self.add_option_contract(mirror_option) self.delta = self.d(option, mirror_option)
The follow table describes the arguments that the D
method accepts in addition to the standard parameters:
Argument | Data Type | Description | Default Value |
---|---|---|---|
ivModel iv_model | OptionPricingModelType |
The Option pricing model to use to estimate the IV when calculating Delta.
If you don't provide a value, the default value is to match the optionModel option_model parameter.
| null None |
For more information about the D
method, see Using D Indicator.
Manual Indicators
To create a manual indicator for delta, call the Delta
constructor.
private Delta _delta; public override void Initialize() { var equity = AddEquity("AAPL").Symbol; var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); var interestRateProvider = new InterestRateProvider(); var dividendYieldProvider = new DividendYieldProvider(equity); // Example of using the single-contract IV calculation: _delta = new Delta(option, interestRateProvider, dividendYieldProvider); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _delta = new Delta(option, interestRateProvider, dividendYieldProvider, mirrorOption); }
def initialize(self): equity = self.add_equity("AAPL").symbol option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) interest_rate_provider = InterestRateProvider() dividend_yield_provider = DividendYieldProvider(equity) # Example of using the single-contract IV calculation: self.delta = Delta(option, interest_rate_provider, dividend_yield_provider) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505m, new DateTime(2014, 6, 27)) self.add_option_contract(mirrorOption) self.delta = Delta(option, interest_rate_provider, dividend_yield_provider, mirrorOption)
For more information about the Delta
constructor, see Using D Indicator.
Volatility Smoothing
The default IV smoothing method uses the one contract in the pair that's at-the-money or out-of-money to calculate the IV.
To change the smoothing function, pass a mirrorOption
mirror_option
argument to the indicator method or constructor and then call the SetSmoothingFunction
set_smoothing_function
method of the ImpliedVolatility
property of the indicator.
// Example: Average IV of the call-put pair. _delta.ImpliedVolatility.SetSmoothingFunction((iv, mirrorIv) => (iv + mirrorIv) * 0.5m);
# Example: Average IV of the call-put pair. self.delta.implied_volatility.set_smoothing_function(lambda iv, mirror_iv: (iv + mirror_iv) * 0.5)
For more information about the IV smoothing function, see Implied Volatility.
Gamma
Gamma, , is the rate of change of the portfolio's delta with respect to the underlying asset's price. It represents the second-order sensitivity of the Option to a movement in the underlying asset's price. For more information about Gamma, see Gamma.
Automatic Indicators
To create an automatic indicator for gamma, call the QCAlgorithm.G
QCAlgorithm.g
method with the Option contract Symbol
symbol
object(s).
private Gamma _gamma; public override void Initialize() { var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); // Example of using the single-contract IV calculation: _gamma = G(option); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _gamma = G(option, mirrorOption); }
def initialize(self): option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) # Example of using the single-contract IV calculation: self.gamma = self.g(option) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505, datetime(2014, 6, 27)) self.add_option_contract(mirror_option) self.gamma = self.g(option, mirror_option)
The follow table describes the arguments that the G
method accepts in addition to the standard parameters:
Argument | Data Type | Description | Default Value |
---|---|---|---|
ivModel iv_model | OptionPricingModelType |
The Option pricing model to use to estimate the IV when calculating Gamma.
If you don't provide a value, the default value is to match the optionModel option_model parameter.
| null None |
For more information about the G
method, see Using G Indicator.
Manual Indicators
To create a manual indicator for gamma, call the Gamma
constructor.
private Gamma _gamma; public override void Initialize() { var equity = AddEquity("AAPL").Symbol; var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); var interestRateProvider = new InterestRateProvider(); var dividendYieldProvider = new DividendYieldProvider(equity); // Example of using the single-contract IV calculation: _gamma = new Gamma(option, interestRateProvider, dividendYieldProvider); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _gamma = new Gamma(option, interestRateProvider, dividendYieldProvider, mirrorOption); }
def initialize(self): equity = self.add_equity("AAPL").symbol option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) interest_rate_provider = InterestRateProvider() dividend_yield_provider = DividendYieldProvider(equity) # Example of using the single-contract IV calculation: self.gamma = Gamma(option, interest_rate_provider, dividend_yield_provider) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505m, new DateTime(2014, 6, 27)) self.add_option_contract(mirrorOption) self.gamma = Gamma(option, interest_rate_provider, dividend_yield_provider, mirrorOption)
For more information about the Gamma
constructor, see Using G Indicator.
Volatility Smoothing
The default IV smoothing method uses the one contract in the pair that's at-the-money or out-of-money to calculate the IV.
To change the smoothing function, pass a mirrorOption
mirror_option
argument to the indicator method or constructor and then call the SetSmoothingFunction
set_smoothing_function
method of the ImpliedVolatility
property of the indicator.
// Example: Average IV of the call-put pair. _gamma.ImpliedVolatility.SetSmoothingFunction((iv, mirrorIv) => (iv + mirrorIv) * 0.5m);
# Example: Average IV of the call-put pair. self.gamma.implied_volatility.set_smoothing_function(lambda iv, mirror_iv: (iv + mirror_iv) * 0.5)
For more information about the IV smoothing function, see Implied Volatility.
Vega
Vega, , is the rate of change in the value of the Option with respect to the volatility of the underlying asset. For more information about vega, see Vega.
Automatic Indicators
To create an automatic indicator for vega, call the QCAlgorithm.V
QCAlgorithm.v
method with the Option contract Symbol
symbol
object(s).
private Vega _vega; public override void Initialize() { var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); // Example of using the single-contract IV calculation: _vega = V(option); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _vega = V(option, mirrorOption); }
def initialize(self): option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) # Example of using the single-contract IV calculation: self.vega = self.v(option) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505, datetime(2014, 6, 27)) self.add_option_contract(mirror_option) self.vega = self.v(option, mirror_option)
The follow table describes the arguments that the V
method accepts in addition to the standard parameters:
Argument | Data Type | Description | Default Value |
---|---|---|---|
ivModel iv_model | OptionPricingModelType |
The Option pricing model to use to estimate the IV when calculating Vega.
If you don't provide a value, the default value is to match the optionModel option_model parameter.
| null None |
For more information about the V
method, see Using V Indicator.
Manual Indicators
To create a manual indicator for vega, call the Vega
constructor.
private Vega _vega; public override void Initialize() { var equity = AddEquity("AAPL").Symbol; var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); var interestRateProvider = new InterestRateProvider(); var dividendYieldProvider = new DividendYieldProvider(equity); // Example of using the single-contract IV calculation: _vega = new Vega(option, interestRateProvider, dividendYieldProvider); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _vega = new Vega(option, interestRateProvider, dividendYieldProvider, mirrorOption); }
def initialize(self): equity = self.add_equity("AAPL").symbol option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) interest_rate_provider = InterestRateProvider() dividend_yield_provider = DividendYieldProvider(equity) # Example of using the single-contract IV calculation: self.vega = Vega(option, interest_rate_provider, dividend_yield_provider) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505m, new DateTime(2014, 6, 27)) self.add_option_contract(mirrorOption) self.vega = Vega(option, interest_rate_provider, dividend_yield_provider, mirrorOption)
For more information about the Vega
constructor, see Using V Indicator.
Volatility Smoothing
The default IV smoothing method uses the one contract in the pair that's at-the-money or out-of-money to calculate the IV.
To change the smoothing function, pass a mirrorOption
mirror_option
argument to the indicator method or constructor and then call the SetSmoothingFunction
set_smoothing_function
method of the ImpliedVolatility
property of the indicator.
// Example: Average IV of the call-put pair. _vega.ImpliedVolatility.SetSmoothingFunction((iv, mirrorIv) => (iv + mirrorIv) * 0.5m);
# Example: Average IV of the call-put pair. self.vega.implied_volatility.set_smoothing_function(lambda iv, mirror_iv: (iv + mirror_iv) * 0.5)
For more information about the IV smoothing function, see Implied Volatility.
Theta
Theta, , is the rate of change of the value of the Option with respect to the passage of time. It is also known to as the time decay of an Option. For more information about theta, see Theta.
Automatic Indicators
To create an automatic indicator for theta, call the QCAlgorithm.T
QCAlgorithm.t
method with the Option contract Symbol
symbol
object(s).
private Theta _theta; public override void Initialize() { var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); // Example of using the single-contract IV calculation: _theta = T(option); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _theta = T(option, mirrorOption); }
def initialize(self): option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) # Example of using the single-contract IV calculation: self.theta = self.t(option) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505, datetime(2014, 6, 27)) self.add_option_contract(mirror_option) self.theta = self.t(option, mirror_option)
The follow table describes the arguments that the T
method accepts in addition to the standard parameters:
Argument | Data Type | Description | Default Value |
---|---|---|---|
ivModel iv_model | OptionPricingModelType |
The Option pricing model to use to estimate the IV when calculating theta.
If you don't provide a value, the default value is to match the optionModel option_model parameter.
| null None |
For more information about the T
method, see Using T Indicator.
Manual Indicators
To create a manual indicator for theta, call the Theta
constructor.
private Theta _theta; public override void Initialize() { var equity = AddEquity("AAPL").Symbol; var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); var interestRateProvider = new InterestRateProvider(); var dividendYieldProvider = new DividendYieldProvider(equity); // Example of using the single-contract IV calculation: _theta = new Theta(option, interestRateProvider, dividendYieldProvider); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _theta = new Theta(option, interestRateProvider, dividendYieldProvider, mirrorOption); }
def initialize(self): equity = self.add_equity("AAPL").symbol option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) interest_rate_provider = InterestRateProvider() dividend_yield_provider = DividendYieldProvider(equity) # Example of using the single-contract IV calculation: self.theta = Theta(option, interest_rate_provider, dividend_yield_provider) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505m, new DateTime(2014, 6, 27)) self.add_option_contract(mirrorOption) self.theta = Theta(option, interest_rate_provider, dividend_yield_provider, mirrorOption)
For more information about the Theta
constructor, see Using T Indicator.
Volatility Smoothing
The default IV smoothing method uses the one contract in the pair that's at-the-money or out-of-money to calculate the IV.
To change the smoothing function, pass a mirrorOption
mirror_option
argument to the indicator method or constructor and then call the SetSmoothingFunction
set_smoothing_function
method of the ImpliedVolatility
property of the indicator.
// Example: Average IV of the call-put pair. _theta.ImpliedVolatility.SetSmoothingFunction((iv, mirrorIv) => (iv + mirrorIv) * 0.5m);
# Example: Average IV of the call-put pair. self.theta.implied_volatility.set_smoothing_function(lambda iv, mirror_iv: (iv + mirror_iv) * 0.5)
For more information about the IV smoothing function, see Implied Volatility.
Rho
Rho, , is the rate of change of the value of a derivative with respect to the interest rate. It is usually small and not a big issue in practice unless the Option is deep in-the-money and has a long horizon. In this case, the interest rate matters because you need to discount a larger cash flow over a longer horizon. For more information about rho, see Rho.
Automatic Indicators
To create an automatic indicator for rho, call the QCAlgorithm.R
QCAlgorithm.r
method with the Option contract Symbol
symbol
object(s).
private Rho _rho; public override void Initialize() { var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); // Example of using the single-contract IV calculation: _rho = R(option); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _rho = R(option, mirrorOption); }
def initialize(self): option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) # Example of using the single-contract IV calculation: self.rho = self.r(option) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505, datetime(2014, 6, 27)) self.add_option_contract(mirror_option) self.rho = self.r(option, mirror_option)
The follow table describes the arguments that the R
method accepts in addition to the standard parameters:
Argument | Data Type | Description | Default Value |
---|---|---|---|
ivModel iv_model | OptionPricingModelType |
The Option pricing model to use to estimate the IV when calculating rho
If you don't provide a value, the default value is to match the optionModel option_model parameter.
| null None |
Manual Indicators
To create a manual indicator for rho, call the Rho
constructor.
private Rho _rho; public override void Initialize() { var equity = AddEquity("AAPL").Symbol; var option = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Put, 505m, new DateTime(2014, 6, 27)); AddOptionContract(option); var interestRateProvider = new InterestRateProvider(); var dividendYieldProvider = new DividendYieldProvider(equity); // Example of using the single-contract IV calculation: _rho = new Rho(option, interestRateProvider, dividendYieldProvider); // Example of using the using mirror-contract IV calculation: var mirrorOption = QuantConnect.Symbol.CreateOption("AAPL", Market.USA, OptionStyle.American, OptionRight.Call, 505m, new DateTime(2014, 6, 27)); AddOptionContract(mirrorOption); _rho = new Rho(option, interestRateProvider, dividendYieldProvider, mirrorOption); }
def initialize(self): equity = self.add_equity("AAPL").symbol option = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.PUT, 505, datetime(2014, 6, 27)) self.add_option_contract(option) interest_rate_provider = InterestRateProvider() dividend_yield_provider = DividendYieldProvider(equity) # Example of using the single-contract IV calculation: self.rho = Rho(option, interest_rate_provider, dividend_yield_provider) # Example of using the using mirror-contract IV calculation: mirrorOption = Symbol.create_option("AAPL", Market.USA, OptionStyle.AMERICAN, OptionRight.CALL, 505m, new DateTime(2014, 6, 27)) self.add_option_contract(mirrorOption) self.rho = Rho(option, interest_rate_provider, dividend_yield_provider, mirrorOption)
For more information about the Rho
constructor, see Using R Indicator.
Volatility Smoothing
The default IV smoothing method uses the one contract in the pair that's at-the-money or out-of-money to calculate the IV.
To change the smoothing function, pass a mirrorOption
mirror_option
argument to the indicator method or constructor and then call the SetSmoothingFunction
set_smoothing_function
method of the ImpliedVolatility
property of the indicator.
// Example: Average IV of the call-put pair. _rho.ImpliedVolatility.SetSmoothingFunction((iv, mirrorIv) => (iv + mirrorIv) * 0.5m);
# Example: Average IV of the call-put pair. self.rho.implied_volatility.set_smoothing_function(lambda iv, mirror_iv: (iv + mirror_iv) * 0.5)
For more information about the IV smoothing function, see Implied Volatility.