QuantConnect / lean-cli

CLI for running the LEAN engine locally and in the cloud
https://www.lean.io/cli
Apache License 2.0
194 stars 99 forks source link

C# project ends up non-compilable when solution file is present #326

Closed starteleport closed 1 year ago

starteleport commented 1 year ago

Hi!

I have the following directory structure for my project:

.
|____pump-detect
| |____tests
| | |____PumpDetector.Tests
| | | |____PumpDetector.Tests.csproj
| |____pump-detect.sln
| |____storage
| |____.idea
| |____src
| | |____PumpDetector
| | | |____obj
| | | |____bin
| | | |____backtests
| | | |____research.ipynb
| | | |____config.json
| | | |____optimize-config.json
| | | |____Main.cs
| | | |____PumpDetector.csproj
| | | |____storage
| | | |____optimizations
|____lean.json
|____data

When I'm inside src, I execute lean backtest PumpDetector.

Expected result: backtest runs successfully

Actual result: The error is returned in backtest output:

20230630 19:20:32.784 ERROR:: API.GetExtendedTypeNames(): No types found in assembly.
20230630 19:20:32.785 ERROR:: Loader.TryCreateILAlgorithm(): Types array empty, no algorithm type found.
20230630 19:20:32.799 ERROR:: Engine.Run():  QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following
exception has occurred: Algorithm type was not found.
   at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in
/LeanCLI/Lean/Engine/Setup/BacktestingSetupHandler.cs:line 103
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath, WorkerThread workerThread) in
/LeanCLI/Lean/Engine/Engine.cs:line 116

Also, I've noticed the following changes in my directory:

.
|____pump-detect
| |____tests
| | |____PumpDetector.Tests
| | | |____PumpDetector.Tests.csproj
| |____pump-detect.sln
| |____storage
| |____.idea
| |____src
| | |____PumpDetector
| | | |____obj
| | | |____bin
| | | |____backtests
| | | |____research.ipynb
| | | |____config.json
| | | |____optimize-config.json
| | | |____Main.cs
| | | |____PumpDetector.csproj
| | | |____src <<<<<<-------------- this directory appears
| | | | |____PumpDetector
| | | | | |____PumpDetector.csproj
| | | |____storage
| | | |____tests <<<<<<-------------- this directory appears
| | | | |____PumpDetector.Tests
| | | | | |____PumpDetector.Tests.csproj
| | | |____optimizations
|____lean.json
|____data

If I rename the solution file so that it doesn't have .sln extension, the backtest would succeed as soon as I remove those two directories.

Martin-Molinero commented 1 year ago

Thanks for the report @starteleport. Will close as duplicate of https://github.com/QuantConnect/lean-cli/issues/260