deribit_http/model/
tradingview.rs1use pretty_simple_display::{DebugPretty, DisplaySimple};
7use serde::{Deserialize, Serialize};
8
9#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
11pub struct TradingViewChartData {
12 pub status: String,
14 pub ticks: Vec<u64>,
16 pub open: Vec<f64>,
18 pub high: Vec<f64>,
20 pub low: Vec<f64>,
22 pub close: Vec<f64>,
24 pub volume: Vec<f64>,
26 pub cost: Vec<f64>,
28}
29
30impl TradingViewChartData {
31 pub fn new() -> Self {
33 Self {
34 status: "ok".to_string(),
35 ticks: Vec::new(),
36 open: Vec::new(),
37 high: Vec::new(),
38 low: Vec::new(),
39 close: Vec::new(),
40 volume: Vec::new(),
41 cost: Vec::new(),
42 }
43 }
44
45 #[allow(clippy::too_many_arguments)]
47 pub fn add_candle(
48 &mut self,
49 timestamp: u64,
50 open: f64,
51 high: f64,
52 low: f64,
53 close: f64,
54 volume: f64,
55 cost: f64,
56 ) {
57 self.ticks.push(timestamp);
58 self.open.push(open);
59 self.high.push(high);
60 self.low.push(low);
61 self.close.push(close);
62 self.volume.push(volume);
63 self.cost.push(cost);
64 }
65}
66
67impl Default for TradingViewChartData {
68 fn default() -> Self {
69 Self::new()
70 }
71}