1use crate::prelude::{Deserialize, Serialize};
16use std::collections::HashSet;
17use std::fmt::{Debug, Display};
18
19#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Default, Hash)]
24#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
25pub enum StreamingMarketField {
26 MidOpen,
28 High,
30 Low,
32 Change,
34 ChangePct,
36 UpdateTime,
38 MarketDelay,
40 MarketState,
42 Bid,
44 #[default]
46 Offer,
47}
48
49impl Debug for StreamingMarketField {
50 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51 let field_name = match self {
52 StreamingMarketField::MidOpen => "MID_OPEN",
53 StreamingMarketField::High => "HIGH",
54 StreamingMarketField::Low => "LOW",
55 StreamingMarketField::Change => "CHANGE",
56 StreamingMarketField::ChangePct => "CHANGE_PCT",
57 StreamingMarketField::UpdateTime => "UPDATE_TIME",
58 StreamingMarketField::MarketDelay => "MARKET_DELAY",
59 StreamingMarketField::MarketState => "MARKET_STATE",
60 StreamingMarketField::Bid => "BID",
61 StreamingMarketField::Offer => "OFFER",
62 };
63 write!(f, "{}", field_name)
64 }
65}
66
67impl Display for StreamingMarketField {
68 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 write!(f, "{:?}", self)
70 }
71}
72
73pub(crate) fn get_streaming_market_fields(fields: &HashSet<StreamingMarketField>) -> Vec<String> {
88 let mut fields_vec = Vec::new();
89 for field in fields {
90 let val = serde_json::to_value(field).expect("Failed to serialize StreamingMarketField");
92 match val {
93 serde_json::Value::String(s) => fields_vec.push(s),
94 _ => fields_vec.push(format!("{:?}", field)),
96 }
97 }
98 fields_vec
99}
100
101#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Default, Hash)]
106#[serde(rename_all = "UPPERCASE")]
107pub enum StreamingPriceField {
108 #[serde(rename = "MID_OPEN")]
110 MidOpen,
111 High,
113 Low,
115 BidQuoteId,
117 AskQuoteId,
119 BidPrice1,
121 BidPrice2,
123 BidPrice3,
125 BidPrice4,
127 BidPrice5,
129 AskPrice1,
131 AskPrice2,
133 AskPrice3,
135 AskPrice4,
137 #[default]
139 AskPrice5,
140 BidSize1,
142 BidSize2,
144 BidSize3,
146 BidSize4,
148 BidSize5,
150 AskSize1,
152 AskSize2,
154 AskSize3,
156 AskSize4,
158 AskSize5,
160 Currency0,
162 Currency1,
164 C1BidSize1,
166 C1BidSize2,
168 C1BidSize3,
170 C1BidSize4,
172 C1BidSize5,
174 C1AskSize1,
176 C1AskSize2,
178 C1AskSize3,
180 C1AskSize4,
182 C1AskSize5,
184 Currency2,
186 C2BidSize1,
188 C2BidSize2,
190 C2BidSize3,
192 C2BidSize4,
194 C2BidSize5,
196 C2AskSize1,
198 C2AskSize2,
200 C2AskSize3,
202 C2AskSize4,
204 C2AskSize5,
206 Currency3,
208 C3BidSize1,
210 C3BidSize2,
212 C3BidSize3,
214 C3BidSize4,
216 C3BidSize5,
218 C3AskSize1,
220 C3AskSize2,
222 C3AskSize3,
224 C3AskSize4,
226 C3AskSize5,
228 Currency4,
230 C4BidSize1,
232 C4BidSize2,
234 C4BidSize3,
236 C4BidSize4,
238 C4BidSize5,
240 C4AskSize1,
242 C4AskSize2,
244 C4AskSize3,
246 C4AskSize4,
248 C4AskSize5,
250 Currency5,
252 C5BidSize1,
254 C5BidSize2,
256 C5BidSize3,
258 C5BidSize4,
260 C5BidSize5,
262 C5AskSize1,
264 C5AskSize2,
266 C5AskSize3,
268 C5AskSize4,
270 C5AskSize5,
272 Timestamp,
274 #[serde(rename = "DLG_FLAG")]
276 DlgFlag,
277 #[serde(rename = "NET_CHG")]
279 NetChg,
280 #[serde(rename = "NET_CHG_PCT")]
282 NetChgPct,
283 Delay,
285}
286
287impl Debug for StreamingPriceField {
288 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
289 let field_name = match self {
290 StreamingPriceField::MidOpen => "MID_OPEN",
291 StreamingPriceField::High => "HIGH",
292 StreamingPriceField::Low => "LOW",
293 StreamingPriceField::BidQuoteId => "BIDQUOTEID",
294 StreamingPriceField::AskQuoteId => "ASKQUOTEID",
295 StreamingPriceField::BidPrice1 => "BIDPRICE1",
296 StreamingPriceField::BidPrice2 => "BIDPRICE2",
297 StreamingPriceField::BidPrice3 => "BIDPRICE3",
298 StreamingPriceField::BidPrice4 => "BIDPRICE4",
299 StreamingPriceField::BidPrice5 => "BIDPRICE5",
300 StreamingPriceField::AskPrice1 => "ASKPRICE1",
301 StreamingPriceField::AskPrice2 => "ASKPRICE2",
302 StreamingPriceField::AskPrice3 => "ASKPRICE3",
303 StreamingPriceField::AskPrice4 => "ASKPRICE4",
304 StreamingPriceField::AskPrice5 => "ASKPRICE5",
305 StreamingPriceField::BidSize1 => "BIDSIZE1",
306 StreamingPriceField::BidSize2 => "BIDSIZE2",
307 StreamingPriceField::BidSize3 => "BIDSIZE3",
308 StreamingPriceField::BidSize4 => "BIDSIZE4",
309 StreamingPriceField::BidSize5 => "BIDSIZE5",
310 StreamingPriceField::AskSize1 => "ASKSIZE1",
311 StreamingPriceField::AskSize2 => "ASKSIZE2",
312 StreamingPriceField::AskSize3 => "ASKSIZE3",
313 StreamingPriceField::AskSize4 => "ASKSIZE4",
314 StreamingPriceField::AskSize5 => "ASKSIZE5",
315 StreamingPriceField::Currency0 => "CURRENCY0",
316 StreamingPriceField::Currency1 => "CURRENCY1",
317 StreamingPriceField::C1BidSize1 => "C1BIDSIZE1",
318 StreamingPriceField::C1BidSize2 => "C1BIDSIZE2",
319 StreamingPriceField::C1BidSize3 => "C1BIDSIZE3",
320 StreamingPriceField::C1BidSize4 => "C1BIDSIZE4",
321 StreamingPriceField::C1BidSize5 => "C1BIDSIZE5",
322 StreamingPriceField::C1AskSize1 => "C1ASKSIZE1",
323 StreamingPriceField::C1AskSize2 => "C1ASKSIZE2",
324 StreamingPriceField::C1AskSize3 => "C1ASKSIZE3",
325 StreamingPriceField::C1AskSize4 => "C1ASKSIZE4",
326 StreamingPriceField::C1AskSize5 => "C1ASKSIZE5",
327 StreamingPriceField::Currency2 => "CURRENCY2",
328 StreamingPriceField::C2BidSize1 => "C2BIDSIZE1",
329 StreamingPriceField::C2BidSize2 => "C2BIDSIZE2",
330 StreamingPriceField::C2BidSize3 => "C2BIDSIZE3",
331 StreamingPriceField::C2BidSize4 => "C2BIDSIZE4",
332 StreamingPriceField::C2BidSize5 => "C2BIDSIZE5",
333 StreamingPriceField::C2AskSize1 => "C2ASKSIZE1",
334 StreamingPriceField::C2AskSize2 => "C2ASKSIZE2",
335 StreamingPriceField::C2AskSize3 => "C2ASKSIZE3",
336 StreamingPriceField::C2AskSize4 => "C2ASKSIZE4",
337 StreamingPriceField::C2AskSize5 => "C2ASKSIZE5",
338 StreamingPriceField::Currency3 => "CURRENCY3",
339 StreamingPriceField::C3BidSize1 => "C3BIDSIZE1",
340 StreamingPriceField::C3BidSize2 => "C3BIDSIZE2",
341 StreamingPriceField::C3BidSize3 => "C3BIDSIZE3",
342 StreamingPriceField::C3BidSize4 => "C3BIDSIZE4",
343 StreamingPriceField::C3BidSize5 => "C3BIDSIZE5",
344 StreamingPriceField::C3AskSize1 => "C3ASKSIZE1",
345 StreamingPriceField::C3AskSize2 => "C3ASKSIZE2",
346 StreamingPriceField::C3AskSize3 => "C3ASKSIZE3",
347 StreamingPriceField::C3AskSize4 => "C3ASKSIZE4",
348 StreamingPriceField::C3AskSize5 => "C3ASKSIZE5",
349 StreamingPriceField::Currency4 => "CURRENCY4",
350 StreamingPriceField::C4BidSize1 => "C4BIDSIZE1",
351 StreamingPriceField::C4BidSize2 => "C4BIDSIZE2",
352 StreamingPriceField::C4BidSize3 => "C4BIDSIZE3",
353 StreamingPriceField::C4BidSize4 => "C4BIDSIZE4",
354 StreamingPriceField::C4BidSize5 => "C4BIDSIZE5",
355 StreamingPriceField::C4AskSize1 => "C4ASKSIZE1",
356 StreamingPriceField::C4AskSize2 => "C4ASKSIZE2",
357 StreamingPriceField::C4AskSize3 => "C4ASKSIZE3",
358 StreamingPriceField::C4AskSize4 => "C4ASKSIZE4",
359 StreamingPriceField::C4AskSize5 => "C4ASKSIZE5",
360 StreamingPriceField::Currency5 => "CURRENCY5",
361 StreamingPriceField::C5BidSize1 => "C5BIDSIZE1",
362 StreamingPriceField::C5BidSize2 => "C5BIDSIZE2",
363 StreamingPriceField::C5BidSize3 => "C5BIDSIZE3",
364 StreamingPriceField::C5BidSize4 => "C5BIDSIZE4",
365 StreamingPriceField::C5BidSize5 => "C5BIDSIZE5",
366 StreamingPriceField::C5AskSize1 => "C5ASKSIZE1",
367 StreamingPriceField::C5AskSize2 => "C5ASKSIZE2",
368 StreamingPriceField::C5AskSize3 => "C5ASKSIZE3",
369 StreamingPriceField::C5AskSize4 => "C5ASKSIZE4",
370 StreamingPriceField::C5AskSize5 => "C5ASKSIZE5",
371 StreamingPriceField::Timestamp => "TIMESTAMP",
372 StreamingPriceField::DlgFlag => "DLG_FLAG",
373 StreamingPriceField::NetChg => "NET_CHG",
374 StreamingPriceField::NetChgPct => "NET_CHG_PCT",
375 StreamingPriceField::Delay => "DELAY",
376 };
377 write!(f, "{}", field_name)
378 }
379}
380
381impl Display for StreamingPriceField {
382 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
383 write!(f, "{:?}", self)
384 }
385}
386
387pub(crate) fn get_streaming_price_fields(fields: &HashSet<StreamingPriceField>) -> Vec<String> {
402 let map_field = |f: &StreamingPriceField| -> &'static str {
404 match f {
405 StreamingPriceField::MidOpen => "MID_OPEN",
407 StreamingPriceField::High => "HIGH",
408 StreamingPriceField::Low => "LOW",
409 StreamingPriceField::BidQuoteId => "BIDQUOTEID",
410 StreamingPriceField::AskQuoteId => "ASKQUOTEID",
411
412 StreamingPriceField::BidPrice1 => "BIDPRICE1",
414 StreamingPriceField::BidPrice2 => "BIDPRICE2",
415 StreamingPriceField::BidPrice3 => "BIDPRICE3",
416 StreamingPriceField::BidPrice4 => "BIDPRICE4",
417 StreamingPriceField::BidPrice5 => "BIDPRICE5",
418
419 StreamingPriceField::AskPrice1 => "ASKPRICE1",
421 StreamingPriceField::AskPrice2 => "ASKPRICE2",
422 StreamingPriceField::AskPrice3 => "ASKPRICE3",
423 StreamingPriceField::AskPrice4 => "ASKPRICE4",
424 StreamingPriceField::AskPrice5 => "ASKPRICE5",
425
426 StreamingPriceField::BidSize1 => "BIDSIZE1",
428 StreamingPriceField::BidSize2 => "BIDSIZE2",
429 StreamingPriceField::BidSize3 => "BIDSIZE3",
430 StreamingPriceField::BidSize4 => "BIDSIZE4",
431 StreamingPriceField::BidSize5 => "BIDSIZE5",
432
433 StreamingPriceField::AskSize1 => "ASKSIZE1",
435 StreamingPriceField::AskSize2 => "ASKSIZE2",
436 StreamingPriceField::AskSize3 => "ASKSIZE3",
437 StreamingPriceField::AskSize4 => "ASKSIZE4",
438 StreamingPriceField::AskSize5 => "ASKSIZE5",
439
440 StreamingPriceField::Currency0 => "CURRENCY0",
442 StreamingPriceField::Currency1 => "CURRENCY1",
443 StreamingPriceField::Currency2 => "CURRENCY2",
444 StreamingPriceField::Currency3 => "CURRENCY3",
445 StreamingPriceField::Currency4 => "CURRENCY4",
446 StreamingPriceField::Currency5 => "CURRENCY5",
447
448 StreamingPriceField::C1BidSize1 => "C1BIDSIZE1",
450 StreamingPriceField::C1BidSize2 => "C1BIDSIZE2",
451 StreamingPriceField::C1BidSize3 => "C1BIDSIZE3",
452 StreamingPriceField::C1BidSize4 => "C1BIDSIZE4",
453 StreamingPriceField::C1BidSize5 => "C1BIDSIZE5",
454 StreamingPriceField::C1AskSize1 => "C1ASKSIZE1",
456 StreamingPriceField::C1AskSize2 => "C1ASKSIZE2",
457 StreamingPriceField::C1AskSize3 => "C1ASKSIZE3",
458 StreamingPriceField::C1AskSize4 => "C1ASKSIZE4",
459 StreamingPriceField::C1AskSize5 => "C1ASKSIZE5",
460
461 StreamingPriceField::C2BidSize1 => "C2BIDSIZE1",
463 StreamingPriceField::C2BidSize2 => "C2BIDSIZE2",
464 StreamingPriceField::C2BidSize3 => "C2BIDSIZE3",
465 StreamingPriceField::C2BidSize4 => "C2BIDSIZE4",
466 StreamingPriceField::C2BidSize5 => "C2BIDSIZE5",
467 StreamingPriceField::C2AskSize1 => "C2ASKSIZE1",
469 StreamingPriceField::C2AskSize2 => "C2ASKSIZE2",
470 StreamingPriceField::C2AskSize3 => "C2ASKSIZE3",
471 StreamingPriceField::C2AskSize4 => "C2ASKSIZE4",
472 StreamingPriceField::C2AskSize5 => "C2ASKSIZE5",
473
474 StreamingPriceField::C3BidSize1 => "C3BIDSIZE1",
476 StreamingPriceField::C3BidSize2 => "C3BIDSIZE2",
477 StreamingPriceField::C3BidSize3 => "C3BIDSIZE3",
478 StreamingPriceField::C3BidSize4 => "C3BIDSIZE4",
479 StreamingPriceField::C3BidSize5 => "C3BIDSIZE5",
480 StreamingPriceField::C3AskSize1 => "C3ASKSIZE1",
482 StreamingPriceField::C3AskSize2 => "C3ASKSIZE2",
483 StreamingPriceField::C3AskSize3 => "C3ASKSIZE3",
484 StreamingPriceField::C3AskSize4 => "C3ASKSIZE4",
485 StreamingPriceField::C3AskSize5 => "C3ASKSIZE5",
486
487 StreamingPriceField::C4BidSize1 => "C4BIDSIZE1",
489 StreamingPriceField::C4BidSize2 => "C4BIDSIZE2",
490 StreamingPriceField::C4BidSize3 => "C4BIDSIZE3",
491 StreamingPriceField::C4BidSize4 => "C4BIDSIZE4",
492 StreamingPriceField::C4BidSize5 => "C4BIDSIZE5",
493 StreamingPriceField::C4AskSize1 => "C4ASKSIZE1",
495 StreamingPriceField::C4AskSize2 => "C4ASKSIZE2",
496 StreamingPriceField::C4AskSize3 => "C4ASKSIZE3",
497 StreamingPriceField::C4AskSize4 => "C4ASKSIZE4",
498 StreamingPriceField::C4AskSize5 => "C4ASKSIZE5",
499
500 StreamingPriceField::C5BidSize1 => "C5BIDSIZE1",
502 StreamingPriceField::C5BidSize2 => "C5BIDSIZE2",
503 StreamingPriceField::C5BidSize3 => "C5BIDSIZE3",
504 StreamingPriceField::C5BidSize4 => "C5BIDSIZE4",
505 StreamingPriceField::C5BidSize5 => "C5BIDSIZE5",
506 StreamingPriceField::C5AskSize1 => "C5ASKSIZE1",
508 StreamingPriceField::C5AskSize2 => "C5ASKSIZE2",
509 StreamingPriceField::C5AskSize3 => "C5ASKSIZE3",
510 StreamingPriceField::C5AskSize4 => "C5ASKSIZE4",
511 StreamingPriceField::C5AskSize5 => "C5ASKSIZE5",
512
513 StreamingPriceField::Timestamp => "TIMESTAMP",
515 StreamingPriceField::DlgFlag => "DLG_FLAG",
516 StreamingPriceField::NetChg => "NET_CHG",
517 StreamingPriceField::NetChgPct => "NET_CHG_PCT",
518 StreamingPriceField::Delay => "DELAY",
519 }
520 };
521
522 let mut fields_vec = Vec::with_capacity(fields.len());
523 for field in fields {
524 fields_vec.push(map_field(field).to_string());
525 }
526 fields_vec
527}
528
529#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Default, Hash)]
534#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
535pub enum StreamingAccountDataField {
536 #[default]
538 Pnl,
539 Deposit,
541 AvailableCash,
543 PnlLr,
545 PnlNlr,
547 Funds,
549 Margin,
551 MarginLr,
553 MarginNlr,
555 AvailableToDeal,
557 Equity,
559 EquityUsed,
561}
562
563impl Debug for StreamingAccountDataField {
564 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
565 let field_name = match self {
566 StreamingAccountDataField::Pnl => "PNL",
567 StreamingAccountDataField::Deposit => "DEPOSIT",
568 StreamingAccountDataField::AvailableCash => "AVAILABLE_CASH",
569 StreamingAccountDataField::PnlLr => "PNL_LR",
570 StreamingAccountDataField::PnlNlr => "PNL_NLR",
571 StreamingAccountDataField::Funds => "FUNDS",
572 StreamingAccountDataField::Margin => "MARGIN",
573 StreamingAccountDataField::MarginLr => "MARGIN_LR",
574 StreamingAccountDataField::MarginNlr => "MARGIN_NLR",
575 StreamingAccountDataField::AvailableToDeal => "AVAILABLE_TO_DEAL",
576 StreamingAccountDataField::Equity => "EQUITY",
577 StreamingAccountDataField::EquityUsed => "EQUITY_USED",
578 };
579 write!(f, "{}", field_name)
580 }
581}
582
583impl Display for StreamingAccountDataField {
584 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
585 write!(f, "{:?}", self)
586 }
587}
588
589pub(crate) fn get_streaming_account_data_fields(
604 fields: &HashSet<StreamingAccountDataField>,
605) -> Vec<String> {
606 let mut fields_vec = Vec::new();
607 for field in fields {
608 let val =
609 serde_json::to_value(field).expect("Failed to serialize StreamingAccountDataField");
610 match val {
611 serde_json::Value::String(s) => fields_vec.push(s),
612 _ => fields_vec.push(format!("{:?}", field)),
613 }
614 }
615 fields_vec
616}
617
618#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Default, Hash)]
623#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
624pub enum StreamingChartField {
625 #[default]
628 Ltv,
629 Ttv,
631 Utm,
633 DayOpenMid,
635 DayNetChgMid,
637 DayPercChgMid,
639 DayHigh,
641 DayLow,
643
644 Bid,
647 Ofr,
649 Ltp,
651
652 OfrOpen,
655 OfrHigh,
657 OfrLow,
659 OfrClose,
661 BidOpen,
663 BidHigh,
665 BidLow,
667 BidClose,
669 LtpOpen,
671 LtpHigh,
673 LtpLow,
675 LtpClose,
677 ConsEnd,
679 ConsTickCount,
681}
682
683impl std::fmt::Debug for StreamingChartField {
684 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
685 let name = match self {
686 StreamingChartField::Ltv => "LTV",
687 StreamingChartField::Ttv => "TTV",
688 StreamingChartField::Utm => "UTM",
689 StreamingChartField::DayOpenMid => "DAY_OPEN_MID",
690 StreamingChartField::DayNetChgMid => "DAY_NET_CHG_MID",
691 StreamingChartField::DayPercChgMid => "DAY_PERC_CHG_MID",
692 StreamingChartField::DayHigh => "DAY_HIGH",
693 StreamingChartField::DayLow => "DAY_LOW",
694
695 StreamingChartField::Bid => "BID",
696 StreamingChartField::Ofr => "OFR",
697 StreamingChartField::Ltp => "LTP",
698
699 StreamingChartField::OfrOpen => "OFR_OPEN",
700 StreamingChartField::OfrHigh => "OFR_HIGH",
701 StreamingChartField::OfrLow => "OFR_LOW",
702 StreamingChartField::OfrClose => "OFR_CLOSE",
703 StreamingChartField::BidOpen => "BID_OPEN",
704 StreamingChartField::BidHigh => "BID_HIGH",
705 StreamingChartField::BidLow => "BID_LOW",
706 StreamingChartField::BidClose => "BID_CLOSE",
707 StreamingChartField::LtpOpen => "LTP_OPEN",
708 StreamingChartField::LtpHigh => "LTP_HIGH",
709 StreamingChartField::LtpLow => "LTP_LOW",
710 StreamingChartField::LtpClose => "LTP_CLOSE",
711 StreamingChartField::ConsEnd => "CONS_END",
712 StreamingChartField::ConsTickCount => "CONS_TICK_COUNT",
713 };
714 write!(f, "{}", name)
715 }
716}
717
718impl std::fmt::Display for StreamingChartField {
719 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
720 write!(f, "{:?}", self)
721 }
722}
723
724pub(crate) fn get_streaming_chart_fields(fields: &HashSet<StreamingChartField>) -> Vec<String> {
738 let mut out = Vec::with_capacity(fields.len());
739 for field in fields {
740 let val = serde_json::to_value(field).expect("Failed to serialize StreamingChartField");
741 match val {
742 serde_json::Value::String(s) => out.push(s),
743 _ => out.push(format!("{:?}", field)),
744 }
745 }
746 out
747}
748
749#[cfg(test)]
750mod tests {
751 use super::*;
752
753 #[test]
754 fn test_streaming_market_field_default() {
755 let field = StreamingMarketField::default();
756 assert_eq!(field, StreamingMarketField::Offer);
757 }
758
759 #[test]
760 fn test_streaming_market_field_debug() {
761 assert_eq!(format!("{:?}", StreamingMarketField::Bid), "BID");
762 assert_eq!(format!("{:?}", StreamingMarketField::Offer), "OFFER");
763 assert_eq!(format!("{:?}", StreamingMarketField::High), "HIGH");
764 assert_eq!(format!("{:?}", StreamingMarketField::Low), "LOW");
765 assert_eq!(format!("{:?}", StreamingMarketField::Change), "CHANGE");
766 assert_eq!(
767 format!("{:?}", StreamingMarketField::ChangePct),
768 "CHANGE_PCT"
769 );
770 assert_eq!(
771 format!("{:?}", StreamingMarketField::UpdateTime),
772 "UPDATE_TIME"
773 );
774 assert_eq!(
775 format!("{:?}", StreamingMarketField::MarketDelay),
776 "MARKET_DELAY"
777 );
778 assert_eq!(
779 format!("{:?}", StreamingMarketField::MarketState),
780 "MARKET_STATE"
781 );
782 assert_eq!(format!("{:?}", StreamingMarketField::MidOpen), "MID_OPEN");
783 }
784
785 #[test]
786 fn test_streaming_market_field_display() {
787 assert_eq!(format!("{}", StreamingMarketField::Bid), "BID");
788 assert_eq!(format!("{}", StreamingMarketField::Offer), "OFFER");
789 }
790
791 #[test]
792 fn test_get_streaming_market_fields_empty() {
793 let fields: HashSet<StreamingMarketField> = HashSet::new();
794 let result = get_streaming_market_fields(&fields);
795 assert!(result.is_empty());
796 }
797
798 #[test]
799 fn test_get_streaming_market_fields_single() {
800 let mut fields = HashSet::new();
801 fields.insert(StreamingMarketField::Bid);
802 let result = get_streaming_market_fields(&fields);
803 assert_eq!(result.len(), 1);
804 assert!(result.contains(&"BID".to_string()));
805 }
806
807 #[test]
808 fn test_get_streaming_market_fields_multiple() {
809 let mut fields = HashSet::new();
810 fields.insert(StreamingMarketField::Bid);
811 fields.insert(StreamingMarketField::Offer);
812 fields.insert(StreamingMarketField::High);
813 let result = get_streaming_market_fields(&fields);
814 assert_eq!(result.len(), 3);
815 assert!(result.contains(&"BID".to_string()));
816 assert!(result.contains(&"OFFER".to_string()));
817 assert!(result.contains(&"HIGH".to_string()));
818 }
819
820 #[test]
821 fn test_streaming_price_field_default() {
822 let field = StreamingPriceField::default();
823 assert_eq!(field, StreamingPriceField::AskPrice5);
824 }
825
826 #[test]
827 fn test_streaming_price_field_debug() {
828 assert_eq!(format!("{:?}", StreamingPriceField::High), "HIGH");
829 assert_eq!(format!("{:?}", StreamingPriceField::Low), "LOW");
830 assert_eq!(format!("{:?}", StreamingPriceField::MidOpen), "MID_OPEN");
831 assert_eq!(format!("{:?}", StreamingPriceField::BidPrice1), "BIDPRICE1");
832 assert_eq!(format!("{:?}", StreamingPriceField::AskPrice1), "ASKPRICE1");
833 }
834
835 #[test]
836 fn test_streaming_price_field_display() {
837 assert_eq!(format!("{}", StreamingPriceField::High), "HIGH");
838 assert_eq!(format!("{}", StreamingPriceField::BidPrice1), "BIDPRICE1");
839 }
840
841 #[test]
842 fn test_streaming_account_field_default() {
843 let field = StreamingAccountDataField::default();
844 assert_eq!(field, StreamingAccountDataField::Pnl);
845 }
846
847 #[test]
848 fn test_streaming_account_field_debug() {
849 assert_eq!(format!("{:?}", StreamingAccountDataField::Pnl), "PNL");
850 assert_eq!(
851 format!("{:?}", StreamingAccountDataField::Deposit),
852 "DEPOSIT"
853 );
854 assert_eq!(format!("{:?}", StreamingAccountDataField::Margin), "MARGIN");
855 assert_eq!(format!("{:?}", StreamingAccountDataField::Equity), "EQUITY");
856 }
857
858 #[test]
859 fn test_streaming_account_field_display() {
860 assert_eq!(format!("{}", StreamingAccountDataField::Pnl), "PNL");
861 assert_eq!(format!("{}", StreamingAccountDataField::Equity), "EQUITY");
862 }
863
864 #[test]
865 fn test_get_streaming_account_fields_empty() {
866 let fields: HashSet<StreamingAccountDataField> = HashSet::new();
867 let result = get_streaming_account_data_fields(&fields);
868 assert!(result.is_empty());
869 }
870
871 #[test]
872 fn test_get_streaming_account_fields_multiple() {
873 let mut fields = HashSet::new();
874 fields.insert(StreamingAccountDataField::Pnl);
875 fields.insert(StreamingAccountDataField::Equity);
876 let result = get_streaming_account_data_fields(&fields);
877 assert_eq!(result.len(), 2);
878 assert!(result.contains(&"PNL".to_string()));
879 assert!(result.contains(&"EQUITY".to_string()));
880 }
881
882 #[test]
883 fn test_streaming_chart_field_default() {
884 let field = StreamingChartField::default();
885 assert_eq!(field, StreamingChartField::Ltv);
886 }
887
888 #[test]
889 fn test_streaming_chart_field_debug() {
890 assert_eq!(format!("{:?}", StreamingChartField::Bid), "BID");
891 assert_eq!(format!("{:?}", StreamingChartField::Ofr), "OFR");
892 assert_eq!(format!("{:?}", StreamingChartField::Ltp), "LTP");
893 assert_eq!(format!("{:?}", StreamingChartField::Ltv), "LTV");
894 assert_eq!(format!("{:?}", StreamingChartField::Utm), "UTM");
895 assert_eq!(format!("{:?}", StreamingChartField::DayHigh), "DAY_HIGH");
896 assert_eq!(format!("{:?}", StreamingChartField::DayLow), "DAY_LOW");
897 }
898
899 #[test]
900 fn test_streaming_chart_field_display() {
901 assert_eq!(format!("{}", StreamingChartField::Bid), "BID");
902 assert_eq!(format!("{}", StreamingChartField::Ofr), "OFR");
903 }
904
905 #[test]
906 fn test_get_streaming_chart_fields_empty() {
907 let fields: HashSet<StreamingChartField> = HashSet::new();
908 let result = get_streaming_chart_fields(&fields);
909 assert!(result.is_empty());
910 }
911
912 #[test]
913 fn test_get_streaming_chart_fields_multiple() {
914 let mut fields = HashSet::new();
915 fields.insert(StreamingChartField::Bid);
916 fields.insert(StreamingChartField::Ofr);
917 fields.insert(StreamingChartField::Ltp);
918 let result = get_streaming_chart_fields(&fields);
919 assert_eq!(result.len(), 3);
920 assert!(result.contains(&"BID".to_string()));
921 assert!(result.contains(&"OFR".to_string()));
922 assert!(result.contains(&"LTP".to_string()));
923 }
924
925 #[test]
926 fn test_streaming_market_field_serialization() {
927 let field = StreamingMarketField::Bid;
928 let json = serde_json::to_string(&field).expect("serialize failed");
929 assert_eq!(json, "\"BID\"");
930
931 let deserialized: StreamingMarketField =
932 serde_json::from_str(&json).expect("deserialize failed");
933 assert_eq!(deserialized, StreamingMarketField::Bid);
934 }
935
936 #[test]
937 fn test_streaming_account_field_serialization() {
938 let field = StreamingAccountDataField::Pnl;
939 let json = serde_json::to_string(&field).expect("serialize failed");
940 assert_eq!(json, "\"PNL\"");
941
942 let deserialized: StreamingAccountDataField =
943 serde_json::from_str(&json).expect("deserialize failed");
944 assert_eq!(deserialized, StreamingAccountDataField::Pnl);
945 }
946
947 #[test]
948 fn test_streaming_chart_field_serialization() {
949 let field = StreamingChartField::Bid;
950 let json = serde_json::to_string(&field).expect("serialize failed");
951 assert_eq!(json, "\"BID\"");
952
953 let deserialized: StreamingChartField =
954 serde_json::from_str(&json).expect("deserialize failed");
955 assert_eq!(deserialized, StreamingChartField::Bid);
956 }
957
958 #[test]
959 fn test_streaming_market_field_equality() {
960 let field1 = StreamingMarketField::Bid;
961 let field2 = StreamingMarketField::Bid;
962 let field3 = StreamingMarketField::Offer;
963
964 assert_eq!(field1, field2);
965 assert_ne!(field1, field3);
966 }
967
968 #[test]
969 fn test_streaming_market_field_hash() {
970 let mut set = HashSet::new();
971 set.insert(StreamingMarketField::Bid);
972 set.insert(StreamingMarketField::Bid); assert_eq!(set.len(), 1);
975 }
976
977 #[test]
978 fn test_streaming_market_field_clone() {
979 let field = StreamingMarketField::High;
980 let cloned = field.clone();
981 assert_eq!(field, cloned);
982 }
983}