1use crate::constant::{Exchange, Interval};
5use crate::time::DtNs;
6
7#[derive(Debug, Clone, PartialEq, Default)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub struct BarData {
11 pub gateway_name: String,
13 pub symbol: String,
15 pub exchange: Exchange,
17 pub datetime: DtNs,
19
20 pub interval: Option<Interval>,
22 pub volume: f64,
24 pub turnover: f64,
26 pub open_interest: f64,
28 pub open_price: f64,
30 pub high_price: f64,
32 pub low_price: f64,
34 pub close_price: f64,
36 pub pct_change: f64,
38}
39
40impl BarData {
41 pub fn en_symbol(&self) -> String {
43 let mut buf = String::with_capacity(self.exchange.as_str().len() + 1 + self.symbol.len());
44 self.en_symbol_into(&mut buf);
45 buf
46 }
47
48 pub fn en_symbol_into(&self, buf: &mut String) {
50 crate::symbol::write_vt_symbol(buf, &self.symbol, self.exchange);
51 }
52}