Skip to content

Commit

Permalink
Remove duplicated keys in OpenInterestFutureUniverseSelectionModel (Q…
Browse files Browse the repository at this point in the history
…uantConnect#8365)

* First draft of the solution

* Enhance implementation
  • Loading branch information
Marinovsky authored and wtindall1 committed Nov 10, 2024
1 parent eca59c5 commit 180a0a4
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ public OpenInterestFutureUniverseSelectionModel(IAlgorithm algorithm, PyObject f
}

/// <summary>
/// Defines the future chain universe filter
/// Defines the future chain universe filter
/// </summary>
protected override FutureFilterUniverse Filter(FutureFilterUniverse filter)
{
return filter.Contracts(FilterByOpenInterest(filter.ToDictionary(x => x, x => _marketHoursDatabase.GetEntry(x.ID.Market, x, x.ID.SecurityType))));
// Remove duplicated keys
return filter.Contracts(FilterByOpenInterest(filter.DistinctBy(x => x).ToDictionary(x => x, x => _marketHoursDatabase.GetEntry(x.ID.Market, x, x.ID.SecurityType))));
}

/// <summary>
Expand Down

0 comments on commit 180a0a4

Please sign in to comment.