kline_bar.dart 880 B

1234567891011121314151617181920212223242526272829303132333435
  1. /// K 线单根蜡烛数据(不可变)
  2. /// 实现 == / hashCode 让 Riverpod .select() 能正确判断列表数据是否变化。
  3. class KlineBar {
  4. final DateTime time;
  5. final double open;
  6. final double high;
  7. final double low;
  8. final double close;
  9. final double volume;
  10. const KlineBar({
  11. required this.time,
  12. required this.open,
  13. required this.high,
  14. required this.low,
  15. required this.close,
  16. required this.volume,
  17. });
  18. bool get isBull => close >= open;
  19. @override
  20. bool operator ==(Object other) =>
  21. identical(this, other) ||
  22. other is KlineBar &&
  23. time == other.time &&
  24. open == other.open &&
  25. high == other.high &&
  26. low == other.low &&
  27. close == other.close &&
  28. volume == other.volume;
  29. @override
  30. int get hashCode => Object.hash(time, open, high, low, close, volume);
  31. }