feat: 添加K线图功能 - interactive_chart + 多币种切换 + 技术指标(MA/EMA/BOLL/VOL)
This commit is contained in:
38
flutter_monisuo/lib/models/candle.dart
Normal file
38
flutter_monisuo/lib/models/candle.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
/// K 线数据模型
|
||||
class Candle {
|
||||
final int timestamp; // 毫秒时间戳
|
||||
final double open;
|
||||
final double high;
|
||||
final double low;
|
||||
final double close;
|
||||
final double volume;
|
||||
|
||||
const Candle({
|
||||
required this.timestamp,
|
||||
required this.open,
|
||||
required this.high,
|
||||
required this.low,
|
||||
required this.close,
|
||||
required this.volume,
|
||||
});
|
||||
|
||||
factory Candle.fromJson(Map<String, dynamic> json) {
|
||||
return Candle(
|
||||
timestamp: json['timestamp'] as int? ?? json['time'] as int? ?? 0,
|
||||
open: (json['open'] as num?)?.toDouble() ?? 0,
|
||||
high: (json['high'] as num?)?.toDouble() ?? 0,
|
||||
low: (json['low'] as num?)?.toDouble() ?? 0,
|
||||
close: (json['close'] as num?)?.toDouble() ?? 0,
|
||||
volume: (json['volume'] as num?)?.toDouble() ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'timestamp': timestamp,
|
||||
'open': open,
|
||||
'high': high,
|
||||
'low': low,
|
||||
'close': close,
|
||||
'volume': volume,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user