2
0

bar.go 495 B

1234567891011121314151617181920
  1. package sentio
  2. import (
  3. "cmp"
  4. "time"
  5. )
  6. type Bar struct {
  7. Datetime time.Time `json:"datetime" yaml:"datetime"`
  8. Open float64 `json:"open" yaml:"open"`
  9. High float64 `json:"high" yaml:"high"`
  10. Low float64 `json:"low" yaml:"low"`
  11. Close float64 `json:"close" yaml:"close"`
  12. Volume float64 `json:"volume" yaml:"volume"`
  13. Trades int `json:"trades" yaml:"trades"`
  14. }
  15. func CompareBars(a, b Bar) int {
  16. return cmp.Compare(a.Datetime.Unix(), b.Datetime.Unix())
  17. }