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

Improve Speed of Security Addition and Warmup #98

Open
4 tasks done
AlexCatarino opened this issue Feb 29, 2024 · 0 comments
Open
4 tasks done

Improve Speed of Security Addition and Warmup #98

AlexCatarino opened this issue Feb 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@AlexCatarino
Copy link
Member

Expected Behavior

Be able to subscribe and warm up more than 300 options.

Actual Behavior

It takes 2.2 seconds to add security, and make a historical request to warm it up:

2024-02-28T23:46:14.7609004Z TRACE:: InfluxDbHistoryProvider.GetHistory(): SPX   240315P05025000 IndexOption 2024-02-28T21:10:00.0000000Z to 2024-02-28T23:46:00.8007143Z. QuoteBar. Quote. Minute
2024-02-28T23:46:14.7609481Z TRACE:: InfluxDbHistoryProvider.GetHistory(): SPX   240315P05025000 IndexOption 2024-02-28T21:10:00.0000000Z to 2024-02-28T23:46:00.8007143Z. TradeBar. Trade. Minute
2024-02-28T23:46:14.7611697Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): SPX   240315P05025000 (OPT SPX USD Smart)
2024-02-28T23:46:15.3380276Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): clientOnContractDetails event: OPT SPX USD SMART 20240314 5025 P SPX
2024-02-28T23:46:15.3390762Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): contracts found: 1
2024-02-28T23:46:15.3391535Z TRACE:: InteractiveBrokersBrokerage::GetHistory(): Submitting request: SPX   240315P05025000 (OPT SPX USD Smart  20240314 5025 P): Minute/Quote 2/28/2024 9:10:00 PM UTC -> 2/28/2024 11:46:00 PM UTC
2024-02-28T23:46:16.0407240Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): SPX   240315P05025000 (OPT SPX USD Smart)
2024-02-28T23:46:16.2256337Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): clientOnContractDetails event: OPT SPX USD SMART 20240314 5025 P SPX
2024-02-28T23:46:16.2680131Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): contracts found: 1
2024-02-28T23:46:16.2681073Z TRACE:: InteractiveBrokersBrokerage::GetHistory(): Submitting request: SPX   240315P05025000 (OPT SPX USD Smart  20240314 5025 P): Minute/Trade 2/28/2024 9:10:00 PM UTC -> 2/28/2024 11:46:00 PM UTC
2024-02-28T23:46:16.7629965Z TRACE:: InteractiveBrokersBrokerage::GetHistory(): Download completed: SPX   240315P05025000 (OPT SPX USD Smart  20240314 5025 P)
2024-02-28T23:46:16.7643986Z TRACE:: EventBasedDataQueueHandlerSubscriptionManager.Subscribe(): SPX   240315P05025000
2024-02-28T23:46:16.7644386Z TRACE:: InteractiveBrokersBrokerage.Subscribe(): Subscribe Request: SPX   240315P05025000
2024-02-28T23:46:16.7645160Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): SPX   240315P05025000 (OPT SPX USD Smart)
2024-02-28T23:46:16.9488177Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): clientOnContractDetails event: OPT SPX USD SMART 20240314 5025 P SPX
2024-02-28T23:46:16.9922404Z TRACE:: InteractiveBrokersBrokerage.GetContractDetails(): contracts found: 1
2024-02-28T23:46:16.9924096Z TRACE:: InteractiveBrokersBrokerage.Subscribe(): Subscribe Processed: SPX   240315P05025000 (OPT SPX USD Smart  20240314 5025 P) # 22. SubscribedSymbols.Count: 5
2024-02-28T23:46:16.9925928Z TRACE:: DataManager.AddSubscription(): Added SPX   240315P05025000,#0,SPX,Minute,QuoteBar,Quote,Raw,OpenInterest. Start: 2/28/2024 11:46:00 PM. End: 12/31/2050 5:00:00 AM
2024-02-28T23:46:16.9928868Z TRACE:: DataManager.AddSubscription(): Added SPX   240315P05025000,#0,SPX,Minute,TradeBar,Trade,Raw,OpenInterest. Start: 2/28/2024 11:46:00 PM. End: 12/31/2050 5:00:00 AM
2024-02-28T23:46:16.9932410Z TRACE:: DataManager.AddSubscription(): Added SPX   240315P05025000,#0,SPX,Minute,OpenInterest,OpenInterest,Raw,OpenInterest,Internal. Start: 2/28/2024 6:00:00 AM. End: 12/31/2050 5:00:00 AM

It leads to a 10-minute time out with less than 300 contracts:
10 min x 60 = 600 s / 2 s = 300 contracts

Potential Solution

See #48

Reproducing the Problem

class IndexOptionsAlgorithm(QCAlgorithm):

    def Initialize(self):
        seeder = FuncSecuritySeeder(self.GetLastKnownPrices)
        self.SetSecurityInitializer(lambda security: seeder.SeedSecurity(security))
        index_symbol = self.AddIndex("SPX").Symbol
        option = self.AddIndexOption(index_symbol)
        option.SetFilter(lambda u: u.Strikes(-20, 1).Expiration(0, 100).PutsOnly().StandardsOnly())

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 Feb 29, 2024
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

1 participant