tradingview/live/handler/
utils.rs1#[macro_export]
3macro_rules! cmd_msg {
4 ($value:expr) => {
5 CommandMsg {
6 inner: ustr::ustr($value),
7 }
8 };
9}
10
11#[macro_export]
13macro_rules! quote_cmd {
14 ($session:expr, $($symbol:expr),+ $(,)?) => {
15 QuoteCommandMsg {
16 quote_session: ustr::ustr($session),
17 symbols: vec![$(ustr::ustr($symbol)),+],
18 }
19 };
20}
21
22#[macro_export]
24macro_rules! chart_series_cmd {
25 (
26 session: $session:expr,
27 series_id: $series_id:expr,
28 symbol_series_id: $symbol_series_id:expr,
29 series_identifier: $series_identifier:expr,
30 interval: $interval:expr,
31 bar_count: $bar_count:expr
32 $(, range: $range:expr)?
33 ) => {
34 ChartSeriesCommandMsg {
35 chart_session: ustr::ustr($session),
36 series_identifier: ustr::ustr($series_identifier),
37 series_id: ustr::ustr($series_id),
38 symbol_series_id: ustr::ustr($symbol_series_id),
39 interval: $interval,
40 bar_count: $bar_count,
41 range: None $(.or(Some($range)))?,
42 }
43 };
44}
45
46#[macro_export]
48macro_rules! resolve_symbol_cmd {
49 (
50 session: $session:expr,
51 symbol_series_id: $symbol_series_id:expr,
52 instrument: $instrument:expr
53 $(, adjustment: $adjustment:expr)?
54 $(, currency: $currency:expr)?
55 $(, session_type: $session_type:expr)?
56 $(, replay_session: $replay_session:expr)?
57 ) => {
58 ResolveSymbolCommandMsg {
59 session: ustr::ustr($session),
60 symbol_series_id: ustr::ustr($symbol_series_id),
61 instrument: ustr::ustr($instrument),
62 adjustment: None $(.or(Some($adjustment)))?,
63 currency: None $(.or(Some($currency)))?,
64 session_type: None $(.or(Some($session_type)))?,
65 replay_session: None $(.or(Some(ustr::ustr($replay_session))))?,
66 }
67 };
68}
69
70#[macro_export]
72macro_rules! study_cmd {
73 (
74 session: $session:expr,
75 study_ids: [$id1:expr, $id2:expr],
76 chart_series_id: $chart_series_id:expr,
77 study: $study:expr
78 ) => {
79 StudyCommandMsg {
80 chart_session: ustr::ustr($session),
81 study_ids: [ustr::ustr($id1), ustr::ustr($id2)],
82 chart_series_id: ustr::ustr($chart_series_id),
83 study: $study,
84 }
85 };
86}
87
88#[macro_export]
90macro_rules! replay_series_cmd {
91 (
92 session: $session:expr,
93 series_id: $series_id:expr,
94 instrument: $instrument:expr,
95 interval: $interval:expr
96 $(, adjustment: $adjustment:expr)?
97 $(, currency: $currency:expr)?
98 $(, session_type: $session_type:expr)?
99 ) => {
100 AddReplaySeriesCommandMsg {
101 chart_session: ustr::ustr($session),
102 series_id: ustr::ustr($series_id),
103 instrument: ustr::ustr($instrument),
104 interval: $interval,
105 adjustment: None $(.or(Some($adjustment)))?,
106 currency: None $(.or(Some($currency)))?,
107 session_type: None $(.or(Some($session_type)))?,
108 }
109 };
110}
111
112#[macro_export]
114macro_rules! session_term_cmd {
115 ($session:expr, $id:expr) => {
116 SessionTerminationCommandMsg {
117 chart_session: ustr::ustr($session),
118 id: ustr::ustr($id),
119 }
120 };
121}
122
123#[macro_export]
125macro_rules! locale_cmd {
126 ($lang:expr, $country:expr) => {
127 SetLocaleCommandMsg {
128 language: ustr::ustr($lang),
129 country: ustr::ustr($country),
130 }
131 };
132}
133
134#[macro_export]
136macro_rules! timezone_cmd {
137 ($session:expr, $timezone:expr) => {
138 SetTimeZoneCommandMsg {
139 chart_session: ustr::ustr($session),
140 timezone: $timezone,
141 }
142 };
143}