public void OverridesSupportedResolutions() { dynamic instance; using (Py.GIL()) { PyObject test = PythonEngine.ModuleFromString("testModule", @" from clr import AddReference AddReference(""System"") AddReference(""QuantConnect.Common"") from QuantConnect import * from QuantConnect.Python import * class Test(PythonData): def SupportedResolutions(self): return [ Resolution.Tick, Resolution.Daily ]").GetAttr("Test"); instance = test.CreateType().GetBaseDataInstance(); } var res = instance.SupportedResolutions(); Assert.AreEqual(new List <Resolution> { Resolution.Tick, Resolution.Daily }, res); }
/// <summary> /// Gets the data of the specified symbol and type. /// </summary> /// <param name="type">The type of data we seek</param> /// <returns>The data for the requested symbol</returns> public PyObject Get(PyObject type) { var result = GetImpl(type.CreateType(), _slice) as object; using (Py.GIL()) { return(result.ToPython()); } }
public void OverridesDefaultResolution() { dynamic instance; using (Py.GIL()) { PyObject test = PythonEngine.ModuleFromString("testModule", @" from AlgorithmImports import * class Test(PythonData): def DefaultResolution(self): return Resolution.Tick").GetAttr("Test"); instance = test.CreateType().GetBaseDataInstance(); } Assert.AreEqual(Resolution.Tick, instance.DefaultResolution()); }
public void OverridesIsSparseData(string value, bool booleanValue) { dynamic instance; using (Py.GIL()) { PyObject test = PythonEngine.ModuleFromString("testModule", @" from AlgorithmImports import * class Test(PythonData): def IsSparseData(self): return " + $"{value}").GetAttr("Test"); instance = test.CreateType().GetBaseDataInstance(); } Assert.AreEqual(booleanValue, instance.IsSparseData()); }
public void IsSparseDataDefaultValue() { dynamic instance; using (Py.GIL()) { PyObject test = PythonEngine.ModuleFromString("testModule", @" from AlgorithmImports import * class Test(PythonData): def Pepe(self): return 1").GetAttr("Test"); instance = test.CreateType().GetBaseDataInstance(); instance.Symbol = Symbol.CreateBase(typeof(decimal), Symbols.SPY, QuantConnect.Market.USA); } Assert.IsTrue(instance.IsSparseData()); }
public void OverridesSupportedResolutions() { dynamic instance; using (Py.GIL()) { PyObject test = PythonEngine.ModuleFromString("testModule", @" from AlgorithmImports import * class Test(PythonData): def SupportedResolutions(self): return [ Resolution.Tick, Resolution.Daily ]").GetAttr("Test"); instance = test.CreateType().GetBaseDataInstance(); } var res = instance.SupportedResolutions(); Assert.AreEqual(new List <Resolution> { Resolution.Tick, Resolution.Daily }, res); }
public void OverridesDefaultResolution() { dynamic instance; using (Py.GIL()) { PyObject test = PythonEngine.ModuleFromString("testModule", @" from clr import AddReference AddReference(""System"") AddReference(""QuantConnect.Common"") from QuantConnect import * from QuantConnect.Python import * class Test(PythonData): def DefaultResolution(self): return Resolution.Tick").GetAttr("Test"); instance = test.CreateType().GetBaseDataInstance(); } Assert.AreEqual(Resolution.Tick, instance.DefaultResolution()); }
public void OverridesIsSparseData(string value, bool booleanValue) { dynamic instance; using (Py.GIL()) { PyObject test = PythonEngine.ModuleFromString("testModule", @" from clr import AddReference AddReference(""System"") AddReference(""QuantConnect.Common"") from QuantConnect import * from QuantConnect.Python import * class Test(PythonData): def IsSparseData(self): return " + $"{value}").GetAttr("Test"); instance = test.CreateType().GetBaseDataInstance(); } Assert.AreEqual(booleanValue, instance.IsSparseData()); }
/// <summary> /// Gets the data of the specified symbol and type. /// </summary> /// <param name="type">The type of data we seek</param> /// <param name="symbol">The specific symbol was seek</param> /// <returns>The data for the requested symbol</returns> public dynamic Get(PyObject type, Symbol symbol) { return(GetImpl(type.CreateType(), _slice)[symbol]); }