Calculate Option Greeks with Implied Volatility (#6720)
* Using IV to calculate Greeks, and remove single-step stochastic approximation * Correct calculation for theta, vega, rho * Add calculation from Black Calculator and peer review * Address peer review and added unit test * Update some tests and correct vega/eho * Fix Unit Test and Improve Comments Fixes `IndexOptionCallITMGreeksExpiryRegressionAlgorithm` since `Vega` was really non-zero. * Fix regression test and add IV calculation * refactor and bug fixing on peer review * refactor and bug fixing on peer review * for rerun test * add warning on IV estimation not coveraged and edit speed unit test to not exceed 2s per 1000 iteration * update logging * update logging and description * Add default option pricing models and unit tests * address review * Added Fed interest rate as risk-free rate with unit tests and set as default for option greeks calculation, added regression algorithms, addressed peer review * refactor structure of interest rate * Skip Saturday and Sunday * regression test fix * peer review * Fixes Interest Rate Provider Logic * Minor tweaks * Fix start date * Minor test tweak * Update interest rates * Fix unit tests * Add minor log Co-authored-by: Alexandre Catarino <AlexCatarino@users.noreply.github.com> Co-authored-by: Martin-Molinero <martin@quantconnect.com>
This commit is contained in:
@@ -66,12 +66,14 @@ class OptionPriceModelForOptionStylesBaseRegressionAlgorithm(QCAlgorithm):
|
||||
if self._optionStyleIsSupported:
|
||||
raise Exception(f'Expected greeks to be calculated for {contract.Symbol.Value}, an {optionStyleStr} style option, using {type(self._option.PriceModel).__name__}, which supports them, but they were not')
|
||||
|
||||
# Greeks shpould be valid if they were successfuly accessed for supported option style
|
||||
# Greeks should be valid if they were successfuly accessed for supported option style
|
||||
# Delta can be {-1, 0, 1} if the price is too wild, rho can be 0 if risk free rate is 0
|
||||
# Vega can be 0 if the price is very off from theoretical price, Gamma = 0 if Delta belongs to {-1, 1}
|
||||
if (self._optionStyleIsSupported
|
||||
and ((contract.Right == OptionRight.Call and (greeks.Delta < 0.0 or greeks.Delta > 1.0 or greeks.Rho <= 0.0))
|
||||
or (contract.Right == OptionRight.Put and (greeks.Delta < -1.0 or greeks.Delta > 0.0 or greeks.Rho >= 0.0))
|
||||
or greeks.Theta == 0.0 or greeks.Vega <= 0.0 or greeks.Gamma <= 0.0)):
|
||||
raise Exception(f'Expected greeks to have valid values. Greeks were: Delta: {greeks.Delta}, Rho: {greeks.Rho}, Delta: {greeks.Delta}, Vega: {greeks.Vega}, Gamma: {greeks.Gamma}')
|
||||
and ((contract.Right == OptionRight.Call and (greeks.Delta < 0.0 or greeks.Delta > 1.0 or greeks.Rho < 0.0))
|
||||
or (contract.Right == OptionRight.Put and (greeks.Delta < -1.0 or greeks.Delta > 0.0 or greeks.Rho > 0.0))
|
||||
or greeks.Theta == 0.0 or greeks.Vega < 0.0 or greeks.Gamma < 0.0)):
|
||||
raise Exception(f'Expected greeks to have valid values. Greeks were: Delta: {greeks.Delta}, Rho: {greeks.Rho}, Theta: {greeks.Theta}, Vega: {greeks.Vega}, Gamma: {greeks.Gamma}')
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user