Skip to content

Commit 4414d64

Browse files
committed
Use UniverseManager instead of CacheCustomPythonDataType
1 parent db8b7c9 commit 4414d64

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

Algorithm/QCAlgorithm.History.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using Python.Runtime;
2727
using QuantConnect.Data.UniverseSelection;
2828
using QuantConnect.Data.Auxiliary;
29+
using System.ComponentModel.DataAnnotations;
2930

3031
namespace QuantConnect.Algorithm
3132
{
@@ -1142,10 +1143,7 @@ private IEnumerable<SubscriptionDataConfig> GetMatchingSubscriptions(Symbol symb
11421143
var entry = MarketHoursDatabase.GetEntry(symbol, new[] { type });
11431144

11441145
// If the type is PythonData, we want to check what types are actually associated with the symbol
1145-
if (!_customPythonDataTypes.TryGetValue(symbol, out var dataType))
1146-
{
1147-
dataType = type;
1148-
}
1146+
var dataType = UniverseManager.TryGetValue(symbol, out var universe) ? universe.DataType : type;
11491147

11501148
// we were giving a specific type let's fetch it
11511149
return new[] { new SubscriptionDataConfig(

Algorithm/QCAlgorithm.Python.cs

-13
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public partial class QCAlgorithm
4040
{
4141
private readonly Dictionary<IntPtr, PythonIndicator> _pythonIndicators = new Dictionary<IntPtr, PythonIndicator>();
4242

43-
private Dictionary<Symbol, Type> _customPythonDataTypes = new Dictionary<Symbol, Type>();
44-
4543
/// <summary>
4644
/// PandasConverter for this Algorithm
4745
/// </summary>
@@ -266,12 +264,6 @@ private Security AddDataImpl(Type dataType, Symbol symbol, Resolution? resolutio
266264
var alias = symbol.ID.Symbol;
267265
SymbolCache.Set(alias, symbol);
268266

269-
// Cache the data type for custom python data to keep reference to the actual created type
270-
if (dataType.IsAssignableTo(typeof(PythonData)))
271-
{
272-
CacheCustomPythonDataType(symbol, dataType);
273-
}
274-
275267
if (timeZone != null)
276268
{
277269
// user set time zone
@@ -1895,10 +1887,5 @@ private PyObject TryCleanupCollectionDataFrame(Type dataType, PyObject history)
18951887
}
18961888
return history;
18971889
}
1898-
1899-
private void CacheCustomPythonDataType(Symbol symbol, Type dataType)
1900-
{
1901-
_customPythonDataTypes[symbol] = dataType;
1902-
}
19031890
}
19041891
}

Algorithm/QCAlgorithm.Universe.cs

-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ private SubscriptionDataConfig GetCustomUniverseConfiguration(Type dataType, str
697697
}
698698
// same as 'AddData<>' 'T' type will be treated as custom/base data type with always open market hours
699699
universeSymbol = QuantConnect.Symbol.Create(name, SecurityType.Base, market, baseDataType: dataType);
700-
CacheCustomPythonDataType(universeSymbol, dataType);
701700
}
702701
var marketHoursDbEntry = MarketHoursDatabase.GetEntry(universeSymbol, new[] { dataType });
703702
var dataTimeZone = marketHoursDbEntry.DataTimeZone;

0 commit comments

Comments
 (0)