QuantBook Universe Selection (#7587)

* QuantBook Universe Selection

- QuantBook universe selection helper method. Adding new unit tests.
- Universe selection data sets improvements

* QuantBook API renames
This commit is contained in:
Martin-Molinero
2023-11-21 17:05:02 -03:00
committed by GitHub
parent adaa2f5862
commit 7498d2e6e2
16 changed files with 415 additions and 72 deletions
+15 -2
View File
@@ -1466,7 +1466,7 @@ namespace QuantConnect.Algorithm
return pythonIndicator;
}
private PyObject GetDataFrame(IEnumerable<Slice> data, Type dataType = null)
protected PyObject GetDataFrame(IEnumerable<Slice> data, Type dataType = null)
{
var memoizingEnumerable = data as MemoizingEnumerable<Slice>;
if (memoizingEnumerable != null)
@@ -1475,7 +1475,20 @@ namespace QuantConnect.Algorithm
// the user will only have access to the final pandas data frame object
memoizingEnumerable.Enabled = false;
}
return PandasConverter.GetDataFrame(data, dataType);
var history = PandasConverter.GetDataFrame(data, dataType);
if(dataType != null && dataType.IsAssignableTo(typeof(BaseDataCollection)))
{
// clear out the first symbol level since it doesn't make sense, it's the universe generic symbol
dynamic dynamic = history;
using (Py.GIL())
{
if (!dynamic.empty)
{
dynamic.index = dynamic.index.droplevel("symbol");
}
}
}
return history;
}
}
}