isolate record reading and writing from processing
All checks were successful
Tests / tests (pull_request) Successful in 17s

This commit is contained in:
2025-11-13 14:07:08 +00:00
parent d3fa025a92
commit 70bd8622de
9 changed files with 301 additions and 171 deletions

31
internal/stdout.go Normal file
View File

@@ -0,0 +1,31 @@
package internal
import (
"fmt"
"io"
"os"
"time"
)
type ReportLogger struct {
counter int
writer io.Writer
}
func NewStdOutLogger() *ReportLogger {
return &ReportLogger{
writer: os.Stdout,
}
}
func NewReportLogger(w io.Writer) *ReportLogger {
return &ReportLogger{
writer: w,
}
}
func (rl *ReportLogger) Write(ri ReportItem) error {
rl.counter++
_, err := fmt.Fprintf(rl.writer, "%6d - realised %+f on %s\n", rl.counter, ri.RealisedPnL(), ri.SellTimestamp.Format(time.RFC3339))
return err
}