opt

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShowNum = 600
)

Variables

View Source
var (
	MapCalcOptBest = map[string]FnCalcOptBest{
		"score":   getBestByScore,
		"good3":   optGood3,
		"good0t3": optGood0t3,
		"goodAvg": optGoodMa,
		"good1t4": optGood1t4,
		"good4":   optGood4,

		"good2":    optGood2,
		"good5":    optGood5,
		"good7":    optGood7,
		"good2t5":  optGood2t5,
		"good3t7":  optGood3t7,
		"good0t7":  optGood0t7,
		"good3t10": optGood3t10,
	}
	DefCalcOptBest = "good3"
)
View Source
var (
	PairPickers = make(map[string]func(r *BTResult) []string)
)

Functions

func CollectOptLog

func CollectOptLog(args *config.CmdArgs) *errs.Error

CollectOptLog Collect and analyze the logs generated by RunOptimize Sorts all policy tasks in reverse score order of output. 收集分析RunOptimize生成的日志 将所有策略任务按分数倒序排列输出。

func CompareExgBTOrders

func CompareExgBTOrders(args []string)

CompareExgBTOrders Compare the exchange export order records with the backtest order records. 对比交易所导出订单记录和回测订单记录。

func DescGroups

func DescGroups(items []*OptInfo) ([]*OptInfo, []*OptInfo)

DescGroups Divide the parameter group into profit and loss groups, both in descending order of scores; Return: Profit group, loss group 将参数组划分为盈利和亏损两组,都按分数降序;返回:盈利组,亏损组

func DumpLineGraph added in v0.1.9

func DumpLineGraph(path, title string, label []string, prec float64, tplData []byte, items []*ChartDs) *errs.Error

func RunBTOverOpt

func RunBTOverOpt(args *config.CmdArgs) *errs.Error

RunBTOverOpt Backtesting mode based on continuous parameter tuning. Approach the real situation and avoid using future information to adjust parameters for backtesting. 基于持续调参的回测模式。接近实盘情况,避免使用未来信息调参回测。

func RunOptimize

func RunOptimize(args *config.CmdArgs) *errs.Error

func RunRollBTPicker

func RunRollBTPicker(args *config.CmdArgs) *errs.Error

Types

type BTResult

type BTResult struct {
	MaxOpenOrders   int     `json:"maxOpenOrders"`
	MinReal         float64 `json:"minReal"`
	MaxReal         float64 `json:"maxReal"`         // Maximum Assets 最大资产
	MaxDrawDownPct  float64 `json:"maxDrawDownPct"`  // Maximum drawdown percentage 最大回撤百分比
	ShowDrawDownPct float64 `json:"showDrawDownPct"` // Displays the maximum drawdown percentage 显示最大回撤百分比
	BarNum          int     `json:"barNum"`
	TimeNum         int     `json:"timeNum"`
	OrderNum        int     `json:"orderNum"`

	Plots        *PlotData  `json:"plots"`
	StartMS      int64      `json:"startMS"`
	EndMS        int64      `json:"endMS"`
	PlotEvery    int        `json:"plotEvery"`
	TotalInvest  float64    `json:"totalInvest"`
	OutDir       string     `json:"outDir"`
	PairGrps     []*RowItem `json:"pairGrps"`
	DateGrps     []*RowItem `json:"dateGrps"`
	EnterGrps    []*RowItem `json:"enterGrps"`
	ExitGrps     []*RowItem `json:"exitGrps"`
	ProfitGrps   []*RowItem `json:"profitGrps"`
	TotProfit    float64    `json:"totProfit"`
	TotCost      float64    `json:"totCost"`
	TotFee       float64    `json:"totFee"`
	TotProfitPct float64    `json:"totProfitPct"`
	SharpeRatio  float64    `json:"sharpeRatio"`
	SortinoRatio float64    `json:"sortinoRatio"`
	// contains filtered or unexported fields
}

