Meta Analysis
Optimization Analysis
Read Optimization Results
To get the results of an optimization, call the read_optimization
method with the optimization Id.
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:
Platform | Optimization Id |
---|---|
Cloud Platform | Get Optimization Id |
Local Platform | Get 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.
# 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)