Portfolio Optimization


Understanding Optimization

A strategy is created by implementing trading concepts, ideas, and observations of historical market behavior, into a trading system. The very idea of a trading system implies a degree of optimization to market behavior.

The process of strategy optimization further enhances and automates this process. Strategy optimization is the search for the set of optimum parameters for the defined criteria. By testing a range of signal input values, optimization aids in selecting the values that correspond, based on historical data, to the best strategy performance. Optimization aids in better understanding of strategy's characteristics and in creating new criteria for entries and exits.

Optimization can have detrimental effects if the user searches for the combination of inputs based solely on the best performance over a period of historical data and focuses too much on market conditions that may never occur again. This approach is known as over-optimization or curve-fitting. Performance will not be the same in real trading, since historical patterns are highly unlikely to be repeated.


Optimization Methods

There are two optimization methods: Exhaustive Search and Genetic Algorithm.

Exhaustive, also called Brute-Force, optimization systematically goes through all the potential combinations in search for the best solution. The length of time required is proportional to the total number of all possible solutions. Unless relatively few parameters are involved, the period of time required to reach a solution by this method may turn out to be unacceptably long. Thus, exhaustive optimization may only be suitable when there is a limited number of possible solutions.

Genetic Algorithms optimization evaluates only the more promising combinations, finding near-optimum solutions in a fraction of time that would be required by the brute-force approach, making Genetic Algorithm optimization powerful enough to analyze strategies with hundreds of parameters. Genetic Optimizer settings add flexibility to this technique.

To learn more about optimization techniques, see Understanding Optimization


Running Portfolio Optimization

  • Open Portfolio Trader window.

Once a portfolio has been created, strategy configured, and portfolio settings selected, portfolio optimization can be run.


Exhaustive Search Portfolio Optimization

To perform portfolio optimization:

  1. Click the Optimize Portfolio Optimize.png button on the toolbar, or select Portfolio in the main menu and then click Run Optimization.
  2. In the Select Optimization Method dialog box that appears, select Exhaustive Search.
  3. In the Exhaustive Search Properties window that appears, select the Optimizable Inputs tab.
  4. Check/uncheck the check box to the left of the signal name and input name to enable/disable optimization for this input or check the check box to the left of the Signal Name column heading to enable optimization for all inputs (at least one input should be selected to perform optimization).
  5. The Current Value column shows input values that are currently selected for the signals applied on the chart.
  6. In the Start Value column, enter the desired starting values for each of the inputs.
  7. In the End Value column, enter the desired ending values for each of the inputs.
  8. In the Step column, enter the desired step size, for each of the inputs.
  9. The Step Count column shows current amount of steps for an input.
  10. Select the Optimization Criteria tab.
  11. Select the Use Limitation checkbox to limit the output to a defined number of the best results; unselect the checkbox to list all the results in the optimization report.
  12. When Use Limitation checkbox is checked Optimization dialog window shows current best results for selected ัriteria during optimization.
  13. Enter the desired number of best results in the Show N best results box.
  14. Select the best results criteria in the best results for list box.
  15. Select Ascending or Descending option to sort the output in ascending or descending order, respectively.
  16. Click OK to run the optimization and generate the Optimization Report.


Genetic Algorithms Portfolio Optimization

To perform portfolio optimization:

  1. Click the Optimize Portfolio Optimize.png button on the toolbar, or select Portfolio in the main menu and then click Run Optimization.
  2. In the Select Optimization Method dialog box that appears, select Genetic Algorithm.
  3. In the Genetic Algorithm Properties window that appears, select the Optimizable Inputs tab.
  4. Check/uncheck the check box to the left of the signal name and input name to enable/disable optimization for this input or check the check box to the left of the Signal Name column heading to enable optimization for all inputs (at least one input should be selected to perform optimization).
  5. The Current Value column shows input values that are currently selected for the signals applied on the chart.
  6. In the Start Value column, enter the desired starting values for each of the inputs.
  7. In the End Value column, enter the desired ending values for each of the inputs.
  8. In the Step column, enter the desired step size, for each of the inputs.
  9. The Step Count column shows current amount of steps for an input.
  10. Select the Algorithm-specific Properties tab.
  11. Select the best results criteria in the Criteria list box.
  12. Select Ascending or Descending option to sort the output in ascending or descending order, respectively.
  13. Set the Genetic Algorithm properties. For information on GA properties, see Understanding Genetic Algorithm Optimization
  14. Click OK to run the optimization and generate the Optimization Report.
  15. Optimization dialogue window shows Average fitness value for current population during optimization.


Using Optimization Report

After the optimization process is complete, a Strategy Optimization Report is generated and displayed in the Optimization Report window. Only one Optimization Report window can be open at a time.

The report lists the results of all input combinations (subject to limitations options), arranged by the specified criteria in the specified order. Each row lists a set of performance results for each combination of inputs. The report can be sorted by values in any three of the criteria, in either ascending or descending order.


Sorting the Optimization Report

To sort the report:

  1. Select the most significant sort criterion in the Sort by list box at the top left of the report window, and then select Ascending or Descending to specify the sort order.
  2. Select the second most significant sort criterion in the Then by list box at the top center of the report window, and then select Ascending or Descending to specify the sort order.
  3. Select the least significant sort criterion in the Then by list box at the top right of the report window, and then select Ascending or Descending to specify the sort order.


Applying an Inputs Combination to the Strategy

A combination of inputs listed in any row of the report can be applied directly to the portfolio strategy.

To apply an inputs combination:

  1. Double-click the row with the desired inputs combination.
  2. In the dialog box that appears, click Yes to apply the input combination, or click No to cancel.

Note: Once a new inputs combination is applied to the strategy, the portfolio will have to be backtested again.


3D Optimization Charts

3D Optimization Chart is a visual representation of how the strategy's parameters affect its trading performance. The 3D graph reveals the most robust parameter zones, and is a great tool for avoiding over-optimization (curve-fitting). Robust parameter zones will appear to have gradual, rather then abrupt changes in the surface plot. Over-optimized zones will appear to have radical changes or spikes in the surface plot.

To view the 3D Optimization Chart, click the View 3D Optimization Chart Portfolio 3D.png button at the bottom left of the report window.

A 3D Chart will be displayed in the 3D Optimization Charts window.


Exporting Strategy Optimization Reports

Strategy Optimization Report can be exported to a standard .csv (comma-separated values) file. The .csv file can then be imported into a spreadsheet application for further analysis.

To export the Optimization Report:

  1. Click the Export button at the bottom left of the of the report window.
  2. In the Save Strategy Optimization Report As dialog box that appears, navigate to the desired location, enter the file name, and click the Save button.