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 {
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
Symbol string `json:"symbol,omitempty"`
LastPrice fixedpoint.Value `json:"lastPrice,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
// userConfig.Backtest.StartTime = now.AddDate(0, -6, 0).Format("2006-01-02")
if userConfig.Backtest.EndTime != nil {
endTime = userConfig.Backtest.EndTime.Time()
} else {
endTime = now
}
_ = endTime
log.Infof("starting backtest with startTime %s", startTime.Format(time.ANSIC))
@ -468,6 +466,8 @@ var BacktestCmd = &cobra.Command{
if jsonOutputEnabled {
result := backtest.Report{
StartTime: startTime,
EndTime: endTime,
Symbol: symbol,
LastPrice: lastPrice,
StartPrice: startPrice,