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

Two Option Data Events Within One Minute #133

Open
4 tasks done
AlexCatarino opened this issue Nov 26, 2024 · 0 comments
Open
4 tasks done

Two Option Data Events Within One Minute #133

AlexCatarino opened this issue Nov 26, 2024 · 0 comments

Comments

@AlexCatarino
Copy link
Member

AlexCatarino commented Nov 26, 2024

Expected Behavior

When subscribing to minute-resolution data, we receive one data point per minute.

Actual Behavior

Algorithm has consistently received one bar at the zeroth second and at the 54th:

2024-11-26 15**:16:03** : Time: 2024-11-26 10:16:01.419949 | Option: TSLA 241129P00332500 | Strike: 332.5 | BidPrice: 2.64 | AskPrice: 2.7 | UnderlyingPrice: 341.66 | Delta: -0.268349463384532
2024-11-26 15**:16:54** : Time: 2024-11-26 10:16:54.800595 | Option: TSLA 241129P00332500 | Strike: 332.5 | BidPrice: 0.0 | AskPrice: 0.0 | UnderlyingPrice: 341.57 | Delta: -0.268349463384532
2024-11-26 15**:17:00** : Time: 2024-11-26 10:17:00.023992 | Option: TSLA 241129P00332500 | Strike: 332.5 | BidPrice: 2.6 | AskPrice: 2.66 | UnderlyingPrice: 341.72 | Delta: -0.266020143338156
2024-11-26 15**:17:54** : Time: 2024-11-26 10:17:54.801257 | Option: TSLA 241129P00332500 | Strike: 332.5 | BidPrice: 0.0 | AskPrice: 0.0 | UnderlyingPrice: 341.64 | Delta: -0.266020143338156
2024-11-26 15**:18:00** : Time: 2024-11-26 10:18:00.002957 | Option: TSLA 241129P00332500 | Strike: 332.5 | BidPrice: 2.9 | AskPrice: 2.99 | UnderlyingPrice: 340.63 | Delta: -0.287038025529599
2024-11-26 15**:18:54** : Time: 2024-11-26 10:18:54.800301 | Option: TSLA 241129P00332500 | Strike: 332.5 | BidPrice: 0.0 | AskPrice: 0.0 | UnderlyingPrice: 340.81 | Delta: -0.287038025529599
2024-11-26 15**:19:00** : Time: 2024-11-26 10:19:00.068202 | Option: TSLA 241129P00332500 | Strike: 332.5 | BidPrice: 2.78 | AskPrice: 2.83 | UnderlyingPrice: 341.12 | Delta: -0.280001342839822

EDIT:
Additional logging:

2024-11-27 14:46:00 : Time: 2024-11-27 09:46:00.042342 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 17.9 | AskPrice: 18.05 | UnderlyingPrice: 339.39 | Delta: 0.528016374631765Underlying TradeBar FF: False | Underlying QuoteBar FF: False | Option QuoteBar FF: False |
2024-11-27 14:46:54 : Time: 2024-11-27 09:46:54.800524 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 0.0 | AskPrice: 0.0 | UnderlyingPrice: 339.35 | Delta: 0.528016374631765Option TradeBar FF: True |
2024-11-27 14:47:00 : Time: 2024-11-27 09:47:00.072929 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 18.25 | AskPrice: 18.4 | UnderlyingPrice: 340.29 | Delta: 0.535756540535007Underlying TradeBar FF: False | Underlying QuoteBar FF: False | Option TradeBar FF: False | Option QuoteBar FF: False |
2024-11-27 14:48:00 : Time: 2024-11-27 09:48:00.004858 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 17.75 | AskPrice: 17.95 | UnderlyingPrice: 339.3 | Delta: 0.526544367034253Underlying TradeBar FF: False | Underlying QuoteBar FF: False | Option TradeBar FF: False | Option QuoteBar FF: False |
2024-11-27 14:49:00 : Time: 2024-11-27 09:49:00.020808 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 17.45 | AskPrice: 17.65 | UnderlyingPrice: 338.84 | Delta: 0.522526986378076Underlying TradeBar FF: False | Underlying QuoteBar FF: False | Option TradeBar FF: False | Option QuoteBar FF: False |
2024-11-27 14:50:00 : Time: 2024-11-27 09:50:00.036178 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 17.55 | AskPrice: 17.7 | UnderlyingPrice: 339.05 | Delta: 0.523696513196978Underlying TradeBar FF: False | Underlying QuoteBar FF: False | Option TradeBar FF: False | Option QuoteBar FF: False |
2024-11-27 14:51:00 : Time: 2024-11-27 09:51:00.075431 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 17.7 | AskPrice: 17.85 | UnderlyingPrice: 339.32 | Delta: 0.526679317994741Underlying TradeBar FF: False | Underlying QuoteBar FF: False | Option QuoteBar FF: False |
2024-11-27 14:51:54 : Time: 2024-11-27 09:51:54.800155 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 0.0 | AskPrice: 0.0 | UnderlyingPrice: 339.22 | Delta: 0.526679317994741Option TradeBar FF: True |

