Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed Apr 11, 2024
1 parent b8a979b commit cd17661
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 22 deletions.
10 changes: 5 additions & 5 deletions Algorithm.Python/UniverseSelectedRegressionAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def Initialize(self):

self.UniverseSettings.Resolution = Resolution.Daily

self.universe = self.AddUniverse(self.SelectionFunction)
self._universe = self.AddUniverse(self.SelectionFunction)
self.selectionCount = 0

def SelectionFunction(self, fundamentals):
Expand All @@ -37,13 +37,13 @@ def SelectionFunction(self, fundamentals):
return [ x.Symbol for x in sortedByDollarVolume[:self.selectionCount] ]

def OnData(self, data):
if Symbol.Create("TSLA", SecurityType.Equity, Market.USA) in self.universe.Selected:
if Symbol.Create("TSLA", SecurityType.Equity, Market.USA) in self._universe.Selected:
raise ValueError(f"TSLA shouldn't of been selected")

self.Buy(next(iter(self.universe.Selected)), 1)
self.Buy(next(iter(self._universe.Selected)), 1)

def OnEndOfAlgorithm(self):
if self.selectionCount != 3:
raise ValueError(f"Unexpected selection count {self.selectionCount}")
if self.universe.Selected.Count != 3 or self.universe.Selected.Count == self.universe.Members.Count:
raise ValueError(f"Unexpected universe selected count {self.universe.Selected.Count}")
if self._universe.Selected.Count != 3 or self._universe.Selected.Count == self._universe.Members.Count:
raise ValueError(f"Unexpected universe selected count {self._universe.Selected.Count}")
6 changes: 0 additions & 6 deletions Algorithm/UniverseDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,8 @@ public class UniverseDefinitions
/// <summary>
/// Specifies that universe selection should not make changes on this iteration
/// </summary>
[StubsIgnore]
public Universe.UnchangedUniverse Unchanged => Universe.Unchanged;

/// <summary>
/// Alias for <see cref="Unchanged"/>
/// </summary>
public Universe.UnchangedUniverse UNCHANGED => Unchanged;

/// <summary>
/// Initializes a new instance of the <see cref="UniverseDefinitions"/> class
/// </summary>
Expand Down
6 changes: 0 additions & 6 deletions Common/Data/UniverseSelection/Universe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,8 @@ public abstract class Universe : IDisposable
/// <summary>
/// Gets a value indicating that no change to the universe should be made
/// </summary>
[StubsIgnore]
public static readonly UnchangedUniverse Unchanged = UnchangedUniverse.Instance;

/// <summary>
/// Alias for <see cref="Unchanged"/>
/// </summary>
public static readonly UnchangedUniverse UNCHANGED = Unchanged;

private HashSet<Symbol> _previousSelections;

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions Tests/Algorithm/AlgorithmDownloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public void Download_With_Python_Parameter_Successfully()
var byteKey = Encoding.ASCII.GetBytes($"UserName:Password");
var value = $"Basic ({Convert.ToBase64String(byteKey)})";

var headers = new PyDict();
using (Py.GIL())
{
var headers = new PyDict();
headers.SetItem("Authorization".ToPython(), value.ToPython());
}

var content = string.Empty;
Assert.DoesNotThrow(() => content = algo.Download("https://www.quantconnect.com/", headers));
Assert.IsNotEmpty(content);
var content = string.Empty;
Assert.DoesNotThrow(() => content = algo.Download("https://www.quantconnect.com/", headers));
Assert.IsNotEmpty(content);
}
}
}
}

0 comments on commit cd17661

Please sign in to comment.