I'm excited to experience the integration of Pycharm and LEAN Research Notebooks. I ran a strategy using the quantconnect/lean:latest image without problems. I then tried quantconnect/research:latest and Jupyter lab started ok, but running KitchenSinkQuantBookTemplate.ipynb had a problem -
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Indicators")
from System import *
from QuantConnect import *
from QuantConnect.Data.Custom import *
from QuantConnect.Data.Market import TradeBar, QuoteBar
from QuantConnect.Indicators import *
qb = QuantBook()
resulted with
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-fb9797366fd4> in <module>
17
18 # Create an instance
---> 19 qb = QuantBook()
NameError: name 'QuantBook' is not defined
so I tried
clr.AddReference('QuantConnect.Research')
from QuantConnect.Research import QuantBook
qb = QuantBook()
but got
---------------------------------------------------------------------------
DirectoryNotFoundException Traceback (most recent call last)
<ipython-input-5-64eb21567b20> in <module>
2 from QuantConnect.Research import QuantBook
3
----> 4 qb = QuantBook()
DirectoryNotFoundException: Could not find a part of the path "/home/Data/market-hours/market-hours-database.json".
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00164] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options, System.String msgPath, System.Boolean bFromProxy, System.Boolean useLongPath, System.Boolean checkHost) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,System.IO.FileOptions,string,bool,bool,bool)
at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean checkHost) [0x00067] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.StreamReader..ctor (System.String path, System.Boolean detectEncodingFromByteOrderMarks) [0x0000d] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at System.IO.StreamReader..ctor (System.String path) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at (wrapper remoting-invoke-with-check) System.IO.StreamReader..ctor(string)
at System.IO.File.ReadAllText (System.String path) [0x00000] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
at QuantConnect.Securities.MarketHoursDatabase.FromFile (System.String path) [0x00000] in <99fe1666e1bc41d5a69cbca8386aa5ff>:0
at QuantConnect.Securities.MarketHoursDatabase.FromDataFolder (System.String dataFolder) [0x00028] in <99fe1666e1bc41d5a69cbca8386aa5ff>:0
at QuantConnect.Securities.MarketHoursDatabase.FromDataFolder () [0x00005] in <99fe1666e1bc41d5a69cbca8386aa5ff>:0
at QuantConnect.Algorithm.QCAlgorithm..ctor () [0x001e1] in <0ccf1951074c40da9e1885115333a4e4>:0
at QuantConnect.Research.QuantBook..ctor () [0x00000] in <dcd76d035b414d29bd8e65982f8cdb88>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <b0e1ad7573a24fd5a9f2af9595e677e7>:0
Could you please help with this?
Many thanks.
DaveGilbert
OK, solved!
Copied /Lean/Data to /Lean/Launcher/bin/Debug/Notebooks
and edited config.json to point to /Lean/Launcher/bin/Debug/Notebooks/Data/
{ "data-folder": "/Lean/Launcher/bin/Debug/Notebooks/Data/", "composer-dll-directory": "/Lean/Launcher/bin/Debug/", "algorithm-language": "Python", "messaging-handler": "QuantConnect.Messaging.Messaging", "job-queue-handler": "QuantConnect.Queues.JobQueue", "api-handler": "QuantConnect.Api.Api" }
Danny Luong
You can also change this line in run_docker_notebook.sh from this:
--mount type=bind,source=$data_dir,target=/Data,readonly \
to this to avoid doing the copying:
--mount type=bind,source=$data_dir,target=/home/Data,readonly \
DaveGilbert
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!