Hello all,
I am new to this library. I would like to start by saying that the amount of work that has been put into this application is immense and I am thankful that it exists. I plan to fully utilize it once I have the algorithm in my head working. I went through the entire bootcamp and it is amazing what this library can accomplish.
I tried to set up Docker + VS Code on Mac for Python. Everything seems to be working except that no matter what I do I can not seem to get a universe going. I am wondering what it is that I am doing wrong. I've cut down the code to get to the point. I've changed the universe to one of the of the example codes in the documentation with the slight altering. The documentation example as is also did not work.
class GapRunner(QCAlgorithm):
def Initialize(self):
# Set requested data resolution
self.UniverseSettings.Resolution = Resolution.Minute
self.SetStartDate(2014, 10, 7) # Set Start Date
self.SetEndDate(2020, 10, 7) # Set End Date
self.SetCash(30000) # Set Strategy Cash
self.coarse_count = 10
self.coarses = {}
self.AddUniverse(self.CoarseFilterFunction)
self.Debug(" ----------- we are here -------------- ")
def CoarseFilterFunction(self, coarse):
sortedByDollarVolume = sorted(
coarse, key=lambda x: x.DollarVolume, reverse=True)
filtered = [x.Symbol for x in sortedByDollarVolume
if x.Price < 10]
self.Log("Filtered length is ---- " + str(len(filtered)))
Below is the part of the output
PythonEngine.Initialize(): clr GetManifestResourceStream...
20210119 02:06:08.105 Trace:: PythonInitializer.Initialize(): ended
20210119 02:06:08.106 Trace:: DebuggerHelper.Initialize(): python initialization done
20210119 02:06:08.107 Trace:: DebuggerHelper.Initialize(): starting...
20210119 02:06:08.107 Trace:: DebuggerHelper.Initialize(): waiting for PTVSD debugger to attach at localhost:5678...
20210119 02:06:09.785 Trace:: DebuggerHelper.Initialize(): started
20210119 02:06:09.812 Trace:: AlgorithmPythonWrapper(): Python version 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:25:33)
[GCC 7.3.0]: Importing python module GapRunner
20210119 02:06:11.801 Trace:: AlgorithmPythonWrapper(): Creating IAlgorithm instance.
20210119 02:06:13.116 Trace:: LocalObjectStore.Initialize(): Storage Root: /Lean/Launcher/bin/Debug/storage/QCAlgorithm
20210119 02:06:13.147 Trace:: Config.Get(): Configuration key not found. Key: security-data-feeds - Using default value:
20210119 02:06:13.416 Trace:: Config.GetValue(): data-feed-workers-count - Using default value: 8
20210119 02:06:13.416 Trace:: Config.GetValue(): data-feed-max-work-weight - Using default value: 400
20210119 02:06:13.417 Trace:: Config.Get(): Configuration key not found. Key: data-feed-queue-type - Using default value: QuantConnect.Lean.Engine.DataFeeds.WorkScheduling.WorkQueue, QuantConnect.Lean.Engine
20210119 02:06:13.419 Trace:: WeightedWorkScheduler(): will use 8 workers and MaxWorkWeight is 400. Queue type: WorkQueue
20210119 02:06:13.498 Trace:: FactorFile.HasScalingFactors(): Factor file not found: QC-UNIVERSE-COARSE-USA-7F6CACD8-B398-4EE3-9DD9-5757873B28DB
20210119 02:06:13.542 Trace:: Config.GetValue(): show-missing-data-logs - Using default value: False
20210119 02:06:13.560 Trace:: BaseSetupHandler.SetupCurrencyConversions():
Symbol Quantity Conversion = Value in USD
USD: $ 30000.00 @ 1.00 = $30000.0
-------------------------------------------------
CashBook Total Value: $30000.0
20210119 02:06:13.571 Trace:: BacktestingResultHandler(): Sample Period Set: 789.48
20210119 02:06:13.578 Trace:: Config.GetValue(): forward-console-messages - Using default value: True
20210119 02:06:13.588 Trace:: JOB HANDLERS:
20210119 02:06:13.589 Trace:: DataFeed: QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed
20210119 02:06:13.590 Trace:: Setup: QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler
20210119 02:06:13.590 Trace:: RealTime: QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
20210119 02:06:13.591 Trace:: Results: QuantConnect.Lean.Engine.Results.BacktestingResultHandler
20210119 02:06:13.592 Trace:: Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler
20210119 02:06:13.592 Trace:: Alpha: QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20210119 02:06:13.593 Trace:: ObjectStore: QuantConnect.Lean.Engine.Storage.LocalObjectStore
20210119 02:06:13.594 Trace:: History Provider: QuantConnect.Lean.Engine.HistoricalData.SubscriptionDataReaderHistoryProvider
20210119 02:06:13.661 Trace:: Debug: Launching analysis for GapRunner with LEAN Engine v2.4.0.0
20210119 02:06:13.673 Trace:: AlgorithmManager.Run(): Begin DataStream - Start: 10/7/2014 12:00:00 AM Stop: 10/7/2020 11:59:59 PM
20210119 02:06:20.269 Trace:: UniverseSelection.AddPendingInternalDataFeeds(): Adding internal benchmark data feed SPY,SPY,Hour,TradeBar,Trade,Adjusted,Internal
20210119 02:06:20.833 Trace:: Debug: ----------- we are here --------------
20210119 02:06:20.834 Trace:: Log: Filtered length is ---- 0
20210119 02:06:24.315 Trace:: Synchronizer.GetEnumerator(): Exited thread.
20210119 02:06:24.317 Trace:: AlgorithmManager.Run(): Firing On End Of Algorithm...
20210119 02:06:24.322 Trace:: Engine.Run(): Exiting Algorithm Manager
20210119 02:06:24.343 Trace:: FileSystemDataFeed.Exit(): Start. Setting cancellation token...
20210119 02:06:24.349 Trace:: FileSystemDataFeed.Exit(): Exit Finished.
20210119 02:06:24.350 Trace:: DefaultAlphaHandler.Exit(): Exiting...
20210119 02:06:24.366 Trace:: DefaultAlphaHandler.Exit(): Ended
20210119 02:06:24.368 Trace:: BacktestingResultHandler.Exit(): starting...
20210119 02:06:24.369 Trace:: BacktestingResultHandler.Exit(): Saving logs...
20210119 02:06:24.392 Trace:: StopSafely(): waiting for 'Result Thread' thread to stop...
20210119 02:06:24.967 Trace:: Log: Filtered length is ---- 0
20210119 02:06:24.969 Trace:: Debug: Algorithm Id:(GapRunner) completed in 10.73 seconds at 1k data points per second. Processing total of 9,553 data points.
What am I doing wrong? Why is the filtered length is always 0? I've been doing many variations of the universe selection and I can't seem to get it going.
Karthik Kailash
Do you have the requisite data stored locally?
Okan
Thank you for taking time to try to help me out, I appreciate it.
I was under the impression that the docker container has the data. In the logs, the last line says processed 95553 data points. I assumed those data points are the trading data. Is that wrong?
Derek Melchin
Hi Okan,
To use QC Cloud data in a local backtest, we use the API File Provider. The `filtered` length in the CoarseFilterFunction is 0 because fundamental data is not currently included.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Okan
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!