optimizer

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: AGPL-3.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TotalEquityDiff = func(summaryReport *backtest.SummaryReport) fixedpoint.Value {
	if len(summaryReport.SymbolReports) == 0 {
		return fixedpoint.Zero
	}

	initEquity := summaryReport.SymbolReports[0].InitialEquityValue()
	finalEquity := summaryReport.SymbolReports[0].FinalEquityValue()
	return finalEquity.Sub(initEquity)
}
View Source
var TotalProfitMetricValueFunc = func(summaryReport *backtest.SummaryReport) fixedpoint.Value {
	return summaryReport.TotalProfit
}
View Source
var TotalVolume = func(summaryReport *backtest.SummaryReport) fixedpoint.Value {
	if len(summaryReport.SymbolReports) == 0 {
		return fixedpoint.Zero
	}

	buyVolume := summaryReport.SymbolReports[0].PnL.BuyVolume
	sellVolume := summaryReport.SymbolReports[0].PnL.SellVolume
	return buyVolume.Add(sellVolume)
}

Functions

This section is empty.

Types

type AsyncHandle added in v1.36.0

type AsyncHandle struct {
	Error  error
	Report *backtest.SummaryReport
	Done   chan struct{}
}

type BacktestTask added in v1.36.0

type BacktestTask struct {
	ConfigJson []byte
	Params     []interface{}
	Labels     []string
	Report     *backtest.SummaryReport
	Error      error
}

type Config

type Config struct {
	Executor  *ExecutorConfig  `json:"executor" yaml:"executor"`
	MaxThread int              `yaml:"maxThread,omitempty"`
	Matrix    []SelectorConfig `yaml:"matrix"`
}

func LoadConfig

func LoadConfig(yamlConfigFileName string) (*Config, error)

type Executor

type Executor interface {
	// Execute(configJson []byte) (*backtest.SummaryReport, error)
	Run(ctx context.Context, taskC chan BacktestTask, bar *pb.ProgressBar) (chan BacktestTask, error)
}

type ExecutorConfig added in v1.36.0

type ExecutorConfig struct {
	Type                string               `json:"type" yaml:"type"`
	LocalExecutorConfig *LocalExecutorConfig `json:"local" yaml:"local"`
}

type GridOptimizer

type GridOptimizer struct {
	Config *Config

	ParamLabels   []string
	CurrentParams []interface{}
}

func (*GridOptimizer) Run

func (o *GridOptimizer) Run(executor Executor, configJson []byte) (map[string][]Metric, error)

type LocalExecutorConfig added in v1.36.0

type LocalExecutorConfig struct {
	MaxNumberOfProcesses int `json:"maxNumberOfProcesses" yaml:"maxNumberOfProcesses"`
}

type LocalProcessExecutor

type LocalProcessExecutor struct {
	Config    *LocalExecutorConfig
	Bin       string
	WorkDir   string
	ConfigDir string
	OutputDir string
}

func (*LocalProcessExecutor) ExecuteAsync added in v1.36.0

func (e *LocalProcessExecutor) ExecuteAsync(configJson []byte) *AsyncHandle

func (*LocalProcessExecutor) Prepare added in v1.37.0

func (e *LocalProcessExecutor) Prepare(configJson []byte) error

Prepare prepares the environment for the following back tests this is a blocking operation

func (*LocalProcessExecutor) Run added in v1.36.0

func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask, bar *pb.ProgressBar) (chan BacktestTask, error)

type Metric

type Metric struct {
	// Labels is the labels of the given parameters
	Labels []string `json:"labels,omitempty"`

	// Params is the parameters used to output the metrics result
	Params []interface{} `json:"params,omitempty"`

	// Key is the metric name
	Key string `json:"key"`

	// Value is the metric value of the metric
	Value fixedpoint.Value `json:"value,omitempty"`
}

type MetricValueFunc

type MetricValueFunc func(summaryReport *backtest.SummaryReport) fixedpoint.Value

type OpFunc

type OpFunc func(configJson []byte, next func(configJson []byte) error) error

type SelectorConfig

type SelectorConfig struct {
	Type   string           `json:"type" yaml:"type"`
	Label  string           `json:"label,omitempty" yaml:"label,omitempty"`
	Path   string           `json:"path" yaml:"path"`
	Values []string         `json:"values,omitempty" yaml:"values,omitempty"`
	Min    fixedpoint.Value `json:"min,omitempty" yaml:"min,omitempty"`
	Max    fixedpoint.Value `json:"max,omitempty" yaml:"max,omitempty"`
	Step   fixedpoint.Value `json:"step,omitempty" yaml:"step,omitempty"`
}

Jump to

Keyboard shortcuts

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