diff --git a/backtest/html_report.go b/backtest/html_report.go index ba9b6b8..fa6aee4 100644 --- a/backtest/html_report.go +++ b/backtest/html_report.go @@ -216,10 +216,7 @@ func (h *HTMLReport) writeAssetReport(name string, results []*htmlReportResult) defer helper.CloseAndLogError(file, "unable to close asset report file") - tmpl, err := template.New("report").Parse(htmlAssetReportTmpl) - if err != nil { - return fmt.Errorf("unable to initialize asset report template: %w", err) - } + tmpl := template.Must(template.New("report").Parse(htmlAssetReportTmpl)) err = tmpl.Execute(file, model) if err != nil { @@ -248,10 +245,7 @@ func (h *HTMLReport) writeReport() error { defer helper.CloseAndLogError(file, "unable to close main report file") - tmpl, err := template.New("report").Parse(htmlReportTmpl) - if err != nil { - return fmt.Errorf("unable to execute main report template: %w", err) - } + tmpl := template.Must(template.New("report").Parse(htmlReportTmpl)) err = tmpl.Execute(file, model) if err != nil { diff --git a/helper/README.md b/helper/README.md index 0d691b3..fffc3bb 100644 --- a/helper/README.md +++ b/helper/README.md @@ -38,6 +38,7 @@ The information provided on this project is strictly for informational purposes - [func CheckEquals\[T comparable\]\(inputs ...\<\-chan T\) error](<#CheckEquals>) - [func CloseAndLogError\(closer io.Closer, message string\)](<#CloseAndLogError>) - [func Count\[T Number, O any\]\(from T, other \<\-chan O\) \<\-chan T](<#Count>) +- [func DaysBetween\(from, to time.Time\) int](<#DaysBetween>) - [func DecrementBy\[T Number\]\(c \<\-chan T, d T\) \<\-chan T](<#DecrementBy>) - [func Divide\[T Number\]\(ac, bc \<\-chan T\) \<\-chan T](<#Divide>) - [func DivideBy\[T Number\]\(c \<\-chan T, d T\) \<\-chan T](<#DivideBy>) @@ -348,6 +349,15 @@ fmt.Println(<- s) // 3 fmt.Println(<- s) // 4 ``` + +## func [DaysBetween]() + +```go +func DaysBetween(from, to time.Time) int +``` + +DaysBetween calculates the days between the given two times. + ## func [DecrementBy]()