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)
|
||||
}
|
||||
|
||||
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"`
|
||||
|
@ -188,6 +198,7 @@ func (o *GridOptimizer) Run(executor Executor, configJson []byte) (map[string][]
|
|||
var valueFunctions = map[string]MetricValueFunc{
|
||||
"totalProfit": TotalProfitMetricValueFunc,
|
||||
"totalVolume": TotalVolume,
|
||||
"totalEquityDiff": TotalEquityDiff,
|
||||
}
|
||||
var metrics = map[string][]Metric{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user