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

Open Interest Support #12

Open
4 tasks done
AlexCatarino opened this issue Apr 26, 2024 · 3 comments
Open
4 tasks done

Open Interest Support #12

AlexCatarino opened this issue Apr 26, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@AlexCatarino
Copy link
Member

AlexCatarino commented Apr 26, 2024

Expected Behavior

This data source supports open interest.

Actual Behavior

We receive the following message:

“Warning: USA IndexOption OpenInterest data not supported. Please consider reviewing the data providers selection.” 

Proposed Solution

It's found in the Option Chain endpoint /v3/snapshot/options/{underlyingAsset}
https://polygon.io/docs/options/get_v3_snapshot_options__underlyingasset

Reproducing the Problem

Deploy index option algorithm with polygon data provider.

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 AlexCatarino added the enhancement New feature or request label Apr 26, 2024
@endk17
Copy link

endk17 commented May 1, 2024

Specification

Is there the means to query for open interest value when using Polygon datasets ?

Current

  • No, right now this is not possible using current implementation of Polygon dataset
  • The current implementation in QuantConnect.Polygon/PolygonOptionChainProvider.cs targets polygon data endpoint /v3/reference/options/contracts
  • The polygon data endpoint /v3/reference/options/contracts does not provide values for: Open interest, the greeks (delta, gamma etc.) and implied volatility
  • When using the OptionContract object, values for Open interest, the greeks (delta, gamma etc.) and implied volatility should be made available. Below is the referenced properties that are exposed when invoking the OptionContract object

Proposed

The below files should be modified to support the, above noted, current specification

@endk17
Copy link

endk17 commented May 7, 2024

Hi @AlexCatarino

Can you and or your support team please assist with getting my PR reviewed and approved.

ref: #15

Many thanks
Enda

@ArthurAsenheimer
Copy link

FYI, the following algorithm reproduces the bug:

# region imports
from AlgorithmImports import *
# endregion


class IndexOptionAlgorithm(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2024, 1, 1) 
        self.set_end_date(2024, 5, 1)
        self.set_cash(100000)
        self.spx = self.add_index('SPX') 
        self.spx_option = self.add_index_option(self.spx.symbol) 
        self.spx_option.set_filter(-1, 1, 0, 100)  


    def on_data(self, data: Slice):
        if self.algorithm_mode is not AlgorithmMode.LIVE:
            return 
        chain = data.option_chains.get(self.spx_option.symbol)
        if not chain:
            return 
        for contract in chain: 
            self.log(f"{contract.symbol}| open interest: {contract.open_interest}; delta: {contract.greeks.delta}; implied volatility: {contract.implied_volatility}.") 

Excerpt from logs when using QC + Polygon as data providers in live mode:

2024-05-10 17:37:48 Launching analysis for L-3ffd0d19687922fd9e89e48e6bdf8fea with LEAN Engine v2.5.0.0.16423
2024-05-10 17:37:54 Paper Brokerage account base currency: USD
2024-05-10 17:38:08 Warning: usa IndexOption OpenInterest data not supported. Please consider reviewing the data providers selection.
2024-05-10 17:39:00 SPX   240517C05215000| open interest: 0.0; delta: 0.532253383735248; implied volatility: 0.0920031928428969.
2024-05-10 17:39:00 SPX   240517C05220000| open interest: 0.0; delta: 0.505825425148433; implied volatility: 0.0918866720162672.
2024-05-10 17:39:00 SPX   240517P05215000| open interest: 0.0; delta: -0.470339109238199; implied volatility: 0.102137279946327.
2024-05-10 17:39:00 SPX   240517P05220000| open interest: 0.0; delta: -0.49415161757284; implied volatility: 0.101699571257173.
2024-05-10 17:39:00 SPX   240621C05215000| open interest: 0.0; delta: 0.558908042608909; implied volatility: 0.109208822620727.
2024-05-10 17:39:00 SPX   240621C05220000| open interest: 0.0; delta: 0.549011714694276; implied volatility: 0.108904994834179.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants