KLineEntity.fromJson constructor

KLineEntity.fromJson(
  1. Map<String, dynamic> json
)

Implementation

KLineEntity.fromJson(Map<String, dynamic> json) {
  open = json['open']?.toDouble() ?? 0;
  high = json['high']?.toDouble() ?? 0;
  low = json['low']?.toDouble() ?? 0;
  close = json['close']?.toDouble() ?? 0;
  vol = json['vol']?.toDouble() ?? 0;
  amount = json['amount']?.toDouble() ?? 0;
  int? tempTime = json['time']?.toInt();
  //兼容火币数据
  if (tempTime == null) {
    tempTime = json['id']?.toInt() ?? 0;
    tempTime = tempTime! * 1000;
  }
  time = tempTime;
  ratio = json['ratio']?.toDouble() ?? 0;
  change = json['change']?.toDouble() ?? 0;
  mac_high = json['high_ma']?.toDouble() ?? 0;
  mac_upper = json['mac_upper']?.toDouble() ?? 0;
  mac_low = json['mac_low']?.toDouble() ?? 0;
  mac_lower = json['mac_lower']?.toDouble() ?? 0;
  mac_high_1 = json['mac_high_1']?.toDouble() ?? 0;
  mac_upper_1 = json['mac_upper_1']?.toDouble() ?? 0;
  mac_low_1 = json['mac_low_1']?.toDouble() ?? 0;
  mac_lower_1 = json['mac_lower_1']?.toDouble() ?? 0;
  rsi = json['rsi']?.toDouble() ?? 0;
  rsi_signal = json['rsi_signal']?.toDouble() ?? 0;
  rsi_flag = json['rsi_flag'];
  stochastic_kd_flag = json['stochastic_kd_flag'];

  moving_average = json['ma']?.toDouble() ?? 0;
  top_box = json['top_box']?.toDouble() ?? 0;
  bottom_box = json['bottom_box']?.toDouble() ?? 0;
}