book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

Meta Analysis

Optimization Analysis

Introduction

Load your optimization results into the Research Environment to analyze how different combinations of parameters affect the algorithm's performance.

Read Optimization Results

To get the results of an optimization, call the read_optimization method with the optimization Id.

Select Language:
optimization = api.read_optimization(optimization_id)

The following table provides links to documentation that explains how to get the optimization Id, depending on the platform you use:

PlatformOptimization Id
Cloud PlatformGet Optimization Id
Local PlatformGet Optimization Id
CLI

The read_optimization method returns an Optimization object, which have the following attributes:

Example

Example 1: Read Optimization Results

The following example reads the last completed optimization job and obtains the optimum paramteters in a jupyter notebook.

Select Language:
# Instantiate QuantBook instance for researching.
qb = QuantBook()

# Get optimization job list in the current project.
optimizations = api.list_optimizations(qb.project_id)
# Get the last completed optimizations to study.
optimization_id = sorted(
    [x for x in optimizations if x.status == OptimizationStatus.COMPLETED],
    key=lambda x: x.created,
    reverse=True
)[0].optimization_id
optimization = api.read_optimization(optimization_id)

# Obtain the backtest with the best Sharpe Ratio.
best_backtest = max(optimization.backtests.values(), key=lambda x: x.statistics["SharpeRatio"])
# Obtain the parameter set of the backtest with the best result.
parameter_set = best_backtest.parameter_set
print(parameter_set)

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

Did you find this page helpful?

Contribute to the documentation: