mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +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)
|
||||
}
|
||||
|
||||
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 {
|
||||
// Labels is the labels of the given parameters
|
||||
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))
|
||||
|
||||
var valueFunctions = map[string]MetricValueFunc{
|
||||
"totalProfit": TotalProfitMetricValueFunc,
|
||||
"totalVolume": TotalVolume,
|
||||
"totalProfit": TotalProfitMetricValueFunc,
|
||||
"totalVolume": TotalVolume,
|
||||
"totalEquityDiff": TotalEquityDiff,
|
||||
}
|
||||
var metrics = map[string][]Metric{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user