optimize

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package optimize implements the parameter-optimization study type. It evaluates strategy parameter combinations across cross-validation splits, ranks them by out-of-sample performance, and produces a report with rankings, per-fold detail for the best combination, and an overfitting diagnostic comparing in-sample versus out-of-sample scores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Optimizer

type Optimizer struct {
	// contains filtered or unexported fields
}

Optimizer is a study.Study that evaluates strategy parameter combinations across cross-validation splits and ranks them by out-of-sample performance.

func New

func New(splits []study.Split, opts ...Option) *Optimizer

New creates an Optimizer for the given cross-validation splits. Default objective is Sharpe; default topN is 10.

func (*Optimizer) Analyze

func (opt *Optimizer) Analyze(results []study.RunResult) (report.Report, error)

Analyze processes all RunResults, groups them by combination and split, ranks by out-of-sample objective score, and builds the optimization report.

func (*Optimizer) Configurations

func (opt *Optimizer) Configurations(_ context.Context) ([]study.RunConfig, error)

Configurations returns a single RunConfig whose date range spans the earliest start and latest end across all configured splits.

func (*Optimizer) Description

func (opt *Optimizer) Description() string

Description returns a short explanation of what the study does.

func (*Optimizer) Name

func (opt *Optimizer) Name() string

Name returns the human-readable study name.

type Option

type Option func(*Optimizer)

Option configures an Optimizer.

func WithBaseParams added in v0.9.1

func WithBaseParams(params map[string]string) Option

WithBaseParams sets parameter values applied to every parameter combination before the swept value is overlaid. Use this to fix non-swept strategy flags (e.g. when sweeping --sector-cap but pinning --top-holdings to a specific value).

func WithObjective

func WithObjective(metric portfolio.Rankable) Option

WithObjective sets the metric used to rank parameter combinations.

func WithTopN

func WithTopN(topN int) Option

WithTopN sets the number of top combinations to include in the equity curve section of the report.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL