Skip to main content

leanpeek

Lean backtest results, at a glance.

CI License: MIT Python 3.9 through 3.12

What is leanpeek

leanpeek reads a QuantConnect LEAN backtest result JSON and turns it into one human sentence — plus a terminal sparkline of the equity curve and drawdown, so you can see the shape of the result before opening any file. If you want the details, it writes a small report (summary.csv, report.md) and a chart (equity curve + drawdown, with an optional ticker close overlay).

It was born as a bootcamp mini-project: the class ran a Samsung Electronics Buy-and-Hold backtest on quantconnect/lean and the assignment was "turn the results into something you'd actually use." leanpeek is that something — a tiny, dependency-light CLI that makes the engine's output legible instead of a 215 KB JSON file.

Quick start

pip install -e .          # or: pip install leanpeek (once published)

# Point it at a directory containing SamsungBuyAndHold.json (+ optional samsung.csv)
leanpeek -r sample

[local] 2024-01-01 ~ 2025-01-01: 1,000,000 -> 973,600 (net -2.640%), max drawdown 3.800%, Sharpe -3.919 | 1 order(s) (first: 2024-01-03 Buy 1 @ 79,600)
    equity  ▆▆▅▅▅▅▅▅▅▅▅▅▅▆▇▇▇▇▆▆▆▇▆▆▆▅▆▆▇▇▇███▇▇▆▆▆▆▆▅▄▃▃▃▃▂▂▂▂▂▁▁▂▂  (min 970,300 / max 1,008,200)
  drawdown  █▇▇▇▇▇▇▇▇▇▇▇▇▇████▇▆▆▇▇▇▆▆▆▇▇▇▇███▇▇▆▅▆▆▅▅▄▃▃▃▃▂▂▂▂▂▁▁▂▂  (min -3.8 / max 0.0)
reports -> leanpeek-out

(That exact output is pinned by tests/test_sample.py.) Add --banner for an ASCII-art wordmark, --ascii-plain if your terminal can't render block glyphs, and --spark-width N to control the sparkline length.

leanpeek writes three files into leanpeek-out/ by default (override with -o):

output contents
summary.csv the LEAN statistics / runtimeStatistics flattened to a table
report.md the one-liner plus a Markdown table and data-usage notes
lean_report.png equity curve + drawdown, with ticker close overlay when available
$ leanpeek -r sample
[local] 2024-01-01 ~ 2025-01-01: 1,000,000 -> 973,600 (net -2.640%), max drawdown 3.800%, Sharpe -3.919 | 1 order(s) (first: 2024-01-03 Buy 1 @ 79,600)
    equity  ▆▆▅▅▅▅▅▅▅▅▅▅▅▆▇▇▇▇▆▆▆▇▆▆▆▅▆▆▇▇▇███▇▇▆▆▆▆▆▅▄▃▃▃▃▂▂▂▂▂▁▁▂▂  (min 970,300 / max 1,008,200)
  drawdown  █▇▇▇▇▇▇▇▇▇▇▇▇▇████▇▆▆▇▇▇▆▆▆▇▇▇▇███▇▇▆▅▆▆▅▅▄▃▃▃▃▂▂▂▂▂▁▁▂▂  (min -3.8 / max 0.0)
reports -> leanpeek-out
$ leanpeek -r sample --banner
 _                                  _
| | ___  __ _ _ __  _ __   ___  ___| | __
| |/ _ \/ _` | '_ \| '_ \ / _ \/ _ \ |/ /
| |  __/ (_| | | | | |_) |  __/  __/   <
|_|\___|\__,_|_| |_| .__/ \___|\___|_|\_\
                   |_|

[local] 2024-01-01 ~ 2025-01-01: 1,000,000 -> 973,600 (net -2.640%), max drawdown 3.800%, Sharpe -3.919 | 1 order(s) (first: 2024-01-03 Buy 1 @ 79,600)
    equity  ▆▆▅▅▅▅▅▅▅▅▅▅▅▆▇▇▇▇▆▆▆▇▆▆▆▅▆▆▇▇▇███▇▇▆▆▆▆▆▅▄▃▃▃▃▂▂▂▂▂▁▁▂▂  (min 970,300 / max 1,008,200)
  drawdown  █▇▇▇▇▇▇▇▇▇▇▇▇▇████▇▆▆▇▇▇▆▆▆▇▇▇▇███▇▇▆▅▆▆▅▅▄▃▃▃▃▂▂▂▂▂▁▁▂▂  (min -3.8 / max 0.0)
reports -> leanpeek-out

You can also run it as a module: python -m leanpeek -r sample.

What it reads

A LEAN result JSON stores:

  • equity curve under charts.Strategy Equity.series.Equity.values ([timestamp, open, high, low, close] rows),
  • orders as a dict keyed by order id,
  • metrics under statistics / runtimeStatistics.

leanpeek parses exactly that shape — no QuantConnect account, no data provider, no network. Point it at any LEAN -results folder.

Verification

Every number in this README is regenerated from the committed run in sample/ and pinned by tests/test_sample.py. CI runs ruff + pytest on Python 3.10 and 3.12 — no network, no Docker. If a future LEAN version changes the result format, the tests will notice before the README drifts.

Limitations

  • This is an educational example, not investment advice.
  • The bundled sample strategy does not model KRX fees, dividends, trading calendar, or FX (as noted in the LEAN sample strategy), so treat the numbers as engine/format verification, not realistic performance.

Acknowledgements

License

MIT © 2026 Noah TaeHwan. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leanpeek-0.1.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leanpeek-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file leanpeek-0.1.0.tar.gz.

File metadata

  • Download URL: leanpeek-0.1.0.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for leanpeek-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6736875627bc0dfe94162595cf2bdbc3e1189bc439030b11d98f7ceede0f2a60
MD5 3f0f5a3542bad439cb9dc2cb2d746006
BLAKE2b-256 a4fedefac47b40371b18da64d366b6dca2c2e895abad0ffce33d198f72cb557e

See more details on using hashes here.

File details

Details for the file leanpeek-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: leanpeek-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for leanpeek-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db6215ad980407a3843c370e33ffef0ad04bbb440e00fbf6a1deab72dcdb5eb7
MD5 4ff031399299e645d92446cb8466e82a
BLAKE2b-256 890e0ad8fe323e239261a2a2625a71fa306a7544dfb0131010a5a00909b659cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page