Tutorials

Generating reports

Introduction

The lean report command in the Lean CLI is a wrapper around the LEAN Report Creator. The LEAN Report Creator is a program included with LEAN which allows you to quickly generate polished, professional-grade reports of your backtests. Optionally you can also include live trading results in these reports. We hope that you can use these reports to share your strategy performance with prospective investors.

Generating a report

Follow these steps to generate a report of a backtest:

  1. Open a terminal in the directory you ran lean init in.
  2. Run lean report to generate a report of the most recent backtest.
    $ lean report
    20210322 20:03:48.718 TRACE:: QuantConnect.Report.Main(): Parsing source files...backtest-data-source-file.json,
    20210322 20:03:51.602 TRACE:: QuantConnect.Report.Main(): Instantiating report...
    Successfully generated report to './report.html'
    
    By default, the generated report is saved to ./report.html, although you can change this by providing a custom path with the --report-destination <path> option. If you want to generate a report of a backtest that is not the most recent one, you can use the --backtest-results <path> option to specify the path to the backtest results JSON file to generate a report for.
  3. Open the generated report in the browser and inspect its results.

Optionally you can also configure the following details:

  • Strategy name: This name is displayed in the top-right corner of each page, and can be configured using --strategy-name <value>. This value defaults to the name of the project directory.
  • Strategy version: This version is displayed next to the strategy name and can be configured using --strategy-version <value>.
  • Strategy description: This description is displayed underneath the "Strategy Description" header on the first page and can be configured using --strategy-description. This value defaults to the description stored in the project's configuration.
  • Live results: These results are displayed over the backtest results, and can be configured using --live-results <path>. The provided path must point to a JSON file containing live results.

Interpreting report charts

A generated report contains various statistics about the backtest and optionally about the live trading results. Some of these statistics are formatted in a table, but most of them are formatted as professional-looking charts. This section describes the content of each generated chart.

Monthly returns

This chart shows the return of each month. We convert the original price series into monthly series and calculate the returns of each month. The green color indicates a positive return, the red color indicates a negative return. 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.

Cumulative returns

This chart shows the cumulative returns of your strategy in blue for backtesting, orange for live trading, and gray for the benchmark.

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.

Returns per trade

This chart shows a histogram showing the distribution of returns per trade over the algorithm's backtesting or live trading period.

Asset allocation

The asset allocation chart shows a time-weighted average of each asset to your portfolio. When a certain asset has a 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.

Drawdown

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 before this day. The drawdowns are calculated based on daily data. The top 5 drawdown periods are marked in the chart with different colors.

Daily returns

This chart shows the returns of each day. A blue bar is shown if the strategy made a profit for the day, and a gray bar is shown for a loss.

Rolling portfolio beta (6 months)

This chart shows the rolling portfolio beta over a 6 and 12 month period. The 6 month period is shown in light blue, the 12 month period in dark blue.

Rolling Sharpe ratio (6 months)

This chart shows the rolling Sharpe ratio over a 6 and 12 month period. The 6 month period is shown in light blue, the 12 month period in dark blue.

Leverage

This chart shows the strategy's utilization of leverage over time.

Long-short exposure

This chart shows the strategy's long-short exposure by asset type over time.

Crisis events

This group of charts shows the behaviors of both your strategy and the benchmark during certain historical periods. 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 the crisis event. The report only contains the crisis event charts whose periods are covered by your strategy.

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

Did you find this page helpful?

Contribute to the documentation: