quantconnect / lean-cli Goto Github PK
View Code? Open in Web Editor NEWCLI for running the LEAN engine locally and in the cloud
Home Page: https://www.lean.io/cli
License: Apache License 2.0
CLI for running the LEAN engine locally and in the cloud
Home Page: https://www.lean.io/cli
License: Apache License 2.0
Confused as to why changing the date range of the "My Project" code LEAN CLI gives 0 trades. My code is identical to the LEAN CLI demo except for a different date range and warm up.
from AlgorithmImports import *
class MyProject(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 1, 7) # Set Start Date
self.SetEndDate(2020, 10, 11) # Set End Date
self.SetCash(100000) # Set Strategy Cash
self.AddEquity("SPY", Resolution.Minute)
self.SetWarmUp(360, Resolution.Daily)
def OnData(self, slice):
"""OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
Arguments:
data: Slice object keyed by symbol containing the stock data
"""
if self.IsWarmingUp:
return
if not slice.ContainsKey("SPY"):
return
if not self.Portfolio.Invested:
self.SetHoldings("SPY", 1)
self.Debug("Purchased Stock")
Running the code prints:
$ lean backtest "My Project"
20211105 12:46:58.362 TRACE:: Config.Get(): Configuration key
not found. Key: plugin-directory - Using default value:
20211105 12:46:58.375 TRACE:: Composer(): Loading Assemblies from
/Lean/Launcher/bin/Debug
20211105 12:46:58.476 TRACE:: Python for .NET Assembly:
Python.Runtime, Version=2.0.10.0, Culture=neutral,
PublicKeyToken=5000fea6cba702dd
20211105 12:46:58.559 TRACE:: Config.Get(): Configuration key not
found. Key: data-directory - Using default value: ../../../Data/
20211105 12:46:58.566 TRACE:: Config.Get(): Configuration key not
found. Key: version-id - Using default value:
20211105 12:46:58.567 TRACE:: Config.Get(): Configuration key not
found. Key: cache-location - Using default value: /Lean/Data
20211105 12:46:58.569 TRACE:: Engine.Main(): LEAN ALGORITHMIC
TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit) Host: d-macbookpro
20211105 12:46:58.578 TRACE:: Engine.Main(): Started 12:46 PM
20211105 12:46:58.583 TRACE:: Config.Get(): Configuration key not
found. Key: lean-manager-type - Using default value:
LocalLeanManager
20211105 12:46:58.610 TRACE:: JobQueue.NextJob(): Selected
/LeanCLI/main.py
20211105 12:46:58.710 TRACE:: Config.GetValue():
scheduled-event-leaky-bucket-capacity - Using default value: 120
20211105 12:46:58.711 TRACE:: Config.GetValue():
scheduled-event-leaky-bucket-time-interval-minutes - Using default
value: 1440
20211105 12:46:58.712 TRACE:: Config.GetValue():
scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20211105 12:46:58.716 TRACE:: Config.Get(): Configuration key not
found. Key: job-organization-id - Using default value:
20211105 12:46:58.718 TRACE:: Config.Get(): Configuration key not
found. Key: data-permission-manager - Using default value:
DataPermissionManager
20211105 12:46:58.733 TRACE:: AlgorithmManager.CreateTokenBucket():
Initializing LeakyBucket: Capacity: 120 RefillAmount: 18
TimeInterval: 1440
20211105 12:46:58.736 TRACE:: Config.GetValue():
algorithm-manager-time-loop-maximum - Using default value: 20
20211105 12:46:58.755 TRACE::
TextSubscriptionDataSourceReader.SetCacheSize(): Setting cache size
to 71582788 items
20211105 12:46:59.094 TRACE:: Config.GetValue():
algorithm-creation-timeout - Using default value: 90
20211105 12:46:59.100 TRACE:: PythonInitializer.Initialize():
start...
PythonEngine.Initialize(): Runtime.Initialize()...
Runtime.Initialize(): Py_Initialize...
Runtime.Initialize(): PyEval_InitThreads...
Runtime.Initialize(): Initialize types...
Runtime.Initialize(): Initialize types end.
Runtime.Initialize(): AssemblyManager.Initialize()...
Runtime.Initialize(): AssemblyManager.UpdatePath()...
PythonEngine.Initialize(): GetCLRModule()...
PythonEngine.Initialize(): clr GetManifestResourceStream...
20211105 12:47:00.137 TRACE:: PythonInitializer.Initialize(): ended
20211105 12:47:00.143 TRACE:: AlgorithmPythonWrapper(): Python
version 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:25:33)
[GCC 7.3.0]: Importing python module main
20211105 12:47:02.757 TRACE:: AlgorithmPythonWrapper(): main
successfully imported.
20211105 12:47:02.768 TRACE:: AlgorithmPythonWrapper(): Creating
IAlgorithm instance.
20211105 12:47:02.778 TRACE:: Config.GetValue():
api-data-update-period - Using default value: 1
20211105 12:47:02.933 TRACE:: Config.GetValue():
mute-python-library-logging - Using default value: True
20211105 12:47:02.966 TRACE:: LocalObjectStore.Initialize(): Storage
Root: /Storage/QCAlgorithm. StorageFileCount 100. StorageLimitMB 5
20211105 12:47:02.986 TRACE:: BacktestingSetupHandler.Setup():
Setting up job: Plan: Free, UID: 79669, PID: 949503058, Version:
2.5.0.0, Source: WebIDE
20211105 12:47:02.993 TRACE:: Config.Get(): Configuration key not
found. Key: security-data-feeds - Using default value:
20211105 12:47:03.170 TRACE::
BaseSetupHandler.SetupCurrencyConversions():
Symbol Quantity Conversion = Value in USD
USD: $ 100000.00 @ 1.00 = $100000.0
-------------------------------------------------
CashBook Total Value: $100000.0
20211105 12:47:03.177 TRACE:: SetUp Backtesting: User: 79669
ProjectId: 949503058 AlgoId: 1958612602
20211105 12:47:03.179 TRACE:: Dates: Start: 01/07/2020 End:
10/11/2020 Cash: ¤100,000.00
20211105 12:47:03.182 TRACE:: BacktestingResultHandler(): Sample
Period Set: 100.44
20211105 12:47:03.184 TRACE:: Time.TradeableDates(): Security Count:
1
20211105 12:47:03.188 TRACE:: Config.GetValue():
forward-console-messages - Using default value: True
20211105 12:47:03.191 TRACE:: JOB HANDLERS:
20211105 12:47:03.192 TRACE:: DataFeed:
QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed
20211105 12:47:03.193 TRACE:: Setup:
QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler
20211105 12:47:03.196 TRACE:: RealTime:
QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
20211105 12:47:03.197 TRACE:: Results:
QuantConnect.Lean.Engine.Results.BacktestingResultHandler
20211105 12:47:03.198 TRACE:: Transactions: QuantConnect.Le
an.Engine.TransactionHandlers.BacktestingTransactionHandler
20211105 12:47:03.199 TRACE:: Alpha:
QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20211105 12:47:03.200 TRACE:: ObjectStore:
QuantConnect.Lean.Engine.Storage.LocalObjectStore
20211105 12:47:03.201 TRACE:: History Provider: QuantCo
nnect.Lean.Engine.HistoricalData.SubscriptionDataReaderHistoryProvid
er
20211105 12:47:03.225 TRACE:: Debug: Launching analysis for
1958612602 with LEAN Engine v2.5.0.0
20211105 12:47:03.237 TRACE:: Event Name "Daily Sampling", scheduled
to run at 1/7/2020 5:00:00 AM (UTC)...
20211105 12:47:03.237 TRACE:: AlgorithmManager.Run(): Begin
DataStream - Start: 1/7/2020 12:00:00 AM Stop: 10/11/2020 11:59:59
PM
20211105 12:47:03.259 TRACE:: AlgorithmManager.Stream():
WarmupHistoryRequest: SPY: Start: 8/1/2018 4:00:00 AM End: 1/7/2020
5:00:00 AM Resolution: Daily
20211105 12:47:03.299 TRACE:: Config.GetValue():
data-feed-max-work-weight - Using default value: 400
20211105 12:47:03.300 TRACE:: Config.GetValue():
data-feed-workers-count - Using default value: 4
20211105 12:47:03.302 TRACE:: WeightedWorkScheduler(): will use 4
workers and MaxWorkWeight is 400
20211105 12:47:03.325 TRACE:: Config.GetValue():
show-missing-data-logs - Using default value: False
20211105 12:47:03.628 TRACE:: AlgorithmManager.Stream(): Finished
warmup
20211105 12:47:03.628 TRACE:: Debug: Algorithm warming up...
20211105 12:47:03.914 TRACE::
UniverseSelection.AddPendingInternalDataFeeds(): Adding internal
benchmark data feed SPY,SPY,Hour,TradeBar,Trade,Adjusted,Internal
20211105 12:47:04.083 TRACE:: Debug: Algorithm finished warming up.
20211105 12:47:04.185 TRACE:: Debug: Purchased Stock
20211105 12:47:04.202 TRACE:: Synchronizer.GetEnumerator(): Exited
thread.
20211105 12:47:04.203 TRACE:: AlgorithmManager.Run(): Firing On End
Of Algorithm...
20211105 12:47:04.207 TRACE:: Engine.Run(): Exiting Algorithm
Manager
20211105 12:47:04.211 TRACE:: FileSystemDataFeed.Exit(): Start.
Setting cancellation token...
20211105 12:47:04.216 TRACE:: FileSystemDataFeed.Exit(): Exit
Finished.
20211105 12:47:04.218 TRACE:: DefaultAlphaHandler.Exit(): Exiting...
20211105 12:47:04.226 TRACE:: DefaultAlphaHandler.Exit(): Ended
20211105 12:47:04.227 TRACE:: BacktestingResultHandler.Exit():
starting...
20211105 12:47:04.228 TRACE:: BacktestingResultHandler.Exit():
Saving logs...
20211105 12:47:04.236 TRACE:: Debug: Algorithm Id:(1958612602)
completed in 1.01 seconds at 2k data points per second. Processing
total of 2,082 data points.
20211105 12:47:04.236 TRACE:: StopSafely(): waiting for 'Result
Thread' thread to stop...
20211105 12:47:04.236 TRACE:: Debug: Your log was successfully
created and can be retrieved from: /Results/1958612602-log.txt
20211105 12:47:04.237 TRACE:: BacktestingResultHandler.Run(): Ending
Thread...
20211105 12:47:04.487 TRACE:: Config.GetValue():
regression-update-statistics - Using default value: False
20211105 12:47:04.490 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 -0.42
STATISTICS:: Tracking Error 0.312
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 b7c0987ac8efab0b63bbb8254a8b28c5
20211105 12:47:04.492 TRACE::
BacktestingResultHandler.SendAnalysisResult(): Processed final
packet
20211105 12:47:04.494 TRACE:: Engine.Run(): Disconnecting from
brokerage...
20211105 12:47:04.496 TRACE:: Engine.Run(): Disposing of setup
handler...
20211105 12:47:04.498 TRACE:: Engine.Main(): Analysis Completed and
Results Posted.
Engine.Main(): Analysis Complete.
20211105 12:47:04.501 TRACE:: Engine.Main(): Packet removed from
queue: 1958612602
20211105 12:47:04.502 TRACE:: LeanEngineSystemHandlers.Dispose():
start...
20211105 12:47:04.504 TRACE:: LeanEngineSystemHandlers.Dispose():
Disposed of system handlers.
20211105 12:47:04.506 TRACE:: LeanEngineAlgorithmHandlers.Dispose():
start...
20211105 12:47:04.512 TRACE:: LeanEngineAlgorithmHandlers.Dispose():
Disposed of algorithm handlers.
20211105 12:47:04.515 TRACE:: Program.Main(): Exiting Lean...
Successfully ran 'My Project' in the 'backtesting' environment and
stored the output in 'My Project/backtests/2021-11-05_20-46-56'
Currently the system of checking for "Security Master" subscription only considers "Equity Security Master". However, different datasource require different "Security Master" products.
In example:
Bulk US Equity Data -> Bulk US Equity Security Master (PID 180)
US Equity Data -> US Equity Security Master (PID 37)
Bulk US Futures Data -> Bulk US Futures Security Master (PID 179)
US Futures Data -> US Futures Security Master (PID 137)
I believe this can be addressed by a two step change. One to the API and then the CLI reflecting.
SOLUTION:
The web api response for "data/prices" under "datasources" has a field "requiresSecurityMaster" which is a simple true/false. Instead I suggest we make this a requires
field as an int[] that contains the required products if any for that Product id.
EX Before
"datasources": {
"4": {
"requiresSecurityMaster": true,
"options": [],
"paths": []
}
}
EX after
"datasources": {
"4": {
"requires": [ 37 ],
"options": [],
"paths": []
}
}
That way in the CLI when we want to check if a product can be downloaded we can just ensure that the required product ID exists in the organization subscriptions.
This also allows us to not have to hardcode any security master product ID in the CLI as it is now.
Making docker run without sudo is a security risk - you're essentially granting root permissions to the user account.
Rootless docker installations can't do folder sharing (which I think is used by lean)
lean can't be installed in a way that sudo can find it, AFAICT.
sudo lean
can't find lean
sudo conda
can't find conda
Is there a reasonable workaround for lean data generate
to work with a typical docker installation?
Hi,
I'm currently testing out the Lean CLI for my firm. Unfortunately I'm stuck at the very beginning:
I'm sure it has something to do with our IT team blocking every possible port we can think of. Is there a workaround on your end, otherwise I'm going to have to wait weeks before an internal ticket gets approved.
I went in the init.py file -> _download_repository function -> line 37 and added verify = False to the get method. I get a warning and nothing :
Thanks for your help,
Nicolas Voisin
I'd like to be able to download logs of either cloud backtesting or cloud live algorithm running. I haven't found any examples/hints if it is possible now, thus please consider this issue as a feature request, if it is the case indeed. I.e., if one could run
lean cloud logs [--live|--backtest] --project MyProject [--name RunName]
it would be awesome.
This allows a person who creates a project to be 95% of the way to running the generated jupyter notebooks. The data-folder just needs to be changed to the folder where lean init was run.
Notebook cells arranged for showing of logs in case of error
Hi, after I upgraded Lean CLI to the latest version (1.0.36) I'm having some issues that I could reproduce with the following steps:
> lean create-project MyProject/MyAlgo
> lean backtest MyProject/MyAlgo
> devenv ./MyProject/MyAlgo/MyAlgo.csproj
Then select "File"->"Save All". It will show the dialog to save the solution file. Save the solution file as: MyProject/MyProject.sln
> lean backtest MyProject/MyAlgo
Error: 500 Server Error for
http+docker://localnpipe/v1.41/containers/2b1e943a08d2c169ff9731c202eaeab03e40fe8a7759d3641002ecfd6786185f/start:
Internal Server Error ("OCI runtime create failed: container_linux.go:380: starting container process caused:
process_linux.go:545: container init caused: rootfs_linux.go:76: mounting
"/run/desktop/mnt/host/c/Users/dvp/AppData/Local/Temp/lean-cli-2e8ke7tc/MyAlgo/MyAlgo.csproj" to rootfs at
"/LeanCLI/MyAlgo\\MyAlgo.csproj" caused: open /var/lib/docker/overlay2/6f125dc13c510204bf0181082b735079b0445f61185984f48
ea9e7e360e87eb5/merged/LeanCLI/MyAlgo\MyAlgo.csproj: read-only file system: unknown")
> rm ./MyProject/MyProject.sln
> lean backtest MyProject/MyAlgo
When starting the lean init command (Python 3.9.7) it fails to start if tkinter is not setup. Following the trace back, tkinter is a dependency of the 'gui' command. Since lean the lean init command isn't starting a gui, it shouldn't require tk.
A hack workaround is to remove the dependency on command/gui from lean/commands/init.py. The "lean init" command will startup fine after that change.
# avoid tkinter import from lean.commands.gui import gui
...
# avoid tkinter import lean.add_command(gui)
Command Output:
'lean.json' not found
Traceback (most recent call last):
File "/usr/local/bin/lean", line 5, in <module>
from lean.main import main
File "/usr/local/lib/python3.9/site-packages/lean/main.py", line 95, in <module>
from lean.commands import lean
File "/usr/local/lib/python3.9/site-packages/lean/commands/__init__.py", line 23, in <module>
from lean.commands.gui import gui
File "/usr/local/lib/python3.9/site-packages/lean/commands/gui/__init__.py", line 18, in <module>
from lean.commands.gui.start import start
File "/usr/local/lib/python3.9/site-packages/lean/commands/gui/start.py", line 18, in <module>
import tkinter
File "/usr/local/Cellar/[email protected]/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'```
(base) PS C:\Users\Alex\Local> lean cloud backtest "RiskAverse2" --push --open
[1/1] Pushing 'RiskAverse2'
Successfully updated cloud file 'RiskAverse/main.py'
Started compiling project 'RiskAverse'
Detected parameters: none
Build Request Successful for Project ID: 10244769, with CompileID:
053f5b0cdd39550264ff5d8cc8724370-08219cfbd61c7f9e413b570308392826, Lean Version: 2.5.0.0.13520
Successfully compiled project 'RiskAverse'
Started backtest named 'Geeky Orange Snake' for project 'RiskAverse'
Backtest url: https://www.quantconnect.com/terminal/#open/10244769/922781a33f82d756c2fa67aa3b6597ab
---------------------------------------- 0%
Backtest id: 922781a33f82d756c2fa67aa3b6597ab
Backtest name: Geeky Orange Snake
Backtest url: https://www.quantconnect.com/terminal/#open/10244769/922781a33f82d756c2fa67aa3b6597ab
The https://www.quantconnect.com/terminal/#open/10244769/922781a33f82d756c2fa67aa3b6597ab doesn't open the backtest tab.. It opens that Terminal page instead.
Below is the verbose output I am getting when I try to run the lean local backtest command.
Can you let me know what I'm doing wrong?
Thanks.
(base) chadwick@chadwick-Satellite-S70-B:~/Desktop/QuantConnect_Lean$ lean backtest --verbose "My Project"
Traceback (most recent call last):
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/client.py", line 268, in _raise_for_status
response.raise_for_status()
File "/home/chadwick/.local/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http+docker://localhost/v1.40/containers/create
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/main.py", line 30, in main
lean.main(standalone_mode=False)
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/click.py", line 68, in invoke
result = super().invoke(ctx)
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/commands/backtest.py", line 79, in backtest
lean_runner.run_lean("backtesting", algorithm_file, output, version, debugging_method)
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/components/docker/lean_runner.py", line 90, in run_lean
success = self._docker_manager.run_image(ENGINE_IMAGE, version, **run_options)
File "/home/chadwick/anaconda3/lib/python3.8/site-packages/lean/components/docker/docker_manager.py", line 77, in run_image
container = docker_client.containers.run(f"{image}:{tag}", None, **kwargs)
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/models/containers.py", line 811, in run
container = self.create(image=image, command=command,
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/models/containers.py", line 870, in create
resp = self.client.api.create_container(**create_kwargs)
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/container.py", line 430, in create_container
return self.create_container_from_config(config, name)
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/container.py", line 441, in create_container_from_config
return self._result(res, True)
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/client.py", line 274, in _result
self._raise_for_status(response)
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/api/client.py", line 270, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/home/chadwick/.local/lib/python3.8/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 400 Client Error for http+docker://localhost/v1.40/containers/create: Bad Request ("invalid mount config for
type "bind": bind source path does not exist: /tmp/tmpp_7xwf_a/config.json")
Error: 400 Client Error for http+docker://localhost/v1.40/containers/create: Bad Request ("invalid mount config for type "bind":
bind source path does not exist: /tmp/tmpp_7xwf_a/config.json")
With reference to this community post
Since GPUs in local machines are not utilized in LEAN CLI, the support for extra computational power by GPUs for machine learning in the research environment is requested.
I am trying to debug locally using VS 2019.
`C:\LeanCLi> lean backtest "First" --debug vsdbg
Microsoft (R) Build Engine version 16.10.1+2fd48ab73 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored /LeanCLI/First.csproj (in 60 ms).
First -> /Compile/bin/First.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.30
20210720 11:15:37.878 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20210720 11:15:37.888 TRACE:: Composer(): Loading Assemblies from /Lean/Launcher/bin/Debug
20210720 11:15:37.906 TRACE:: Python for .NET Assembly: QuantConnect.DataSource.ExamplePythonScriptMyCustomDataTypeDoNotUse,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
20210720 11:15:37.950 TRACE:: Python for .NET Assembly: Python.Runtime, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=5000fea6cba702dd
20210720 11:15:37.985 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value:
../../../Data/
20210720 11:15:37.988 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20210720 11:15:37.989 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: /Lean/Data
20210720 11:15:37.990 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit) Host: ROL0003
20210720 11:15:37.994 TRACE:: Engine.Main(): Started 11:15 AM
20210720 11:15:37.997 TRACE:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value:
LocalLeanManager
20210720 11:15:38.014 TRACE:: JobQueue.NextJob(): Selected First.dll
20210720 11:15:38.076 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
20210720 11:15:38.076 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440
20210720 11:15:38.077 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20210720 11:15:38.077 TRACE:: Config.Get(): Configuration key not found. Key: algorithm-id - Using default value: First
20210720 11:15:38.078 TRACE:: Config.Get(): Configuration key not found. Key: job-organization-id - Using default value:
20210720 11:15:38.078 TRACE:: Config.GetValue(): job-project-id - Using default value: 0
20210720 11:15:38.080 TRACE:: Config.Get(): Configuration key not found. Key: data-permission-manager - Using default value:
DataPermissionManager
20210720 11:15:38.091 TRACE:: AlgorithmManager.CreateTokenBucket(): Initializing LeakyBucket: Capacity: 120 RefillAmount: 18
TimeInterval: 1440
20210720 11:15:38.093 TRACE:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20
20210720 11:15:38.105 TRACE:: TextSubscriptionDataSourceReader.SetCacheSize(): Setting cache size to 71582788 items
20210720 11:15:38.371 TRACE:: DebuggerHelper.Initialize(): waiting for debugger to attach...`
But when trying to attach to the docker container process with id 1 I keep receiving:
Initialization log:
Determining user folder on remote system...
Checking for existing installation of debugging tools...
Downloading debugger launcher...
Creating debugger installation folder: /root/.vs-debugger
Copying debugger launcher to /root/.vs-debugger/GetVsDbg.sh
Failed: Failed to copy files.
Unable to find debugger script at '/root/.vs-debugger'.
Failed: Unable to find debugger script at '/root/.vs-debugger'.
The program '[1] dotnet' has exited with code -1 (0xffffffff).
Is this environment issue or it's related to lean?
Thanks.
lean data generate --start=20210315 --symbol-count=1
lean data generate --start=20210315 --symbol-count=1
lean data generate --start=20210315 --symbol-count=1
20210331 04:59:42.337 TRACE:: Config.GetValue(): debug-mode - Using default value: False
20210331 04:59:42.338 TRACE:: Config.Get(): Configuration key not found. Key: results-destination-folder - Using default value:
20210331 04:59:42.339 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20210331 04:59:42.343 TRACE:: Config.Get(): Configuration key not found. Key: composer-dll-directory - Using default value: /Lean/Launcher/bin/Debug/
'market' was not specified. Using default value: ''
'quote-trade-ratio' was not specified. Using default value: '1'
'random-seed' was not specified. Using default value: ''
'ipo-percentage' was not specified. Using default value: '5.0'
'rename-percentage' was not specified. Using default value: '30.0'
'splits-percentage' was not specified. Using default value: '15.0'
'dividends-percentage' was not specified. Using default value: '60.0'
'dividend-every-quarter-percentage' was not specified. Using default value: '30.0'
Using default value of 'usa' for --market and --security-type=Equity
Selected tick types for Equity: Trade
20210331 04:59:42.605 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20210331 04:59:42.607 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20210331 04:59:42.607 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: ../../../Data/
Begin data generation of 1 randomly generated Equity assets...
Symbol[1]: SSE 2T Progress: 0.0% - Generating data...
Symbol[1]: SSE 2T Dividends, splits, and map files have been written to disk.
Symbol[1]: Month: March
Symbol[1]: SSE 2T Progress: 50.0% - Saving data in LEAN format
20210331 04:59:43.445 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210315_trade.zip
20210331 04:59:43.494 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210316_trade.zip
20210331 04:59:43.545 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210317_trade.zip
20210331 04:59:43.621 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210318_trade.zip
20210331 04:59:43.672 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210319_trade.zip
20210331 04:59:43.722 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210322_trade.zip
20210331 04:59:43.773 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210323_trade.zip
20210331 04:59:43.829 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210324_trade.zip
20210331 04:59:43.878 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210325_trade.zip
20210331 04:59:43.928 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210326_trade.zip
20210331 04:59:43.977 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210329_trade.zip
20210331 04:59:44.036 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/sse/20210330_trade.zip
20210331 04:59:44.096 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/daily/sse.zip
Symbol[1]: SSE 2T Progress: 100.0% - Symbol data generation and output completed
Random data generation has completed.
Launching coarse data generator...
20210331 04:59:44.100 TRACE:: Config.Get(): Configuration key not found. Key: reserved-words-prefix - Using default value: quantconnect-
20210331 04:59:44.108 TRACE:: CoarseUniverseGeneratorProgram.ProcessDailyFolder(): Processing: /Lean/Data/equity/usa/daily
20210331 04:59:44.220 TRACE:: CoarseUniverseGeneratorProgram.PopulateSidContex(): Generating SID context from QuantQuote's map files.
20210331 04:59:44.277 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/pry.zip not found!
20210331 04:59:44.277 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/dgf.zip not found!
20210331 04:59:44.340 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/wnq.zip not found!
20210331 04:59:44.354 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/npo.zip not found!
20210331 04:59:44.355 TRACE:: FactorFile.HasScalingFactors(): Factor file not found: GOOAV
20210331 04:59:44.375 TRACE:: FactorFile.HasScalingFactors(): Factor file not found: VXX
20210331 04:59:44.375 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/vxxb.zip not found!
20210331 04:59:44.376 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/vxx.zip not found!
20210331 04:59:44.376 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker VXX not found!
20210331 04:59:44.376 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker VXXB not found!
20210331 04:59:44.388 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/vxx.zip not found!
20210331 04:59:44.388 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker VXX not found!
20210331 04:59:44.406 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/asg.zip not found!
20210331 04:59:44.494 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/aol.zip not found!
20210331 04:59:44.495 ERROR:: CoarseUniverseGeneratorProgram.Run(): /Lean/Data/equity/usa/daily/twx.zip not found!
20210331 04:59:44.495 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker TWX not found!
20210331 04:59:44.495 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker AOL not found!
20210331 04:59:44.508 TRACE:: FactorFile.HasScalingFactors(): Factor file not found: FB.1
20210331 05:00:53.595 ERROR:: CoarseUniverseGeneratorProgram.Run(): CoarseUniverseGeneratorProgram.Run(): FAILED! System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Sequence contains no
elements
at System.Linq.Enumerable.Last[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00010] in <92922d9bda2f4e1cba9242d052be6d43>:0
at QuantConnect.ToolBox.CoarseUniverseGenerator.CoarseUniverseGeneratorProgram+<PopulateSidContex>d__12.MoveNext () [0x00062] in <5fac3c9a18e44332bdae2a2dbf9cae7f>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionerForIEnumerable`1+InternalPartitionEnumerable[TSource].GrabChunk_Buffered (System.Collections.Generic.KeyValuePair`2[System.Int64,TSource][] destArray, System.Int32
requestedChunkSize, System.Int32& actualNumElementsGrabbed) [0x001c7] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionerForIEnumerable`1+InternalPartitionEnumerable[TSource].GrabChunk (System.Collections.Generic.KeyValuePair`2[System.Int64,TSource][] destArray, System.Int32
requestedChunkSize, System.Int32& actualNumElementsGrabbed) [0x00026] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionerForIEnumerable`1+InternalPartitionEnumerator[TSource].GrabNextChunk (System.Int32 requestedChunkSize) [0x00023] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionEnumerator_Abstract`2[TSource,TSourceReader].MoveNext () [0x000ba] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Parallel+<>c__DisplayClass42_0`2[TSource,TLocal].<PartitionerForEachWorker>b__1 () [0x00287] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task.InnerInvokeWithArg (System.Threading.Tasks.Task childTask) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task+<>c__DisplayClass178_0.<ExecuteSelfReplicating>b__0 (System.Object <p0>) [0x00086] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task.Wait () [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal] (System.Collections.Concurrent.Partitioner`1[TSource] source, System.Threading.Tasks.ParallelOptions parallelOptions, System.Action`1[T] simpleBody,
System.Action`2[T1,T2] bodyWithState, System.Action`3[T1,T2,T3] bodyWithStateAndIndex, System.Func`4[T1,T2,T3,TResult] bodyWithStateAndLocal, System.Func`5[T1,T2,T3,T4,TResult] bodyWithEverything, System.Func`1[TResult] localInit,
System.Action`1[T] localFinally) [0x001fb] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal] (System.Collections.Generic.IEnumerable`1[T] source, System.Threading.Tasks.ParallelOptions parallelOptions, System.Action`1[T] body, System.Action`2[T1,T2]
bodyWithState, System.Action`3[T1,T2,T3] bodyWithStateAndIndex, System.Func`4[T1,T2,T3,TResult] bodyWithStateAndLocal, System.Func`5[T1,T2,T3,T4,TResult] bodyWithEverything, System.Func`1[TResult] localInit, System.Action`1[T]
localFinally) [0x0005e] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Parallel.ForEach[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Threading.Tasks.ParallelOptions parallelOptions, System.Action`1[T] body) [0x0002a] in
<b0e1ad7573a24fd5a9f2af9595e677e7>:0
at QuantConnect.ToolBox.CoarseUniverseGenerator.CoarseUniverseGeneratorProgram.Run () [0x0013b] in <5fac3c9a18e44332bdae2a2dbf9cae7f>:0
---> (Inner Exception #0) System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Last[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00010] in <92922d9bda2f4e1cba9242d052be6d43>:0
at QuantConnect.ToolBox.CoarseUniverseGenerator.CoarseUniverseGeneratorProgram+<PopulateSidContex>d__12.MoveNext () [0x00062] in <5fac3c9a18e44332bdae2a2dbf9cae7f>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionerForIEnumerable`1+InternalPartitionEnumerable[TSource].GrabChunk_Buffered (System.Collections.Generic.KeyValuePair`2[System.Int64,TSource][] destArray, System.Int32
requestedChunkSize, System.Int32& actualNumElementsGrabbed) [0x001c7] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionerForIEnumerable`1+InternalPartitionEnumerable[TSource].GrabChunk (System.Collections.Generic.KeyValuePair`2[System.Int64,TSource][] destArray, System.Int32
requestedChunkSize, System.Int32& actualNumElementsGrabbed) [0x00026] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionerForIEnumerable`1+InternalPartitionEnumerator[TSource].GrabNextChunk (System.Int32 requestedChunkSize) [0x00023] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Collections.Concurrent.Partitioner+DynamicPartitionEnumerator_Abstract`2[TSource,TSourceReader].MoveNext () [0x000ba] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Parallel+<>c__DisplayClass42_0`2[TSource,TLocal].<PartitionerForEachWorker>b__1 () [0x00287] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task.InnerInvokeWithArg (System.Threading.Tasks.Task childTask) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.Threading.Tasks.Task+<>c__DisplayClass178_0.<ExecuteSelfReplicating>b__0 (System.Object <p0>) [0x00086] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0 <---
Windows:
[System.Environment]::OSversion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 19042 0
Python:
python --version
Python 3.8.5
Lean:
lean --version
lean, version 0.1.28
master
branchI'm trying to visualize my Keras/TF model in the research environment but I receive an error:
'You must install pydot (
pip install pydot
) and install graphviz (see instructions at https://graphviz.gitlab.io/download/) ', 'for plot_model/model_to_dot to work.'
I've tried following these solutions, specifically installing pydot, pydotplus and graphviz via pip. I suspect the graphviz library would need to be installed at the os-level (via apt-get for example).
A basic reproducible error would be:
from tensorflow.keras.utils import plot_model
plot_model(model, show_shapes=True, dpi=72)
When deploying with the Atreyu brokerage on QuantConnect.com, we can set an existing cash and holdings state. The process is documented here. When deploying with the CLI, we are not prompted to set an existing cash and holdings state.
Sets the value for the following key in lean.json
"transaction-log": "",
in order to create the csv file with the orders generated during the algorithm runtime.
Hi, I am test a simple dual average strategy.
Here is the code, it scan 5000 stocks.
'import time
class MyFirstProject(QCAlgorithm):
def Initialize(self):
self.T = time.time()
self.SetStartDate(2002, 6, 1) # Set Start Date
self.SetEndDate(2016, 2, 8) # Set End Date 2016, 2, 8
self.SetCash(100000000) # Set Strategy Cash
self.stock = []
for i in range(1,5001):
self.stock.append(f"AAA{i}")
self.Fast={}
self.Slow={}
for s in self.stock:
symbol = self.AddEquity(s, Resolution.Daily).Symbol
self.Fast[s] = self.SMA(symbol,5,Resolution.Daily)
self.Slow[s] = self.SMA(symbol,10,Resolution.Daily)
self.i=0
self.targetpositionpct = 1 / len(self.stock) -0.0001/100
self.Tolerance = 0.00015
def OnData(self, data):
self.i+=1
if self.i<20: return
traderBars = data.Bars
for s in self.stock:
holdings = self.Portfolio[s].Quantity
if holdings<=0:
if self.Fast[s].Current.Value>self.Slow[s].Current.Value*(1+self.Tolerance):
self.SetHoldings(s, self.targetpositionpct)
else:
if self.Fast[s]<self.Slow[s]:
self.Liquidate()
bar = traderBars[s]
self.Log(f"holding {holdings} stock {s} bar info, open {round(bar.Open,2)}, volume {bar.Volume}, bar Endtime {bar.EndTime}, 'time used seconds', {time.time()-self.T}")`
When runing, it stoped every 1 minutes, waiting anothet 1 minutes, then continues. Each time it stops, it says:
TRACE:: Isolator.ExecuteWithTimeLimit(): Used: 2305, Sample: 3903, App: 4706, CurrentTimeStepElapsed: 00:32.013.
How to solve it?
This is the log:
`20220214 11:10:17.616 TRACE:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20220214 11:10:17.624 TRACE:: Composer(): Loading Assemblies from /Lean/Launcher/bin/Debug
20220214 11:10:17.671 TRACE:: Python for .NET Assembly: Python.Runtime, Version=2.0.8.0, Culture=neutral, PublicKeyToken=5000fea6cba702dd
20220214 11:10:17.692 TRACE:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20220214 11:10:17.695 TRACE:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20220214 11:10:17.695 TRACE:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: /Lean/Data
20220214 11:10:17.695 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.5.0.0 Mode: DEBUG (64bit) Host: BF-202009261209
20220214 11:10:17.698 TRACE:: Engine.Main(): Started 11:10 AM
20220214 11:10:17.700 TRACE:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager
20220214 11:10:17.714 TRACE:: JobQueue.NextJob(): Selected /LeanCLI/main.py
20220214 11:10:17.764 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-capacity - Using default value: 120
20220214 11:10:17.765 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440
20220214 11:10:17.765 TRACE:: Config.GetValue(): scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20220214 11:10:17.767 TRACE:: Config.Get(): Configuration key not found. Key: job-organization-id - Using default value:
20220214 11:10:17.768 TRACE:: Config.Get(): Configuration key not found. Key: data-permission-manager - Using default value: DataPermissionManager
20220214 11:10:17.781 TRACE:: AlgorithmManager.CreateTokenBucket(): Initializing LeakyBucket: Capacity: 120 RefillAmount: 18 TimeInterval: 1440
20220214 11:10:17.782 TRACE:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20
20220214 11:10:17.792 TRACE:: TextSubscriptionDataSourceReader.SetCacheSize(): Setting cache size to 71582788 items
20220214 11:10:18.017 TRACE:: Config.GetValue(): algorithm-creation-timeout - Using default value: 90
20220214 11:10:18.021 TRACE:: PythonInitializer.Initialize(): start...
PythonEngine.Initialize(): Runtime.Initialize()...
Runtime.Initialize(): Py_Initialize...
Runtime.Initialize(): PyEval_InitThreads...
Runtime.Initialize(): Initialize types...
Runtime.Initialize(): Initialize types end.
Runtime.Initialize(): AssemblyManager.Initialize()...
Runtime.Initialize(): AssemblyManager.UpdatePath()...
PythonEngine.Initialize(): GetCLRModule()...
PythonEngine.Initialize(): clr GetManifestResourceStream...
20220214 11:10:18.824 TRACE:: PythonInitializer.Initialize(): ended
20220214 11:10:18.827 TRACE:: AlgorithmPythonWrapper(): Python version 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:25:33)
[GCC 7.3.0]: Importing python module main
20220214 11:10:20.345 TRACE:: AlgorithmPythonWrapper(): main successfully imported.
20220214 11:10:20.370 TRACE:: AlgorithmPythonWrapper(): Creating IAlgorithm instance.
20220214 11:10:20.376 TRACE:: Config.GetValue(): api-data-update-period - Using default value: 1
20220214 11:10:20.384 TRACE:: SecurityDefinitionSymbolResolver(): No security definitions data loaded from file: /Lean/Data/symbol-properties/security-database.csv
20220214 11:10:20.489 TRACE:: Config.GetValue(): mute-python-library-logging - Using default value: True
20220214 11:10:20.501 TRACE:: LocalObjectStore.Initialize(): Storage Root: /Storage/QCAlgorithm. StorageFileCount 100. StorageLimitMB 5
20220214 11:10:20.513 TRACE:: BacktestingSetupHandler.Setup(): Setting up job: Plan: Free, UID: 0, PID: 384237878, Version: 2.5.0.0, Source: WebIDE
20220214 11:10:20.517 TRACE:: Config.Get(): Configuration key not found. Key: security-data-feeds - Using default value:
......
holding 0.0 stock AAA4990 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.728204011917114
holding 0.0 stock AAA4991 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.72913837432861
holding 0.0 stock AAA4992 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.730098485946655
holding 0.0 stock AAA4993 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.731056213378906
holding 0.0 stock AAA4994 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.731996297836304
holding 0.0 stock AAA4995 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.73293852806091
holding 0.0 stock AAA4996 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.73388195037842
holding 0.0 stock AAA4997 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.73484182357788
holding 0.0 stock AAA4998 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.73577094078064
holding 0.0 stock AAA4999 bar info, open 49.56, volume 1800.0, bar Endtime 2002-06-28 00:00:00, 'time used seconds', 39.73671269416809
20220214 11:21:01.973 TRACE:: Isolator.ExecuteWithTimeLimit(): Used: 2305, Sample: 3903, App: 4706, CurrentTimeStepElapsed: 00:32.013`
When I run a very simple strategy optimization in the lean gui, no charts, job status, or results are updated in the gui.
The strategy under test is a simple ema crossover, and the parameter configuration results in only 3 backtests run. When the same job is run through the CLI, it completes successfully in under 30 seconds.
When I configure and run a local optimization from the lean gui, I expect to see the optimization results displayed in the gui in the same way as they are displayed on quantconnect.com.
Expected screenshot of the same algorithm and optimization job run on quantconnect.com:
Docker shows the backtest container launch, run, and complete.
GUI:
Seems like a callback isn't happening after the optimize job is launched. I'm guessing a network config issue between the optimize container and the gui container.
lean gui start
Lean v1.0.72
Python 3.9.7
Windows 10 Home 21H1 19043.1415
Docker Desktop 4.3.1 (72247), Engine 20.10.11, Compose 1.29.2, Kubernetes v1.22.4
[x] I have completely filled out this template
[x] I have confirmed that this issue exists on the current master
branch
[x] I have confirmed that this is not a duplicate issue by searching issues
[x] I have provided detailed steps to reproduce the issue
Thanks for building the cli tool. It really reduces the efforts on the shoulders in setting up required environment for doing any backtesting.
I would really like to have a lean log command that retireves the latest log of a backtested result. Similar to how lean report
does the job.
Let me know if this interests you I can work on this small contribution.
When I try to login with the credentials i got from the email and following the steps the login fails. I copy pasted the user id and the even first to notepad to make sure nu extra characters/markup is being copied.
Is this a bug?
It will log in
Throws the following error:
Error: Credentials are invalid
Visit https://www.lean.io/docs/lean-cli/tutorials/authentication#02-Logging-in for more information
master
branchExpected Behavior
Documentation here suggests Forex data (Oanda) can be downloaded from QC Data Library.
Actual Behavior
Fails with error message:
Error: There is no data vendor that sells 'forex/oanda/hour/eurusd.zip'
Reproducing
(Interactive mode)
$ lean data download
$ 1
$ 5
$ 4
$ EURUSD
(Non-interactive mode)
$ lean data download --product "Forex" --organization "MyOrg" --resolution "Hour" --ticker "EURUSD"
System
Lean CLI 1.0.22
In the data folder the lean-CLI has a copy of the SPDB and MHDB get outdated and are not refreshed with the latest version from Lean
For security reasons, I want to deploy my algo in a .NET assembly rather than using a CS code project. Is there any way to do that? Even if I reference the DLL in the project and run it, that should be fine.
Following the Lean CLI install, expected it to work
'lean.json' not found
Traceback (most recent call last):
File "/Users/frankcastellucci/signal/lean-play/env/bin/lean", line 5, in <module>
from lean.main import main
File "/Users/frankcastellucci/signal/lean-play/env/lib/python3.9/site-packages/lean/main.py", line 95, in <module>
from lean.commands import lean
File "/Users/frankcastellucci/signal/lean-play/env/lib/python3.9/site-packages/lean/commands/__init__.py", line 23, in <module>
from lean.commands.gui import gui
File "/Users/frankcastellucci/signal/lean-play/env/lib/python3.9/site-packages/lean/commands/gui/__init__.py", line 18, in <module>
from lean.commands.gui.start import start
File "/Users/frankcastellucci/signal/lean-play/env/lib/python3.9/site-packages/lean/commands/gui/start.py", line 18, in <module>
import tkinter
File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
Just starting out with this, I could only guess without any insight
mkdir lean-play && cd lean-play
python3 -m venv env
source env/bin/activate
pip install lean
lean init
This produces the error above
macos BigSur 11.6.2
python: 3.9.9
master
branchI'm trying to install lean and have come across an issue seemingly related to pywin32.
I initially installed the package simply using pip and my base anaconda3 package, but was getting an install of version 0.1.2. When I specify version 1.0.78, I get the below error...
ERROR: Cannot install lean because these package versions have conflicting dependencies.
The conflict is caused by:
docker 4.4.4 depends on pywin32==227; sys_platform == "win32"
docker 4.4.3 depends on pywin32==227; sys_platform == "win32"
docker 4.4.2 depends on pywin32==227; sys_platform == "win32"
docker 4.4.1 depends on pywin32==227; sys_platform == "win32"
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
This error states that the requirements.txt (or however pip works) requires bersion 227 of pywin32 installed. I've tried pip install pywin32==227, but apparently this version is no longer available.
Can anyone provide help on this?
Hi All
im getting the following error. Seems to be somthing with Docker and read write permissions
PS D:\LeanCLI> lean backtest 'Crypto DonChan' --verbose --> GET https://raw.githubusercontent.com/QuantConnect/lean-cli/master/announcements.json Error response from daemon: error creating temporary lease: write /var/lib/desktop-containerd/daemon/io.containerd.metadata.v1.bolt/meta.db: read-only file system: unknown Traceback (most recent call last): File "d:\python3.6.8\lib\site-packages\lean\main.py", line 96, in main lean.main(standalone_mode=False) File "d:\python3.6.8\lib\site-packages\click\core.py", line 782, in main rv = self.invoke(ctx) return _process_result(sub_ctx.command.invoke(sub_ctx)) File "d:\python3.6.8\lib\site-packages\lean\click.py", line 114, in invoke result = super().invoke(ctx) File "d:\python3.6.8\lib\site-packages\click\core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "d:\python3.6.8\lib\site-packages\click\core.py", line 610, in invoke return callback(*args, **kwargs) File "d:\python3.6.8\lib\site-packages\lean\commands\backtest.py", line 342, in backtest docker_manager.pull_image(engine_image) File "d:\python3.6.8\lib\site-packages\lean\components\docker\docker_manager.py", line 70, in pull_image f"Something went wrong while pulling {image}, see the logs above for more information") RuntimeError: Something went wrong while pulling quantconnect/lean:latest, see the logs above for more information Error: Something went wrong while pulling quantconnect/lean:latest, see the logs above for more information
Consider the following file structure:
+
|- Library
| |- MyLibrary
| |- mylib.py
|- MyProject
|- main.py
In order to make mylib
from MyLibrary
available in main.py
from MyProject
I need to use two different import statements depending on whether i run the code in a local or in a cloud backtest.
Local backtest needs:
from MyLibrary import mylib
Cloud backtest needs:
import mylib
I think this difference comes from the fact that in local backtesting the Library
folder is sourced into the backtest as is. However, in cloud backtesting, QC copies the contents of the referenced libraries into the projects directly. In our case here, mylib.py
would be copied next to main.py
.
When we delete a file locally, it should be removed from the Cloud when lean cloud push
is called.
How to reproduce:
lean cloud push "ProjectName"
lean cloud push "ProjectName"
Hi there,
Is Windows Server Datacenter 2019 supported?
I'm attempting to run lean research
and lean backtest
. But lean is failing to pull both the quantconnect/research and quantconnect/lean images.
When I run lean research .
in a project's directory, I'm getting the output below:
PS C:\Users\wadams19\workspace\QC\live\coin-toss> lean research .
Pulling quantconnect/research:latest...
latest: Pulling from quantconnect/research
no matching manifest for windows/amd64 10.0.17763 in the manifest list entries
Error: Something went wrong while pulling quantconnect/research:latest, see the logs above for more information
Any ideas?
Be able to fetch backtest results from the cloud, e.g.:
lean cloud backtest "My Project" --read "Backtest Name"
Hello, I would like to build an automated process to restart my live algorithm from the CLI weekly to make sure that I am running the most up-to-date version of LEAN.
Starting the algorithm from the CLI is not a problem, however, there is currently no way to stop a running algorithm, or even to force restart the algorithm. If a live node is in use, the only thing that works is to manually go in to the GUI and stop the algorithm running on it. Only then is the node available to deploy to from the CLI.
Is it possible to get this capability as a either a separate CLI API, or even as a "force" parameter to the lean cloud live
API?
Hi,
I've successfully installed lean-cli on windows and the coding, autocompletition and cloud backtesting are working fine.
The problem is when I need to prepare data or run a local backtest. Although my Docker is up and running, I keep receiving the Docker error:
Error: Please make sure Docker is installed and running
When I use the verbose option, it shows:
Traceback (most recent call last):
File "d:\programs\anaconda\envs\fastai\lib\site-packages\docker\api\client.py", line 159, in __init__
self._custom_adapter = NpipeHTTPAdapter(
NameError: name 'NpipeHTTPAdapter' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\programs\anaconda\envs\fastai\lib\site-packages\lean\components\docker\docker_manager.py", line 307, in _get_docker_client
docker_client = docker.from_env()
File "d:\programs\anaconda\envs\fastai\lib\site-packages\docker\client.py", line 101, in from_env
**kwargs_from_env(**kwargs)
File "d:\programs\anaconda\envs\fastai\lib\site-packages\docker\client.py", line 45, in __init__
self.api = APIClient(*args, **kwargs)
File "d:\programs\anaconda\envs\fastai\lib\site-packages\docker\api\client.py", line 165, in __init__
'Install pypiwin32 package to enable npipe:// support'
docker.errors.DockerException: Install pypiwin32 package to enable npipe:// support
Pypwin32 has been installed manually with pip. Tried running other containers and docker seems to be Ok.
No other clue from the internet.
Any ideas?
Thanks
Mauricio
This GitHub Issue is created in Lean-CLI and IBAutomater because it has not been observed in QuantConnect Cloud or locally, only within Digital Ocean environment.
Based on the syslog, it looks like the IBGateway process is still running but not responding, because, after the countdown popups, no other events are received (especially the usual Shutdown/OnExited message, which triggers the restart).
We can see the countdown starting after 2021-09-27T23:41:01.1807775Z:
2021-09-27T23:41:01.1924755Z TRACE:: InteractiveBrokersBrokerage.OnIbAutomaterOutputDataReceived(): Content: Set Auto Restart Time (HH:MM) The application will automatically restart in 4 minutes 30 seconds EXIT SESSION SETTING
After connected to the docker instance about 23.47 UTC, we confirmed that the java process which contains the IBGateway was running. In fact, the memory consumption of that process on top
command was about 35% of the 1GB.
IB Gateway's launcher.log, we can verify that IBGateway did actually restart:
2021-09-29 23:45:22.662 [WR] INFO [JTS-Main] - ------------------------------- IB GATEWAY RESTART --------------------------------
2021-09-29 23:45:22.702 [WR] INFO [JTS-Main] - installer version: 2.82, installer type: standalone, install dir: '/root/ibgateway/', Jts dir: '/root/Jts', VM options file: '/root/ibgateway/ibgateway.vmoptions'
Does it work on a mac?
I set up an example like in this tutorial: https://www.youtube.com/watch?v=yAVjsFdtpEY
but I ended up with an error like this:
20210527 10:31:21.764 ERROR:: Failed to assign conversion rates for the following cash: EUR. Attempting to request daily resolution history to resolve conversion rate
2021-05-27T09:27:12.7093632Z ERROR:: AUSUSD 0 not found in portfolio. Request this data when initializing the algorithm.
So I also downloaded EURUSD, still no joy.
My example was first written/run in the QC cloud, so it wasn't a coding issue I think.
Then I made another example using SPY and the default EMA cross from the QC builder I ended up with this error when run locally:
20210527 09:50:47.300 ERROR:: SPY: The security does not have an accurate price as it has not yet received a bar of data. Before placing a trade (or using SetHoldings) warm up your algorithm with SetWarmup
It seems it doesn't run the same locally as the cloud, at least on a mac
Hi,
Is there a way to update the directory created by lean init
with the latest LEAN repository? Thank you.
when I run the command "pip install lean" (tried it with --user too). I get the following error.
side-note : yes I ran "apt-get install linux-headers-$(uname -r)" and yes I confirmed that the headers were there.
`
Building wheels for collected packages: evdev
Building wheel for evdev (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /root/anaconda3/envs/quant/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/setup.py'"'"'; file='"'"'/tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-zhmty0s0
cwd: /tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/
Complete output (37 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/evdev
copying evdev/device.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/evtest.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/genecodes.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/events.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/eventio.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/uinput.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/ff.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/init.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/util.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/ecodes.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/eventio_async.py -> build/lib.linux-x86_64-3.6/evdev
running build_ext
running build_ecodes
The 'linux/input.h' and 'linux/input-event-codes.h' include files
are missing. You will have to install the kernel header files in
order to continue:
yum install kernel-headers-$(uname -r)
apt-get install linux-headers-$(uname -r)
emerge sys-kernel/linux-headers
pacman -S kernel-headers
In case they are installed in a non-standard location, you may use
the '--evdev-headers' option to specify one or more colon-separated
paths. For example:
python setup.py \
build \
build_ecodes --evdev-headers path/input.h:path/input-event-codes.h \
build_ext --include-dirs path/ \
install
ERROR: Failed building wheel for evdev
Running setup.py clean for evdev
Failed to build evdev
Installing collected packages: evdev, cycler, chardet, wrapt, websocket-client, typing-extensions, setuptools-scm, requests, pynput, pygments, pandas, matplotlib, dataclasses, commonmark, colorama, rich, quantconnect-stubs, python-certifi-win32, pyshortcuts, pydantic, maskpass, lxml, json5, joblib, docker, dependency-injector, click, lean
Running setup.py install for evdev ... error
ERROR: Command errored out with exit status 1:
command: /root/anaconda3/envs/quant/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/setup.py'"'"'; file='"'"'/tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-dm4o0nha/install-record.txt --single-version-externally-managed --compile --install-headers /root/anaconda3/envs/quant/include/python3.6m/evdev
cwd: /tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/
Complete output (37 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/evdev
copying evdev/device.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/evtest.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/genecodes.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/events.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/eventio.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/uinput.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/ff.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/init.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/util.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/ecodes.py -> build/lib.linux-x86_64-3.6/evdev
copying evdev/eventio_async.py -> build/lib.linux-x86_64-3.6/evdev
running build_ext
running build_ecodes
The 'linux/input.h' and 'linux/input-event-codes.h' include files
are missing. You will have to install the kernel header files in
order to continue:
yum install kernel-headers-$(uname -r)
apt-get install linux-headers-$(uname -r)
emerge sys-kernel/linux-headers
pacman -S kernel-headers
In case they are installed in a non-standard location, you may use
the '--evdev-headers' option to specify one or more colon-separated
paths. For example:
python setup.py \
build \
build_ecodes --evdev-headers path/input.h:path/input-event-codes.h \
build_ext --include-dirs path/ \
install
----------------------------------------
ERROR: Command errored out with exit status 1: /root/anaconda3/envs/quant/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/setup.py'"'"'; file='"'"'/tmp/pip-install-sjlw86xr/evdev_7a53e6c97716423e80e6b94c800dce28/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-dm4o0nha/install-record.txt --single-version-externally-managed --compile --install-headers /root/anaconda3/envs/quant/include/python3.6m/evdev Check the logs for full command output.
`
Kraken and FXT Brokerage are not supported yet.
When running lean live algo
, lean gets stuck on login, specifically the line Click button: [Paper Log In]
.
The log says InteractiveBrokersBrokerage.CheckIbAutomaterError(): InitializationTimeout - The IBAutomater initialization timed out
See: https://github.com/QuantConnect/lean-cli/blob/master/lean/commands/cloud/live.py#L192
This means when you run lean cloud live passing '--notify-insights no', it prints out in the debug output that notify insights is yes. Instead, it's necessary to pass '--notify-insights ""' in order to get it to print correctly in the debug output. This conflicts with the documentation provided here: https://www.quantconnect.com/docs/v2/lean-cli/api-reference/lean-cloud-live
Thanks for this awesome library.
I'm encountering an issue when i try to download stock data following the documentation, i get this error.
Error: Your organization needs to have an active Security Master subscription to download Equity data
You can add the subscription at https://www.quantconnect.com/pricing?organization=.
I need some guidance for https://github.com/QuantConnect/lean-cli#lean-backtest.
I guess we need local data set up to use this command but the above doc doesn't have instruction to set up local data.
Currently while installing it outputs:
Using cached docker-4.4.1-py2.py3-none-any.whl (146 kB)
INFO: pip is looking at multiple versions of dependency-injector to determine which version is compatible with other requirements. This could take a while.
Collecting dependency-injector~=4.20.1
Using cached dependency-injector-4.20.1.tar.gz (631 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: six>=1.4.0 in c:\python310\lib\site-packages (from docker~=4.4.1->lean) (1.16.0)
INFO: pip is looking at multiple versions of click to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of maskpass to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of lean to determine which version is compatible with other requirements. This could take a while.
See https://github.com/QuantConnect/lean-cli/blob/master/setup.py#L54
Hi,
First of all, really appreciate the work you guys have been doing out there! Lean CLI is such a great tool.
When trying to run backtest locally though, I am getting the following error:
$ lean backtest "My Python Project" --verbose
Running 'quantconnect/lean:latest' with the following configuration:
{'entrypoint': ['dotnet', 'QuantConnect.Lean.Launcher.dll'],
'mounts': [{'ReadOnly': True,
'Source':
'/var/folders/62/8jhxvq556zz_nj_x_d_8k9tr0000gn/T/tmpea7ns7dl/config.json',
'Target': '/Lean/Launcher/bin/Debug/config.json',
'Type': 'bind'}],
'ports': {},
'volumes': {'/Users/alex/Documents/lean/My Python Project': {'bind':
'/LeanCLI',
'mode':
'ro'},
'/Users/alex/Documents/lean/My Python
Project/backtests/2021-05-16_01-46-37': {'bind': '/Results',
'mode': 'rw'},
'/Users/alex/Documents/lean/My Python Project/storage':
{'bind': '/Storage',
'm
ode': 'rw'},
'/Users/alex/Documents/lean/data': {'bind': '/Lean/Data',
'mode': 'rw'}}}
20210516 05:46:39.325 TRACE:: Config.GetValue(): debug-mode - Using default
value: False
20210516 05:46:39.334 TRACE:: Config.Get(): Configuration key not found. Key:
plugin-directory - Using default value:
20210516 05:46:39.553 TRACE:: Python for .NET Assembly: Python.Runtime,
Version=2.0.1.0, Culture=neutral, PublicKeyToken=5000fea6cba702dd
20210516 05:46:39.578 TRACE:: Python for .NET Assembly: nPython,
Version=3.0.0.0, Culture=neutral, PublicKeyToken=null
20210516 05:46:39.810 TRACE:: Config.Get(): Configuration key not found. Key:
data-directory - Using default value: ../../../Data/
20210516 05:46:39.822 TRACE:: Config.Get(): Configuration key not found. Key:
version-id - Using default value:
20210516 05:46:39.830 TRACE:: Config.Get(): Configuration key not found. Key:
cache-location - Using default value: /Lean/Data
20210516 05:46:39.834 TRACE:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE
v2.5.0.0 Mode: DEBUG (64bit)
20210516 05:46:39.851 TRACE:: Engine.Main(): Started 5:46 AM
20210516 05:46:39.864 TRACE:: Config.Get(): Configuration key not found. Key:
lean-manager-type - Using default value: LocalLeanManager
20210516 05:46:40.000 TRACE:: JobQueue.NextJob(): Selected /LeanCLI/main.py
20210516 05:46:40.401 TRACE:: Config.GetValue():
scheduled-event-leaky-bucket-capacity - Using default value: 120
20210516 05:46:40.413 TRACE:: Config.GetValue():
scheduled-event-leaky-bucket-time-interval-minutes - Using default value: 1440
20210516 05:46:40.419 TRACE:: Config.GetValue():
scheduled-event-leaky-bucket-refill-amount - Using default value: 18
20210516 05:46:40.431 TRACE:: Config.Get(): Configuration key not found. Key:
algorithm-id - Using default value: main
20210516 05:46:40.447 TRACE:: Config.GetValue(): job-project-id - Using default
value: 0
20210516 05:46:40.455 TRACE:: Config.Get(): Configuration key not found. Key:
data-permission-manager - Using default value: DataPermissionManager
20210516 05:46:40.517 TRACE:: AlgorithmManager.CreateTokenBucket(): Initializing
LeakyBucket: Capacity: 120 RefillAmount: 18 TimeInterval: 1440
20210516 05:46:40.540 TRACE:: Config.GetValue():
algorithm-manager-time-loop-maximum - Using default value: 20
20210516 05:46:40.601 TRACE:: TextSubscriptionDataSourceReader.SetCacheSize():
Setting cache size to 71582788 items
20210516 05:46:41.617 TRACE:: Config.GetValue(): algorithm-creation-timeout -
Using default value: 90
20210516 05:46:41.629 TRACE:: PythonInitializer.Initialize(): start...
PythonEngine.Initialize(): Runtime.Initialize()...
Runtime.Initialize(): Py_Initialize...
Runtime.Initialize(): PyEval_InitThreads...
Runtime.Initialize(): Initialize types...
Runtime.Initialize(): Initialize types end.
Runtime.Initialize(): AssemblyManager.Initialize()...
Runtime.Initialize(): AssemblyManager.UpdatePath()...
PythonEngine.Initialize(): GetCLRModule()...
PythonEngine.Initialize(): clr GetManifestResourceStream...
20210516 05:46:46.004 TRACE:: PythonInitializer.Initialize(): ended
20210516 05:46:46.016 TRACE:: AlgorithmPythonWrapper(): Python version 3.6.8
|Anaconda, Inc.| (default, Dec 30 2018, 01:25:33)
[GCC 7.3.0]: Importing python module main
20210516 05:46:46.420 ERROR:: Loader.TryCreatePythonAlgorithm():
System.Exception: AlgorithmPythonWrapper(): SyntaxError : invalid syntax
(main.py, line 4) SyntaxError : invalid syntax (main.py, line 4)
at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper..ctor(St
ring moduleName) in /LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Algori
thmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs:line 146
at QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm(String
assemblyPath, IAlgorithm& algorithmInstance, String& errorMessage) in /LeanCloud
/CI.Builder/bin/Debug/src/QuantConnect/Lean/AlgorithmFactory/Loader.cs:line 173
20210516 05:46:46.428 ERROR:: Engine.Run():
QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm
initialization, the following exception has occurred:
Loader.TryCreatePythonAlgorithm(): Unable to import python module
/LeanCLI/main.py. AlgorithmPythonWrapper(): SyntaxError : invalid syntax
(main.py, line 4) SyntaxError : invalid syntax (main.py, line 4)
at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateAlgorithmInstanc
e(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in /LeanCloud/CI
.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Setup/BacktestingSetupHandler.cs
:line 104
at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager
manager, String assemblyPath, WorkerThread workerThread) in
/LeanCloud/CI.Builder/bin/Debug/src/QuantConnect/Lean/Engine/Engine.cs:line 119
20210516 05:46:46.432 TRACE:: JOB HANDLERS:
20210516 05:46:46.437 TRACE:: DataFeed:
QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed
20210516 05:46:46.440 TRACE:: Setup:
QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler
20210516 05:46:46.442 TRACE:: RealTime:
QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
20210516 05:46:46.444 TRACE:: Results:
QuantConnect.Lean.Engine.Results.BacktestingResultHandler
20210516 05:46:46.446 TRACE:: Transactions:
QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler
20210516 05:46:46.457 ERROR:: Algorithm.Initialize() Error: During the algorithm
initialization, the following exception has occurred:
Loader.TryCreatePythonAlgorithm(): Unable to import python module
/LeanCLI/main.py. AlgorithmPythonWrapper(): SyntaxError : invalid syntax
(main.py, line 4) SyntaxError : invalid syntax (main.py, line 4) Stack Trace:
During the algorithm initialization, the following exception has occurred:
Loader.TryCreatePythonAlgorithm(): Unable to import python module
/LeanCLI/main.py. AlgorithmPythonWrapper(): SyntaxError : invalid syntax
(main.py, line 4) SyntaxError : invalid syntax (main.py, line 4)
During the algorithm initialization, the following exception has occurred:
Loader.TryCreatePythonAlgorithm(): Unable to import python module
/LeanCLI/main.py. AlgorithmPythonWrapper(): SyntaxError : invalid syntax
(main.py, line 4) SyntaxError : invalid syntax (main.py, line 4)
20210516 05:46:46.462 TRACE:: Alpha:
QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20210516 05:46:46.466 TRACE:: ObjectStore:
QuantConnect.Lean.Engine.Storage.LocalObjectStore
20210516 05:46:46.473 TRACE:: DefaultAlphaHandler.Exit(): Exiting...
20210516 05:46:46.480 TRACE:: DefaultAlphaHandler.Exit(): Ended
20210516 05:46:46.482 TRACE:: BacktestingResultHandler.Exit(): starting...
20210516 05:46:46.486 TRACE:: BacktestingResultHandler.Exit(): Saving logs...
20210516 05:46:46.510 TRACE:: Debug: Your log was successfully created and can
be retrieved from: /Results/main-log.txt
20210516 05:46:46.512 TRACE:: BacktestingResultHandler.Run(): Ending Thread...
20210516 05:46:46.512 TRACE:: StopSafely(): waiting for 'Result Thread' thread
to stop...
20210516 05:46:46.683 TRACE:: Config.GetValue(): regression-update-statistics -
Using default value: False
20210516 05:46:46.688 TRACE::
STATISTICS:: Fitness Score 0
STATISTICS:: Kelly Criterion Estimate 0
STATISTICS:: Kelly Criterion Probability Value 0
STATISTICS:: Sortino Ratio 0
STATISTICS:: Return Over Maximum Drawdown 0
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
20210516 05:46:46.692 TRACE:: BacktestingResultHandler.SendAnalysisResult():
Processed final packet
20210516 05:46:46.699 TRACE:: Engine.Run(): Disposing of setup handler...
20210516 05:46:46.710 TRACE:: Engine.Main(): Analysis Completed and Results
Posted.
Engine.Main(): Analysis Complete.
20210516 05:46:46.715 TRACE:: Engine.Main(): Packet removed from queue: main
20210516 05:46:46.717 TRACE:: LeanEngineSystemHandlers.Dispose(): start...
20210516 05:46:46.719 TRACE:: LeanEngineSystemHandlers.Dispose(): Disposed of
system handlers.
20210516 05:46:46.721 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): start...
20210516 05:46:46.724 TRACE:: LeanEngineAlgorithmHandlers.Dispose(): Disposed of
algorithm handlers.
20210516 05:46:46.729 TRACE:: Program.Main(): Exiting Lean...
Traceback (most recent call last):
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
lean/main.py", line 30, in main
lean.main(standalone_mode=False)
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
lean/click.py", line 80, in invoke
result = super().invoke(ctx)
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
lean/commands/backtest.py", line 201, in backtest
lean_runner.run_lean("backtesting", algorithm_file, output, engine_image,
debugging_method)
File "/Users/alex/opt/anaconda3/envs/lean/lib/python3.6/site-packages/
lean/components/docker/lean_runner.py", line 110, in run_lean
f"Something went wrong while running '{relative_project_dir}' in the
'{environment}' environment, the output is stored in '{relative_output_dir}'")
RuntimeError: Something went wrong while running 'My Python Project' in the
'backtesting' environment, the output is stored in 'My Python
Project/backtests/2021-05-16_01-46-37'
Error: Something went wrong while running 'My Python Project' in the
'backtesting' environment, the output is stored in 'My Python
Project/backtests/2021-05-16_01-46-37'
Can someone please help?
this line
lean-cli/lean/components/util/logger.py
Line 116 in 54b77f2
should check stdin instead of stdout.
When we push a file to cloud with invalid name, the message is not correct:
Create new project named ShortFileTest in QuantConnect.com, and pull it:
$ lean cloud pull --project "ShortFileTest"
add lib.py file to the ShortFileTest directory and push the project
$ lean cloud push --project "ShortFileTest"
The following message is shown:
"Cannot push 'ShortFileTest 2' (failed on $HOME\Local\ShortFileTest\lib.py): Invalid credentials, please log
in using lean login
"
where it should inform that the file name is too short.
I noticed Lean CLI always runs projects in Debug configuration. It would be useful to have an option to build and run the project in Release mode also. In a Release build we get compiler optimization and debug specific statements are left out of the output binaries. For example, I use a lot of Debug.Assert()
calls that are good for testing at runtime but will also slow down the algorithm.
I suggest to also include the Release build of the Lean Engine in its Docker image. That should give some performance improvement to running the algos.
Steps to reproduce:
lean create-project my-project
dotnet build my-project # --configuration Debug
dotnet build my-project --configuration Release
lean backtest my-project
Backtest will fail with this error:
/LeanCLI/lean-cloud/my-project/obj/Release/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs(4,12): error CS0579: Duplicate
'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [/LeanCLI/lean-cloud/my-project/my-project.csproj]
.
.
.
I noticed the project will run again after deleting the obj
directory.
rm -r my-project/obj
I think to fix it, we can get lean
command to remove the obj
directory before running backtest, or maybe we could use the .dockerignore
file to exclude the build artifacts from going into the docker image.
Hi,
I tried to generate random data using lean data generate, but when I run the backtest, the newly generated ticker doesn't appear in the Universe Selection nor in the OnData feed, even if I add the equity manually.
I tried reseting the lean repository and updating the lean data generate as explained in #3 (comment).
It raises an error at the end:
20210622 18:14:08.080 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/ths/20210617_trade.zip 20210622 18:14:08.104 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/ths/20210618_trade.zip 20210622 18:14:08.128 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/ths/20210621_trade.zip 20210622 18:14:08.147 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/minute/ths/20210622_trade.zip 20210622 18:14:08.172 TRACE:: LeanDataWriter.Write(): Created: ../../../Data/equity/usa/daily/ths.zip Symbol[1]: THS 2T Progress: 100.0% - Symbol data generation and output completed Random data generation has completed. Launching coarse data generator... 20210622 18:14:08.173 TRACE:: Config.Get(): Configuration key not found. Key: reserved-words-prefix - Using default value: quantconnect- 20210622 18:14:08.176 TRACE:: CoarseUniverseGeneratorProgram.ProcessDailyFolder(): Processing: /Lean/Data/equity/usa/daily 20210622 18:14:08.196 TRACE:: CoarseUniverseGeneratorProgram.PopulateSidContex(): Generating SID context from QuantQuote's map files. 20210622 18:14:08.209 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/vxxb.zip not found! 20210622 18:14:08.213 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/vxx.zip not found! 20210622 18:14:08.213 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker VXX not found! 20210622 18:14:08.213 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker VXXB not found! 20210622 18:14:08.286 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/vxx.zip not found! 20210622 18:14:08.286 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker VXX not found! 20210622 18:14:08.341 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/aol.zip not found! 20210622 18:14:08.344 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/twx.zip not found! 20210622 18:14:08.344 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker TWX not found! 20210622 18:14:08.344 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker AOL not found! 20210622 18:14:08.350 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/twx.zip not found! 20210622 18:14:08.350 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker TWX not found! 20210622 18:14:08.365 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/nb.zip not found! 20210622 18:14:08.424 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/nwsa.zip not found! 20210622 18:14:08.426 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/foxa.zip not found! 20210622 18:14:08.428 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/tfcfa.zip not found! 20210622 18:14:08.428 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker TFCFA not found! 20210622 18:14:08.428 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker FOXA not found! 20210622 18:14:08.428 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker NWSA not found! 20210622 18:14:08.441 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/spwr.zip not found! 20210622 18:14:08.442 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/spwra.zip not found! 20210622 18:14:08.442 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker SPWR not found! 20210622 18:14:08.442 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker SPWRA not found! 20210622 18:14:08.442 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker SPWR not found! 20210622 18:14:08.533 ERROR:: CoarseUniverseGeneratorProgram.Run(): ../../../Data/equity/usa/daily/qqqq.zip not found! 20210622 18:14:09.483 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker QQQQ not found! 20210622 18:14:10.415 ERROR:: CoarseUniverseGeneratorProgram.Run(): Daily data for ticker NB not found! 20210622 18:14:23.855 TRACE:: CoarseUniverseGeneratorProgram.Run(): Processed 1000 in 0:00:00.9406899 at 1063.05 files/second 20210622 18:14:24.743 TRACE:: CoarseUniverseGeneratorProgram.Run(): Processed 2000 in 0:00:01.8294276 at 1093.24 files/second 20210622 18:14:25.678 TRACE:: CoarseUniverseGeneratorProgram.Run(): Processed 3000 in 0:00:02.7642657 at 1085.28 files/second
However, when I check the minute
folder, the fundamental/coarse
and the map_files
, the new ticker appears normally. I don't understand what is missing for Lean to find it.
Any suggestions?
Thanks
Hi,
My local lean was working fine in v1.05. Today, when I updated to lean 1.10 it is not stopping in the breakpoints when debugging using VSCode. I restarted the working directory and pulled all projects from the cloud again, but no changes. It connects to the port 5678 as expected and runs the code, but now it skips all breakpoints. Tried other solutions but none seems to work.
Any ideas?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.