Open Source

Lean Report Creator

Lean Report Creator


The LEAN Report Creator is a report generated from backtesting-result objects and allows you to quickly create polished, professional-grade reports for each backtest (see a full example report generated by LRC). Our hope is that you can use these reports to share your strategy performance with prospective investors.

Users working through the IDE can have these reports generated automatically at the end of a backtest. To generate one, look at the “Report” tab below your backtest result charts.

Creating a Report

The LEAN Report Creator is a python script located in the PythonToolbox. It is a command line tool which takes the json backtest result object as its input. You can run it like this:

python --output=./report.html --user=data.json

The program has three key options you should configure to your requirements:

Command SwitchDescription
--backtestLocation of the source backtest json file.
--outputResulting output HTML file location.
--userJson data object for the user data of the report (see example).

The program injects the images as base64 encoded objects into the HTML file to make it more portable and simpler to share with your partners.

Source Backtest

The --backtest switch refers to a JSON file created by the LEAN Engine. This holds all of the backtest data which is required for generating the report html. This data can be sourced for desktop or cloud backtests.

Desktop Backtesting Results

By default LEAN saves the backtest result data to disk inside of your LEAN launcher folder: Lean/Launcher/bin/Debug/BasicTemplateAlgorithm.json. It is saved there by the BaseResultHandler.SaveResult method. You can access it like this from the Python Toolbox:

python --backtest=../Launcher/bin/Debug/BasicTemplateAlgorithm.json ....

Cloud Backtesting Results

Backtest processed reports can also be downloaded via API. The following example imports the QuantConnect API class; and uses it to download the final HTML report. To access the API you will need to know your API User Id and Token, which can be located on your Account page.

Option 1: Easy: Downloading Cloud Generated Reports:
>>> from IPython.core.display import display, HTML
>>> from quantconnect.api import Api
>>> api = Api(your-user-id, your-token)
>>> lean_report = api.read_backtest_report(project-id, backtest-id)
>>> display(HTML(lean_report['report']))
Option 2: Harder: Downloading Cloud Generated Backtest Json Files:
>>> from quantconnect.api import Api
>>> from json import dump
>>> api = Api(your-user-id, your-token)
>>> data = api.read_backtest(project-id, backtest-id)
>>> with open("./json/sample.json", 'w+') as fp:
>>>    json.dump(data['result'], fp, ensure_ascii=False)

You can update your report description by clicking on the Project Description button in your project panel. The report automatically uses your profile picture for the report image.

Customizing Report Contents

The report imports a profile image and description of the strategy. This is stored inside a JSON file user_data.json. You can customize the contents of this file to automatically generate future reports with the new data:

    "authorName": "Joe Blogs",
    "authorPicture": "AuthorProfile.png",
    "authorBiography": "Put your biography here.",
    "projectName": " -- Page title / project name --",
    "projectDescription": " -- Longer description text area -- "

Interpreting Report Charts

Cumulative Return

This chart shows the cumulative returns for your strategy in orange and the benchmark in gray.

Daily Return

This chart shows the daily returns for your strategy. When the return is positive, a orange bar will show above the horizontal line; when the return is negative, a gray bar will show below the horizontal line.

Top 5 Drawdown Periods

This chart shows the drawdown of each day. A certain day's drawdown is defined as the percentage of loss compared to the maximum value prior to this day. The drawdowns are calculated based on daily data. The top 5 drawdown periods are marked in the chart with different colors.

Monthly Returns

This chart shows the return of each month. We convert original price series into monthly series, and calculate the returns of each month. The green color indicates positive return, the red color indicates negative return, and the greater the loss is, the darker the color is; the yellow color means the gain or loss is rather small; the white color means the month is not included in the backtest period. The values in the cells are in percentage.

Annual Returns

This chart shows the return of each year. We calculate the total return within each year, shown by the blue bars. The red dotted line represents the average of the annual returns. If the backtest covers less than 12 months of a certain year, then the value in the chart is the actual return which is not annualized.

Crisis Events

This group of charts shows the behaviors of both your strategy and the benchmark during a certain historical period. We set the value of your strategy the same as the benchmark at the beginning of each crisis event, and the lines represent the cumulative returns of your strategy and benchmark from the beginning of this crisis event. The report only draws the crisis event charts whose time periods are covered by your strategy.

Rolling Portfolio Beta to Equity

This chart shows the rolling portfolio beta to the benchmark. This chart is drawn based on daily data. Every day, we calculate the beta of your portfolio to the benchmark over the past 6 months (gray line) or 12 months (blue line).

A beta close to 1 means the strategy has a risk exposure similar to the benchmark. A beta higher than 1 means the strategy has more risk than the benchmark, a beta close to 0 means the strategy is "market neutral", which isn't much affected by market situation. Beta can also be negative - in this situation the the strategy has opposite risk exposure to the benchmark. We won't draw this chart when your backtest period is less than 12 months.

Rolling Sharpe Ratio

This chart shows the rolling sharpe ratio of your strategy. The rolling sharpe ratio is calculated on daily data, and annualized. Every day, we calculate the sharpe ratio of your portfolio over the past 6 months, and connect the sharpe ratios into a line. The red dotted line represents the mean value of the total sharpe ratios. We won't draw this chart when your backtest period is less than 6 months.

Net Holdings

This chart shows the net holdings of your portfolio. The net holding is the aggregated weight of risky assets in your portfolio. It could be either positive (when your total position is long), negative (when your total position is short) or 0 (when you only hold cash). The net holding changes only if new order is fired. The chart is drawn based on minute data, which means we aggregate all the positions of a minute together.


This chart shows the leverage of your portfolio. The value of the leverage is always non-negative. When you only hold cash, the leverage is 0; a leverage smaller than 1 means you either long assets with money less than your portfolio value or short assets with total value less than your portfolio value; a leverage larger than 1 means you either borrow money to buy assets or short assets whose value is larger than your portfolio value. The leverage changes only if new order is fired.

Asset Allocations

The asset allocation charts show a time-weighted average of each class of asset to your portfolio. When a certain asset has very small percentage and is too small to be shown in the pie chart, it will be incorporated into an "Others" category. The value of the percentage could be either positive or negative.

You can also see our Documentation and Videos. You can also get in touch with us via Chat.

Did you find this page helpful?

Contribute to the tutorials: