optmize

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: AGPL-3.0 Imports: 44 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"
)

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 added in v0.1.7

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 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 added in v0.1.7

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

Types

type BTResult

type BTResult struct {
	MaxOpenOrders   int
	MinReal         float64
	MaxReal         float64 // Maximum Assets 最大资产
	MaxDrawDownPct  float64 // Maximum drawdown percentage 最大回撤百分比
	ShowDrawDownPct float64 // Displays the maximum drawdown percentage 显示最大回撤百分比
	BarNum          int
	TimeNum         int
	OrderNum        int

	Plots        *PlotData
	StartMS      int64
	EndMS        int64
	PlotEvery    int
	TotalInvest  float64
	OutDir       string
	PairGrps     []*RowItem
	TotProfit    float64
	TotCost      float64
	TotFee       float64
	TotProfitPct float64
	SharpeRatio  float64
	SortinoRatio float64
	// contains filtered or unexported fields
}

func NewBTResult

func NewBTResult() *BTResult

func (*BTResult) BriefLine added in v0.1.7

func (r *BTResult) BriefLine() string

func (*BTResult) Collect added in v0.1.7

func (r *BTResult) Collect()

func (*BTResult) Score added in v0.1.7

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 FnCalcOptBest added in v0.1.7

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 OptGroup

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

type OptInfo

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

func AvgGoodDesc added in v0.1.7

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 added in v0.1.7

func (o *OptInfo) ToLine() string

func (*OptInfo) ToPol added in v0.1.7

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

type PlotData

type PlotData struct {
	Labels        []string
	OdNum         []int
	Real          []float64
	Available     []float64
	UnrealizedPOL []float64
	WithDraw      []float64
	// contains filtered or unexported fields
}

type RowItem

type RowItem struct {
	Title string
	RowPart
}

type RowPart

type RowPart struct {
	WinCount     int
	ProfitSum    float64
	ProfitPctSum float64
	CostSum      float64
	Durations    []int
	Orders       []*orm.InOutOrder
	Sharpe       float64 // 夏普比率
	Sortino      float64
}

type ValItem added in v0.1.7

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