Coverage for scripts/lean_teardown_smoke/main.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.17.3, created at 2026-11-22 12:55 +0000

1"""Problems.md #104 smoke test: the smallest Lean algorithm (SPY daily, no custom objects, nothing of this project). 

2 

3Run it with `lean backtest scripts/lean_teardown_smoke --image <image>` and 

4read the ENGINE log (`backtests/<run>/log.txt`): a clean exit shows `PythonInitializer.Shutdown(): ended`; the known hang shows 

5`Operation timed out` / `Failed to shutdown python` after the results were written. If the trivial algorithm hangs, so does 

6every algorithm on that image, whatever this project does. 

7""" 

8 

9from AlgorithmImports import * 

10 

11 

12class TeardownSmoke(QCAlgorithm): 

13 def initialize(self): 

14 self.set_start_date(2020, 1, 2) 

15 self.set_end_date(2020, 3, 31) 

16 self.set_cash(100000) 

17 self.symbol = self.add_equity("SPY", Resolution.DAILY).symbol 

18 

19 def on_data(self, data): 

20 if not self.portfolio.invested and data.contains_key(self.symbol): 

21 self.set_holdings(self.symbol, 1.0)