Lean icon indicating copy to clipboard operation
Lean copied to clipboard

Use Greek Indicators Along With QuantLib Option Pricing Models

Open AlexCatarino opened this issue 2 years ago • 2 comments

Expected Behavior

Option price models are implemented in LEAN. With this implementation, it is easier to debug and fix some problems.

Actual Behavior

LEAN relies on QLNet.

Potential Solution

Implement the pricing models and remove QLNet. QLNel is convenient because it provides several models out of the box. However, most users use one or two models, so it's not particularly hard to implement the most popular options pricing models, and we can optimize the implementation for LEAN's consumption.

EDIT: We have implemented Option Pricing Model: see Greek Indicators. We need to be able to use them seamlessly.

Reproducing the Problem

N/A

Checklist

  • [x] I have completely filled out this template
  • [x] I have confirmed that this issue exists on the current master branch
  • [x] I have confirmed that this is not a duplicate issue by searching issues
  • [x] I have provided detailed steps to reproduce the issue

AlexCatarino avatar Oct 10 '23 16:10 AlexCatarino

We have experienced this sort of error:

Convergence:

2023-11-20T14:35:12.8027251Z DEBUG:: QLOptionPriceModel.Evaluate(). Cannot calculate Implied Volatility for QQQ 231120C00381000. Implied volatility from Newton-Raphson optimization: 1E-07. Premium: 6.69. Underlying price: 387.65. Initial guess volatility: 0.8264616307869571. Maturity: 0.0027397260273972603. Risk Free: 0.9998904169635637. Forward price: 387.69248451965717. Data time: 11/20/2023 12:00:00 AM. Reference date: 11/20/2023. root not bracketed: f[1E-07,4] -> [0.001751136882203852,28.807216459746737] at QLNet.Utils.QL_REQUIRE(Boolean condition, Func`1 message, QLNetExceptionEnum exEnum)

Implied Volatility near zero:

2023-11-20T14:35:12.7967847Z DEBUG:: QLOptionPriceModel.Evaluate(). Zero-value greek for QQQ 231120C00380000. Premium: 7.68. Underlying price: 387.65. Initial guess volatility: 0.9487631277195561. Maturity: 0.0027397260273972603. Risk Free: 0.9998904169635637. Forward price: 387.69248451965717. Implied Volatility: 1E-07. Is Approximation? False. Data time: 11/20/2023 12:00:00 AM. Reference date: 11/20/2023.

AlexCatarino avatar Nov 21 '23 14:11 AlexCatarino