func NewBTResult

func NewBTResult() *BTResult

func (*BTResult) BriefLine

func (r *BTResult) BriefLine() string

func (*BTResult) Collect

func (r *BTResult) Collect()

func (*BTResult) Score

func (r *BTResult) Score() float64

type BackTest

type BackTest struct {
	biz.Trader
	*BTResult
	// contains filtered or unexported fields
}

func NewBackTest

func NewBackTest(isOpt bool, outDir string) *BackTest

func (*BackTest) FeedKLine

func (b *BackTest) FeedKLine(bar *orm.InfoKline)

func (*BackTest) Init

func (b *BackTest) Init() *errs.Error

func (*BackTest) Run

func (b *BackTest) Run()

type ChartDs added in v0.1.9

type ChartDs struct {
	Label           string    `json:"label"`
	Data            []float64 `json:"data"`
	Color           string    `json:"color,omitempty"`
	BorderColor     string    `json:"borderColor,omitempty"`
	BackgroundColor string    `json:"backgroundColor,omitempty"`
	YAxisID         string    `json:"yAxisID,omitempty"`
	Hidden          bool      `json:"hidden"`
}

type FnCalcOptBest

type FnCalcOptBest = func(items []*OptInfo) *OptInfo

type FuncOptTask

type FuncOptTask func(params map[string]float64) (float64, *errs.Error)

type GroupScore

type GroupScore struct {
	Items []*config.RunPolicyConfig
	Score float64
}

type LineGraph added in v0.1.9

type LineGraph struct {
	TplData   []byte
	Precision float64
	Title     string     `json:"title"`
	Labels    []string   `json:"labels"`
	Datasets  []*ChartDs `json:"datasets"`
}

func (*LineGraph) Dump added in v0.1.9

func (g *LineGraph) Dump() ([]byte, *errs.Error)

func (*LineGraph) DumpFile added in v0.1.9

func (g *LineGraph) DumpFile(path string) *errs.Error

type OptGroup

type OptGroup struct {
	Items []*OptInfo
	Score float64
	Name  string
	Pair  string
	TFStr string
}

type OptInfo

type OptInfo struct {
	Dirt   string
	ID     string
	Score  float64
	Params map[string]float64
	*BTResult
}

func AvgGoodDesc

func AvgGoodDesc(items []*OptInfo, startRate float64, endRate float64) *OptInfo

AvgGoodDesc For profitable groups, cut the specified range in descending order of scores and take the average of the parameters 对盈利的组,按分数降序,截取指定范围,取参数平均值

func (*OptInfo) ToLine

func (o *OptInfo) ToLine() string

func (*OptInfo) ToPol

func (o *OptInfo) ToPol(name, dirt, tfStr, pairStr string) *config.RunPolicyConfig

type PlotData

type PlotData struct {
	Labels        []string  `json:"labels"`
	OdNum         []int     `json:"odNum"`
	Real          []float64 `json:"real"`
	Available     []float64 `json:"available"`
	Profit        []float64 `json:"profit"`
	UnrealizedPOL []float64 `json:"unrealizedPOL"`
	WithDraw      []float64 `json:"withDraw"`
	// contains filtered or unexported fields
}

type RowItem

type RowItem struct {
	Title string `json:"title"`
	RowPart
}

type RowPart

type RowPart struct {
	WinCount     int               `json:"winCount"`
	ProfitSum    float64           `json:"profitSum"`
	ProfitPctSum float64           `json:"profitPctSum"`
	CostSum      float64           `json:"costSum"`
	Durations    []int             `json:"durations"`
	Orders       []*orm.InOutOrder `json:"-"`
	Sharpe       float64           `json:"sharpe"` // 夏普比率
	Sortino      float64           `json:"sortino"`
}

type ValItem

type ValItem struct {
	Tag   string
	Score float64
	Order int
	Res   int
}

Jump to

Keyboard shortcuts

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