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

Fix 17 data wrong sorted queue #18

Merged

Conversation

Romazes
Copy link
Contributor

@Romazes Romazes commented Aug 9, 2024

Description

This pull request addresses a bug in the GetOptions method where redundant requests were being made for the same option contract on consecutive days within a specified date range. The current implementation iterates over each day and retrieves the option chain for the given symbol, which can result in multiple identical requests if the same option contract exists on multiple days.

Related Issue

Motivation and Context

The motivation behind this fix is to optimize the retrieval of option contracts by avoiding unnecessary and redundant API calls. This change is intended to enhance performance and reduce potential overhead caused by duplicate requests, especially when dealing with large datasets or extended date ranges.

Requires Documentation Change

N/A

How Has This Been Tested?

Run specific algorithm from issue:

public class SampleOptionAlgo : QCAlgorithm
{
    public override void Initialize()
    {
        SetStartDate(2024, 7, 18);
        SetEndDate(2024, 7, 19);
        SetCash(100000);

        SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin);
        var equity = AddEquity("OXY", Resolution.Minute).Symbol;
        Securities[equity].SetDataNormalizationMode(DataNormalizationMode.Raw);
        SetBenchmark(equity);

        var option = AddOption(equity, Resolution.Minute);
        option.SetFilter(-1, 1, TimeSpan.FromDays(20), TimeSpan.FromDays(60));
    }

    public override void OnData(Slice data)
    {
        foreach (var (symbol, optionChain) in data.OptionChains)
        {
            foreach (var option in optionChain)
            {
                Log($"Received {option}");
            }
        }
    }

}

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@Romazes Romazes requested a review from Martin-Molinero August 9, 2024 22:34
@Romazes Romazes self-assigned this Aug 9, 2024
Copy link
Contributor

@jhonabreul jhonabreul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you!
Just a couple of minor comments, but looks good!

QuantConnect.Polygon.Tests/PolygonAdditionalTests.cs Outdated Show resolved Hide resolved
QuantConnect.Polygon.Tests/PolygonAdditionalTests.cs Outdated Show resolved Hide resolved
@jhonabreul jhonabreul merged commit 426e686 into QuantConnect:master Aug 12, 2024
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

Successfully merging this pull request may close these issues.

3 participants