Hello Community,
I am trying to execute the covered call. Before I could add entry/exit logic, I decided to write a plain program testing a simple sell of a call. I see that the execution is correct when I test it on the Quantconnect platform. But when I backtest locally on lean, I do not see any trade execution.
Please point out where I am making any mistakes.
Following is
C:\Users\QT>lean backtest coveredc
←[?1h←=20220712 10:21:35.291 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20220712 10:21:35.305 TRACE:: Composer(): Loading Assemblies from /Lean/Launcher/bin/Debug
20220712 10:21:35.358 TRACE:: Python for .NET Assembly: Python.Runtime, Version=2.0.16.0, Culture=neutral, PublicKeyToken=5000fea6cba702dd
20220712 10:21:35.370 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20220712 10:21:35.426 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20220712 10:21:35.427 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: /Lean/Data
20220712 10:21:35.427 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit) Host: Ninad-Zone
20220712 10:21:35.433 TRACE:: Engine.Main(): Started 10:21 AM
20220712 10:21:35.440 TRACE:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager
20220712 10:21:35.464 TRACE:: JobQueue.NextJob(): Selected /LeanCLI/main.py
20220712 10:21:35.530 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
20220712 10:21:35.531 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440
20220712 10:21:35.531 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20220712 10:21:35.532 TRACE:: Config.GetValue(): storage-permissions - Using default value: 3
20220712 10:21:35.541 TRACE:: Config.Get(): Configuration key not found. Key: job-organization-id - Using default value:
20220712 10:21:35.542 TRACE:: Config.Get(): Configuration key not found. Key: data-permission-manager - Using default value: DataPermissionManager
20220712 10:21:35.561 TRACE:: AlgorithmManager.CreateTokenBucket(): Initializing LeakyBucket: Capacity: 120 RefillAmount: 18 TimeInterval: 1440
20220712 10:21:35.564 TRACE:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20
20220712 10:21:35.590 TRACE:: TextSubscriptionDataSourceReader.SetCacheSize(): Setting cache size to 71582788 items
20220712 10:21:35.960 TRACE:: Config.GetValue(): algorithm-creation-timeout - Using default value: 90
20220712 10:21:35.966 TRACE:: PythonInitializer.Initialize(): start...
PythonEngine.Initialize(): clr GetManifestResourceStream...
20220712 10:21:36.933 TRACE:: PythonInitializer.Initialize(): ended
20220712 10:21:36.937 TRACE:: AlgorithmPythonWrapper(): Python version 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:25:33)
[GCC 7.3.0]: Importing python module main
20220712 10:21:38.989 TRACE:: AlgorithmPythonWrapper(): main successfully imported.
20220712 10:21:38.994 TRACE:: AlgorithmPythonWrapper(): Creating IAlgorithm instance.
20220712 10:21:39.004 TRACE:: Config.GetValue(): api-data-update-period - Using default value: 1
20220712 10:21:39.141 TRACE:: Config.GetValue(): mute-python-library-logging - Using default value: True
20220712 10:21:39.157 TRACE:: LocalObjectStore.Initialize(): Storage Root: /Storage/QCAlgorithm. StorageFileCount 9999999. StorageLimitMB 9999999
20220712 10:21:39.174 TRACE:: BacktestingSetupHandler.Setup(): Setting up job: UID: 0, PID: 686314193, Version: 2.5.0.0, Source: WebIDE
20220712 10:21:39.180 TRACE:: Config.Get(): Configuration key not found. Key: security-data-feeds - Using default value:
20220712 10:21:39.350 TRACE:: Config.GetValue(): data-feed-max-work-weight - Using default value: 400
20220712 10:21:39.350 TRACE:: Config.GetValue(): data-feed-workers-count - Using default value: 16
20220712 10:21:39.351 TRACE:: WeightedWorkScheduler(): will use 16 workers and MaxWorkWeight is 400
20220712 10:21:39.379 TRACE:: BaseSetupHandler.SetupCurrencyConversions():
Symbol Quantity Conversion = Value in USD
USD: $ 100000.00 @ 1.00 = $100000.0
-------------------------------------------------
CashBook Total Value: $100000.0
20220712 10:21:39.383 TRACE:: SetUp Backtesting: User: 0 ProjectId: 686314193 AlgoId: 1211218677
20220712 10:21:39.385 TRACE:: Dates: Start: 10/07/2018 End: 01/01/2019 Cash: ¤100,000.00 MaximumRuntime: 100.00:00:00 MaxOrders: 2147483647
20220712 10:21:39.389 TRACE:: BacktestingResultHandler(): Sample Period Set: 31.32
20220712 10:21:39.391 TRACE:: Time.TradeableDates(): Security Count: 2
20220712 10:21:39.395 TRACE:: Config.GetValue(): forward-console-messages - Using default value: True
20220712 10:21:39.398 TRACE:: JOB HANDLERS:
20220712 10:21:39.399 TRACE:: DataFeed: QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed
20220712 10:21:39.399 TRACE:: Setup: QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler
20220712 10:21:39.400 TRACE:: RealTime: QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
20220712 10:21:39.400 TRACE:: Results: QuantConnect.Lean.Engine.Results.BacktestingResultHandler
20220712 10:21:39.400 TRACE:: Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler
20220712 10:21:39.401 TRACE:: Alpha: QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20220712 10:21:39.401 TRACE:: ObjectStore: QuantConnect.Lean.Engine.Storage.LocalObjectStore
20220712 10:21:39.402 TRACE:: History Provider: QuantConnect.Lean.Engine.HistoricalData.HistoryProviderManager
20220712 10:21:39.459 TRACE:: Debug: Launching analysis for 1211218677 with LEAN Engine v2.5.0.0
20220712 10:21:39.468 TRACE:: Event Name "Daily Sampling", scheduled to run.
20220712 10:21:39.470 TRACE:: AlgorithmManager.Run(): Begin DataStream - Start: 10/7/2018 12:00:00 AM Stop: 1/1/2019 11:59:59 PM Time: 10/7/2018 12:00:00 AM Warmup: False
20220712 10:21:39.990 TRACE:: Config.GetValue(): show-missing-data-logs - Using default value: False
20220712 10:21:40.299 TRACE:: UniverseSelection.AddPendingInternalDataFeeds(): Adding internal benchmark data feed SPY,#0,SPY,Hour,TradeBar,Trade,Adjusted,OpenInterest,Internal
20220712 10:21:40.548 TRACE:: Synchronizer.GetEnumerator(): Exited thread.
20220712 10:21:40.548 TRACE:: AlgorithmManager.Run(): Firing On End Of Algorithm...
20220712 10:21:40.551 TRACE:: Engine.Run(): Exiting Algorithm Manager
20220712 10:21:40.556 TRACE:: FileSystemDataFeed.Exit(): Start. Setting cancellation token...
20220712 10:21:40.559 TRACE:: FileSystemDataFeed.Exit(): Exit Finished.
20220712 10:21:40.560 TRACE:: DefaultAlphaHandler.Exit(): Exiting...
20220712 10:21:40.563 TRACE:: Debug: Warning: The following securities were set to raw price normalization mode to work with options: MSFT...
20220712 10:21:40.563 TRACE:: Debug: Algorithm Id:(1211218677) completed in 1.15 seconds at 0k data points per second. Processing total of 408 data points.
20220712 10:21:40.565 TRACE:: DefaultAlphaHandler.Exit(): Ended
20220712 10:21:40.565 TRACE:: BacktestingResultHandler.Exit(): starting...
20220712 10:21:40.566 TRACE:: BacktestingResultHandler.Exit(): Saving logs...
20220712 10:21:40.571 TRACE:: Debug: Your log was successfully created and can be retrieved from: /Results/1211218677-log.txt
20220712 10:21:40.571 TRACE:: StopSafely(): waiting for 'Result Thread' thread to stop...
20220712 10:21:40.572 TRACE:: BacktestingResultHandler.Run(): Ending Thread...
20220712 10:21:40.720 TRACE::
STATISTICS:: Total Trades 0
STATISTICS:: Average Win 0%
STATISTICS:: Average Loss 0%
STATISTICS:: Compounding Annual Return 0%
STATISTICS:: Drawdown 0%
STATISTICS:: Expectancy 0
STATISTICS:: Net Profit 0%
STATISTICS:: Sharpe Ratio 0
STATISTICS:: Probabilistic Sharpe Ratio 0%
STATISTICS:: Loss Rate 0%
STATISTICS:: Win Rate 0%
STATISTICS:: Profit-Loss Ratio 0
STATISTICS:: Alpha 0
STATISTICS:: Beta 0
STATISTICS:: Annual Standard Deviation 0
STATISTICS:: Annual Variance 0
STATISTICS:: Information Ratio 1.556
STATISTICS:: Tracking Error 0.204
STATISTICS:: Treynor Ratio 0
STATISTICS:: Total Fees $0.00
STATISTICS:: Estimated Strategy Capacity $0
STATISTICS:: Lowest Capacity Asset
STATISTICS:: Fitness Score 0
STATISTICS:: Kelly Criterion Estimate 0
STATISTICS:: Kelly Criterion Probability Value 0
STATISTICS:: Sortino Ratio 79228162514264337593543950335
STATISTICS:: Return Over Maximum Drawdown 79228162514264337593543950335
STATISTICS:: Portfolio Turnover 0
STATISTICS:: Total Insights Generated 0
STATISTICS:: Total Insights Closed 0
STATISTICS:: Total Insights Analysis Completed 0
STATISTICS:: Long Insight Count 0
STATISTICS:: Short Insight Count 0
STATISTICS:: Long/Short Ratio 100%
STATISTICS:: Estimated Monthly Alpha Value $0
STATISTICS:: Total Accumulated Estimated Alpha Value $0
STATISTICS:: Mean Population Estimated Insight Value $0
STATISTICS:: Mean Population Direction 0%
STATISTICS:: Mean Population Magnitude 0%
STATISTICS:: Rolling Averaged Population Direction 0%
STATISTICS:: Rolling Averaged Population Magnitude 0%
STATISTICS:: OrderListHash d41d8cd98f00b204e9800998ecf8427e
20220712 10:21:40.720 TRACE:: BacktestingResultHandler.SendAnalysisResult(): Processed final packet
20220712 10:21:40.721 TRACE:: Engine.Run(): Disconnecting from brokerage...
20220712 10:21:40.722 TRACE:: Engine.Run(): Disposing of setup handler...
20220712 10:21:40.722 TRACE:: Engine.Main(): Analysis Completed and Results Posted.
Engine.Main(): Analysis Complete.
20220712 10:21:40.724 TRACE:: Engine.Main(): Packet removed from queue: 1211218677
20220712 10:21:40.725 TRACE:: LeanEngineSystemHandlers.Dispose(): start...
20220712 10:21:40.725 TRACE:: LeanEngineSystemHandlers.Dispose(): Disposed of system handlers.
20220712 10:21:40.726 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): start...
20220712 10:21:40.733 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): Disposed of algorithm handlers.
20220712 10:21:40.735 TRACE:: StopSafely(): waiting for 'CpuPerformance' thread to stop...
20220712 10:21:42.938 TRACE:: Program.Main(): Exiting Lean...
Successfully ran 'coveredc' in the 'backtesting' environment and stored the output in 'coveredc\backtests\2022-07-12_15-51-33'
Fred Painchaud
Hi Ninad,
When you backtest locally, you do not have data by default (or very little, see /data in the lean folder you initialized). No data = no trades.
You can pay QC for data, use your own, etc. But the data is only available for free in the cloud.
Fred
Ninad Pethkar
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!