QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.89k stars 3.28k forks source link

Incorrect Option Universe DataFrame Index #8331

Closed AlexCatarino closed 1 month ago

AlexCatarino commented 1 month ago

Expected Behavior

The index of Option Universe is Symbol/Time.

Actual Behavior

All the Symbols are the same for a given time:

Potential Solution

Review how Symbol is acquired.. it should come from a Data member.

Reproducing the Problem

self = QuantBook()
self.set_start_date(2020, 1, 1)
underlying = self.add_equity("SPY", data_normalization_mode=DataNormalizationMode.RAW).symbol
option_chain = self.option_chain(underlying).data_frame
print(option_chain.index.get_level_values('symbol').drop_duplicates())
print(option_chain.shape)

Logs:

Index(['SPY XFH59UO5PUUE|SPY R735QTJ8XC9X'], dtype='object', name='symbol') (6964, 12) It should have 6964 indices after we call drop_duplicates.

Checklist