Hi,

It seems I need to call PriceModel.Evaluate() or EvaluatePriceModel() to get IV or Greeks for option contracts. I am trying with below code, but didn't get it work. What could be wrong? It seems I need to specify a PriceModel somewhere, how? Is there other thing I need to specify as well? Thanks. 

 

qb = QuantBook()
sym_list = ['NVDA']
for sym_str in sym_list:
    sym = qb.AddEquity(sym_str, Resolution.Daily).Symbol
    op = qb.AddOption(sym_str, Resolution.Daily)
    op.PriceModel = OptionPriceModels.BjerksundStensland();

    def UniverseFunc(universe):
        return universe.IncludeWeeklys().Strikes(-5, 5).Expiration(timedelta(25), timedelta(31))  # 28day +/-3
    op.SetFilter(UniverseFunc)
    op_his = qb.GetOptionHistory(sym, datetime(2023, 7, 27), datetime(2023, 7, 27), Resolution.Daily)

    for slice in op_his:
        for canonical_symbol, chain in slice.OptionChains.items():
            for c in chain:
                # approach 1:
                # sec = qb.Securities[sym]
                # res = sec.PriceModel.Evaluate(sec, None, c)

                # approach 2:
                # https://github.com/QuantConnect/Lean/issues/3083#issuecomment-1435123295
                res = op.EvaluatePriceModel(slice, c)
                if c.Right == OptionRight.Put:
                    # print("{}, {}, {}, {}, {}, {}, {}, ".format(c.Symbol, c.Strike, c.Expiry, c.ImpliedVolatility, c.Greeks.Delta, c.LastPrice, c.Volume))
                    print("{}, {}, {}, {}, {}, {}, {}, ".format(slice.Time, c.Strike, c.Expiry, res.ImpliedVolatility, res.Greeks.Delta, c.LastPrice, c.Volume))