1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
7#[serde(rename_all = "camelCase")]
8pub struct Symbol {
9 pub symbol: String,
10 pub name: String,
11 #[serde(default)]
12 pub currency: Option<String>,
13 #[serde(default)]
14 pub exchange: Option<String>,
15 #[serde(default)]
16 pub exchange_short_name: Option<String>,
17}
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
21#[serde(rename_all = "lowercase")]
22pub enum Period {
23 Annual,
24 Quarter,
25}
26
27impl std::fmt::Display for Period {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 match self {
30 Period::Annual => write!(f, "annual"),
31 Period::Quarter => write!(f, "quarter"),
32 }
33 }
34}
35
36#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38pub enum Timeframe {
39 OneMinute,
40 FiveMinutes,
41 FifteenMinutes,
42 ThirtyMinutes,
43 OneHour,
44 FourHours,
45}
46
47impl std::fmt::Display for Timeframe {
48 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 match self {
50 Timeframe::OneMinute => write!(f, "1min"),
51 Timeframe::FiveMinutes => write!(f, "5min"),
52 Timeframe::FifteenMinutes => write!(f, "15min"),
53 Timeframe::ThirtyMinutes => write!(f, "30min"),
54 Timeframe::OneHour => write!(f, "1hour"),
55 Timeframe::FourHours => write!(f, "4hour"),
56 }
57 }
58}
59
60#[derive(Debug, Clone, Serialize)]
62pub struct Pagination {
63 #[serde(skip_serializing_if = "Option::is_none")]
64 pub page: Option<u32>,
65 #[serde(skip_serializing_if = "Option::is_none")]
66 pub limit: Option<u32>,
67}
68
69impl Pagination {
70 pub fn new() -> Self {
71 Self {
72 page: None,
73 limit: None,
74 }
75 }
76
77 pub fn with_page(mut self, page: u32) -> Self {
78 self.page = Some(page);
79 self
80 }
81
82 pub fn with_limit(mut self, limit: u32) -> Self {
83 self.limit = Some(limit);
84 self
85 }
86}
87
88impl Default for Pagination {
89 fn default() -> Self {
90 Self::new()
91 }
92}
93
94#[derive(Debug, Clone, Serialize)]
96pub struct DateRange {
97 #[serde(skip_serializing_if = "Option::is_none")]
98 pub from: Option<String>,
99 #[serde(skip_serializing_if = "Option::is_none")]
100 pub to: Option<String>,
101}
102
103impl DateRange {
104 pub fn new() -> Self {
105 Self {
106 from: None,
107 to: None,
108 }
109 }
110
111 pub fn from(mut self, date: impl Into<String>) -> Self {
112 self.from = Some(date.into());
113 self
114 }
115
116 pub fn to(mut self, date: impl Into<String>) -> Self {
117 self.to = Some(date.into());
118 self
119 }
120}
121
122impl Default for DateRange {
123 fn default() -> Self {
124 Self::new()
125 }
126}