bbgo_origin/pkg/backtest/report.go

35 lines
1.1 KiB
Go
Raw Normal View History

2022-05-06 11:16:15 +00:00
package backtest
import (
2022-05-09 11:27:02 +00:00
"fmt"
"strings"
"time"
2022-05-06 11:16:15 +00:00
"github.com/c9s/bbgo/pkg/accounting/pnl"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
)
2022-05-09 10:03:03 +00:00
type Report struct {
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
2022-05-06 11:16:15 +00:00
Symbol string `json:"symbol,omitempty"`
LastPrice fixedpoint.Value `json:"lastPrice,omitempty"`
StartPrice fixedpoint.Value `json:"startPrice,omitempty"`
PnLReport *pnl.AverageCostPnlReport `json:"pnlReport,omitempty"`
InitialBalances types.BalanceMap `json:"initialBalances,omitempty"`
FinalBalances types.BalanceMap `json:"finalBalances,omitempty"`
}
2022-05-09 10:03:03 +00:00
2022-05-09 11:27:02 +00:00
const SessionTimeFormat = "2006-01-02T15_04"
// FormatSessionName returns the back-test session name
func FormatSessionName(sessions []string, symbols []string, startTime, endTime time.Time) string {
return fmt.Sprintf("%s_%s_%s-%s",
strings.Join(sessions, "-"),
strings.Join(symbols, "-"),
startTime.Format(SessionTimeFormat),
endTime.Format(SessionTimeFormat),
)
}