mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
optimizer: print equity diff in final report
This commit is contained in:
parent
30978ecbd4
commit
3c0d5727e6
|
@ -30,6 +30,16 @@ var TotalVolume = func(summaryReport *backtest.SummaryReport) fixedpoint.Value {
|
||||||
return buyVolume.Add(sellVolume)
|
return buyVolume.Add(sellVolume)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
type Metric struct {
|
type Metric struct {
|
||||||
// Labels is the labels of the given parameters
|
// Labels is the labels of the given parameters
|
||||||
Labels []string `json:"labels,omitempty"`
|
Labels []string `json:"labels,omitempty"`
|
||||||
|
@ -186,8 +196,9 @@ func (o *GridOptimizer) Run(executor Executor, configJson []byte) (map[string][]
|
||||||
o.CurrentParams = make([]interface{}, len(o.Config.Matrix))
|
o.CurrentParams = make([]interface{}, len(o.Config.Matrix))
|
||||||
|
|
||||||
var valueFunctions = map[string]MetricValueFunc{
|
var valueFunctions = map[string]MetricValueFunc{
|
||||||
"totalProfit": TotalProfitMetricValueFunc,
|
"totalProfit": TotalProfitMetricValueFunc,
|
||||||
"totalVolume": TotalVolume,
|
"totalVolume": TotalVolume,
|
||||||
|
"totalEquityDiff": TotalEquityDiff,
|
||||||
}
|
}
|
||||||
var metrics = map[string][]Metric{}
|
var metrics = map[string][]Metric{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user