add start time and end time to the report struct

This commit is contained in:
c9s 2022-05-10 01:06:16 +08:00
parent 555e2581a0
commit 5b443f0aeb
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 4 additions and 2 deletions

View File

@ -11,6 +11,8 @@ import (
) )
type Report struct { type Report struct {
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
Symbol string `json:"symbol,omitempty"` Symbol string `json:"symbol,omitempty"`
LastPrice fixedpoint.Value `json:"lastPrice,omitempty"` LastPrice fixedpoint.Value `json:"lastPrice,omitempty"`
StartPrice fixedpoint.Value `json:"startPrice,omitempty"` StartPrice fixedpoint.Value `json:"startPrice,omitempty"`

View File

@ -150,13 +150,11 @@ var BacktestCmd = &cobra.Command{
// set default start time to the past 6 months // set default start time to the past 6 months
// userConfig.Backtest.StartTime = now.AddDate(0, -6, 0).Format("2006-01-02") // userConfig.Backtest.StartTime = now.AddDate(0, -6, 0).Format("2006-01-02")
if userConfig.Backtest.EndTime != nil { if userConfig.Backtest.EndTime != nil {
endTime = userConfig.Backtest.EndTime.Time() endTime = userConfig.Backtest.EndTime.Time()
} else { } else {
endTime = now endTime = now
} }
_ = endTime
log.Infof("starting backtest with startTime %s", startTime.Format(time.ANSIC)) log.Infof("starting backtest with startTime %s", startTime.Format(time.ANSIC))
@ -468,6 +466,8 @@ var BacktestCmd = &cobra.Command{
if jsonOutputEnabled { if jsonOutputEnabled {
result := backtest.Report{ result := backtest.Report{
StartTime: startTime,
EndTime: endTime,
Symbol: symbol, Symbol: symbol,
LastPrice: lastPrice, LastPrice: lastPrice,
StartPrice: startPrice, StartPrice: startPrice,