Prompt
Build an algorithm that combines two universes. The first selects the top 100 most liquid US Equities from fundamental data, caches the symbols, and leaves the active universe unchanged. The second pulls the Quiver CNBC-trader alternative dataset and keeps only entries whose traders field mentions "Cramer". The final universe is the intersection. When a security is added, subscribe to the underlying CNBC data feed for it, and log each incoming trader mention. Set $100,000 starting cash. Backtest from September 1, 2024 to December 31, 2024.
Error
The backtest ended with a runtime error.
[ERROR] FATAL UNHANDLED EXCEPTION: name 'QuiverCNBCsUniverseSelectionData' is not defined, at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper..ctor(String moduleName) in AlgorithmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs:line 188, at QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm(String assemblyPath, IAlgorithm& algorithmInstance, String& errorMessage) in AlgorithmFactory/Loader.cs:line 173,Engine.Run(): QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/project/main.pyc. AlgorithmPythonWrapper(): name 'QuiverCNBCsUniverseSelectionData' is not defined, at CramerTrackerAlgorithm, def _select_cnbc(self, data: List[QuiverCNBCsUniverseSelectionData]) -> List[Symbol]:, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^, in main.py: line 39, at , class CramerTrackerAlgorithm(QCAlgorithm):, in main.py: line 5, name 'QuiverCNBCsUniverseSelectionData' is not defined, at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in Engine/Setup/BacktestingSetupHandler.cs:line 113, at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath, WorkerThread workerThread) in Engine/Engine.cs:line 119,ApiConnection.TryRequest(https://www.quantconnect.com/api/v2/cloud/backtest/status/update): Error: The operation was canceled., Response content: ,BacktestingResultHandler.SendFinalResult(): Error running backtest analysis System.NullReferenceException: Object reference not set to an instance of an object., at QuantConnect.Lean.Engine.Results.Analysis.Analyses.ParameterCountAnalysis.Run(QCAlgorithm algorithm, Language language) in Engine/Results/Analysis/Analyses/ParameterCountAnalysis.cs:line 61, at QuantConnect.Lean.Engine.Results.Analysis.Analyses.ParameterCountAnalysis.Run(ResultsAnalysisRunParameters parameters) in Engine/Results/Analysis/Analyses/ParameterCountAnalysis.cs:line 39, at QuantConnect.Lean.Engine.Results.Analysis.ResultsAnalyzer.Run(Int32 timeLimitSeconds, Int32 maxFailedAnalyses) in Engine/Results/Analysis/ResultsAnalyzer.cs:line 122, at QuantConnect.Lean.Engine.Results.BacktestingResultHandler.SendFinalResult() in Engine/Results/BacktestingResultHandler.cs:line 420
During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/project/main.pyc. AlgorithmPythonWrapper(): name 'QuiverCNBCsUniverseSelectionData' is not defined
at CramerTrackerAlgorithm
def _select_cnbc(self, data: List[QuiverCNBCsUniverseSelectionData]) -> List[Symbol]:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
in main.py: line 39
at
class CramerTrackerAlgorithm(QCAlgorithm):
in main.py: line 5
name 'QuiverCNBCsUniverseSelectionData' is not defined
Code
main.py
from AlgorithmImports import *
from QuantConnect.DataSource import *
class CramerTrackerAlgorithm(QCAlgorithm):
def initialize(self):
self.set_start_date(2024, 9, 1)
self.set_end_date(2024, 12, 31)
self.set_cash(100_000)
self.settings.seed_initial_prices = True
# Cache of top-100 liquid symbols from fundamental universe
self._liquid_symbols = set()
# Fundamental universe: top 100 most liquid US equities
self._fundamental_universe = self.add_universe(self._select_fundamentals)
# Quiver CNBC-trader alternative data universe filtered to Cramer mentions
self._cnbc_universe = self.add_universe(
QuiverCNBCsUniverseSelectionData,
"QuiverCNBCsUniverse",
Resolution.DAILY,
self._select_cnbc
)
def _select_fundamentals(self, fundamentals: List[Fundamental]) -> List[Symbol]:
# Sort by dollar volume descending and take top 100
sorted_by_volume = sorted(
[f for f in fundamentals if f.has_fundamental_data],
key=lambda f: f.dollar_volume,
reverse=True
)
selected = [f.symbol for f in sorted_by_volume[:100]]
# Cache the symbols; leave universe unchanged if cache already populated
self._liquid_symbols = set(selected)
return selected
def _select_cnbc(self, data: List[QuiverCNBCsUniverseSelectionData]) -> List[Symbol]:
cramer_symbols = []
for datum in data:
if datum.traders and "Cramer" in datum.traders:
# Only keep if it is also in the liquid universe
if datum.symbol in self._liquid_symbols:
cramer_symbols.append(datum.symbol)
return cramer_symbols
def on_securities_changed(self, changes: SecurityChanges) -> None:
for security in changes.added_securities:
symbol = security.symbol
# Skip universe symbols (non-equity canonical types)
if symbol.security_type != SecurityType.EQUITY:
continue
# Subscribe to the underlying CNBC data feed for this equity
self.add_data(QuiverCNBCs, symbol)
self.log(f"Subscribed to QuiverCNBCs for {symbol.value}")
def on_data(self, data: Slice) -> None:
pass
def on_cnb_cs_data(self, data: QuiverCNBCs) -> None:
# Log each incoming trader mention
self.log(
f"{self.time} | {data.symbol.value} | Traders: {data.traders}"
)
Prompt
Build an algorithm that combines two universes. The first selects the top 100 most liquid US Equities from fundamental data, caches the symbols, and leaves the active universe unchanged. The second pulls the Quiver CNBC-trader alternative dataset and keeps only entries whose traders field mentions "Cramer". The final universe is the intersection. When a security is added, subscribe to the underlying CNBC data feed for it, and log each incoming trader mention. Set $100,000 starting cash. Backtest from September 1, 2024 to December 31, 2024.
Error
The backtest ended with a runtime error.
[ERROR] FATAL UNHANDLED EXCEPTION: name 'QuiverCNBCsUniverseSelectionData' is not defined, at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper..ctor(String moduleName) in AlgorithmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs:line 188, at QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm(String assemblyPath, IAlgorithm& algorithmInstance, String& errorMessage) in AlgorithmFactory/Loader.cs:line 173,Engine.Run(): QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/project/main.pyc. AlgorithmPythonWrapper(): name 'QuiverCNBCsUniverseSelectionData' is not defined, at CramerTrackerAlgorithm, def _select_cnbc(self, data: List[QuiverCNBCsUniverseSelectionData]) -> List[Symbol]:, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^, in main.py: line 39, at , class CramerTrackerAlgorithm(QCAlgorithm):, in main.py: line 5, name 'QuiverCNBCsUniverseSelectionData' is not defined, at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in Engine/Setup/BacktestingSetupHandler.cs:line 113, at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath, WorkerThread workerThread) in Engine/Engine.cs:line 119,ApiConnection.TryRequest(https://www.quantconnect.com/api/v2/cloud/backtest/status/update): Error: The operation was canceled., Response content: ,BacktestingResultHandler.SendFinalResult(): Error running backtest analysis System.NullReferenceException: Object reference not set to an instance of an object., at QuantConnect.Lean.Engine.Results.Analysis.Analyses.ParameterCountAnalysis.Run(QCAlgorithm algorithm, Language language) in Engine/Results/Analysis/Analyses/ParameterCountAnalysis.cs:line 61, at QuantConnect.Lean.Engine.Results.Analysis.Analyses.ParameterCountAnalysis.Run(ResultsAnalysisRunParameters parameters) in Engine/Results/Analysis/Analyses/ParameterCountAnalysis.cs:line 39, at QuantConnect.Lean.Engine.Results.Analysis.ResultsAnalyzer.Run(Int32 timeLimitSeconds, Int32 maxFailedAnalyses) in Engine/Results/Analysis/ResultsAnalyzer.cs:line 122, at QuantConnect.Lean.Engine.Results.BacktestingResultHandler.SendFinalResult() in Engine/Results/BacktestingResultHandler.cs:line 420
During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/project/main.pyc. AlgorithmPythonWrapper(): name 'QuiverCNBCsUniverseSelectionData' is not defined
at CramerTrackerAlgorithm
def _select_cnbc(self, data: List[QuiverCNBCsUniverseSelectionData]) -> List[Symbol]:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
in main.py: line 39
at
class CramerTrackerAlgorithm(QCAlgorithm):
in main.py: line 5
name 'QuiverCNBCsUniverseSelectionData' is not defined
Code
main.py