We can see it's not frequent (twice in 5 minutes). The option data was fill forwarded: "Option TradeBar FF: True |", and slice didn't have TradeBar and QuoteBar for the Underlying or QuoteBar for the Option.

2024-11-27 14:46:54 : Time: 2024-11-27 09:46:54.800524 | Option: TSLA 241220C00340000 | Strike: 340.0 | BidPrice: 0.0 | AskPrice: 0.0 | UnderlyingPrice: 339.35 | Delta: 0.528016374631765Option TradeBar FF: True |

Potential Solution

N/A

Reproducing the Problem

Deploy algorithm with TSLA's options:

from AlgorithmImports import *

class TestOptions(QCAlgorithm):

    def Initialize(self):
        # Configuración inicial
        self.SetStartDate(2024, 11, 18)  
        self.SetEndDate(2024, 11, 19)  
        self.SetCash(100000)          
        self.underlying = None
        self.option = None
        self.option_contract = None

        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) 

        self.underlying = self.AddEquity("TSLA", Resolution.Minute)
        self.underlying.SetDataNormalizationMode(DataNormalizationMode.RAW)
        self.option = self.AddOption("TSLA", Resolution.Minute)
        self.option.SetDataNormalizationMode(DataNormalizationMode.RAW)
        # Let0s just select the ATM call
        self.option.SetFilter(lambda x: x.CallsOnly().FrontMonth().Strikes(0, 0))
        
    def OnData(self, slice):

        chains = slice.OptionChains.get(self.option.Symbol)
        if chains is None:
            return

        # First contract by deafult
        option = [contract for contract in chains][0]
         
        if option:
            msg = f"Time: {self.Time} | " \
                f"Option: {option.Symbol} | " \
                f"Strike: {option.Strike} | " \
                f"BidPrice: {option.BidPrice} | " \
                f"AskPrice: {option.AskPrice} | " \
                f"UnderlyingPrice: {option.UnderlyingLastPrice} | " \
                f"Delta: {option.Greeks.Delta}"
            trade_bar, quote_bar = slice.bars.get("TSLA"), slice.quote_bars.get("TSLA")
            trade_option, quote_option = slice.bars.get(option.Symbol), slice.quote_bars.get(option.Symbol)
            if trade_bar:
                msg += f"Underlying TradeBar FF: {trade_bar.is_fill_forward} | "
            if quote_bar:
                msg += f"Underlying QuoteBar FF: {quote_bar.is_fill_forward} | "
            if trade_option:
                msg += f"Option TradeBar FF: {trade_option.is_fill_forward} | "
            if quote_option:
                msg += f"Option QuoteBar FF: {quote_option.is_fill_forward} | "

            if self.live_mode:
                self.Log(msg)

System Information

QuantConnect Cloud.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant