Hi john smitherson ,
Happy to see you did some research in the forum. It gave us a chance to close old threads. Thanks!
We don't need to copy the Python scripts to Launcher/bin/Debug folder since we set the algorithm location with config.json file:
"algorithm-location": "../../../Algorithm.Python/BasicTemplateFrameworkAlgorithm.py",
it goes back three directories because the executable is found in Lean/Launcher/bin/Debug and the script in Lean/Algorithm.Python, therefore it goes to the root directory (Lean/).
In the online IDE, when we hit "Build", it runs a compiler that creates the pyc files before the algorithm is executed. In this process, we add headers with imports such as:
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
QCAlgorithm class comes from QuantConnect.Algorithm module/namespace. Thus all algorithms need, at least, the commands of the code snippet above.
If the algorithm needs to import classes that are not in those namespaces, we can find them in the code. For example, take PythonData for algorithms with custom data, we can see that it belongs to QuantConnect.Python namespace, consequently we need to add the following import:
from QuantConnect.Python import PythonData
as we can verify in the CustomDataBitcoinAlgorithm.py.
You can add all the imports as the QuantConnect Cloud compiler does. It will have an impact on the time it takes for loading the algorithm, but it shouldn't take too long.