Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Option Chains for Future Options #8277

Open
4 tasks done
AlexCatarino opened this issue Aug 23, 2024 · 1 comment
Open
4 tasks done

Empty Option Chains for Future Options #8277

AlexCatarino opened this issue Aug 23, 2024 · 1 comment

Comments

@AlexCatarino
Copy link
Member

Expected Behavior

No need to define SetFilter for the underlying future. The option chain should have the mapped contract.

Actual Behavior

If we need to set the filter.

Potential Solution

N/A

Reproducing the Problem

# region imports
from AlgorithmImports import *
# endregion

class BasicFutureOptionAlgorithm(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2023,1,1)
        self._future = self.add_future(Futures.Indices.SP_500_E_MINI,
            extended_market_hours=True,
            data_mapping_mode=DataMappingMode.OPEN_INTEREST,
            data_normalization_mode=DataNormalizationMode.BACKWARDS_RATIO,
            contract_depth_offset=0)
        #self._future.set_filter(0, 182)   # < --uncomment to get options

        self.add_future_option(self._future.symbol, lambda u: u.strikes(-1, 1))
    
    def on_data(self, data):
        # Iterate all Option chains to find the desired future and future options contracts 
        for canonical_symbol, chain in data.option_chains.items():
            future_contract = canonical_symbol.underlying
            for symbol, contract in chain.contracts.items():
                contract.strike

        # Get the Option chain for the mapped contract 
        chain = data.option_chains.get(Symbol.create_canonical_option(self._future.mapped))
        if chain:
            for symbol, contract in chain.contracts.items():
                contract.strike

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue
@AlexCatarino
Copy link
Member Author

By the way, it would be nice to be able to get the chain with the underlying symbol:

chain = data.option_chains.get(self._future.mapped)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant