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}
278
279impl Debug for StreamingPriceField {
280 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
281 let field_name = match self {
282 StreamingPriceField::MidOpen => "MID_OPEN",
283 StreamingPriceField::High => "HIGH",
284 StreamingPriceField::Low => "LOW",
285 StreamingPriceField::BidQuoteId => "BIDQUOTEID",
286 StreamingPriceField::AskQuoteId => "ASKQUOTEID",
287 StreamingPriceField::BidPrice1 => "BIDPRICE1",
288 StreamingPriceField::BidPrice2 => "BIDPRICE2",
289 StreamingPriceField::BidPrice3 => "BIDPRICE3",
290 StreamingPriceField::BidPrice4 => "BIDPRICE4",
291 StreamingPriceField::BidPrice5 => "BIDPRICE5",
292 StreamingPriceField::AskPrice1 => "ASKPRICE1",
293 StreamingPriceField::AskPrice2 => "ASKPRICE2",
294 StreamingPriceField::AskPrice3 => "ASKPRICE3",
295 StreamingPriceField::AskPrice4 => "ASKPRICE4",
296 StreamingPriceField::AskPrice5 => "ASKPRICE5",
297 StreamingPriceField::BidSize1 => "BIDSIZE1",
298 StreamingPriceField::BidSize2 => "BIDSIZE2",
299 StreamingPriceField::BidSize3 => "BIDSIZE3",
300 StreamingPriceField::BidSize4 => "BIDSIZE4",
301 StreamingPriceField::BidSize5 => "BIDSIZE5",
302 StreamingPriceField::AskSize1 => "ASKSIZE1",
303 StreamingPriceField::AskSize2 => "ASKSIZE2",
304 StreamingPriceField::AskSize3 => "ASKSIZE3",
305 StreamingPriceField::AskSize4 => "ASKSIZE4",
306 StreamingPriceField::AskSize5 => "ASKSIZE5",
307 StreamingPriceField::Currency0 => "CURRENCY0",
308 StreamingPriceField::Currency1 => "CURRENCY1",
309 StreamingPriceField::C1BidSize1 => "C1BIDSIZE1",
310 StreamingPriceField::C1BidSize2 => "C1BIDSIZE2",
311 StreamingPriceField::C1BidSize3 => "C1BIDSIZE3",
312 StreamingPriceField::C1BidSize4 => "C1BIDSIZE4",
313 StreamingPriceField::C1BidSize5 => "C1BIDSIZE5",
314 StreamingPriceField::C1AskSize1 => "C1ASKSIZE1",
315 StreamingPriceField::C1AskSize2 => "C1ASKSIZE2",
316 StreamingPriceField::C1AskSize3 => "C1ASKSIZE3",
317 StreamingPriceField::C1AskSize4 => "C1ASKSIZE4",
318 StreamingPriceField::C1AskSize5 => "C1ASKSIZE5",
319 StreamingPriceField::Currency2 => "CURRENCY2",
320 StreamingPriceField::C2BidSize1 => "C2BIDSIZE1",
321 StreamingPriceField::C2BidSize2 => "C2BIDSIZE2",
322 StreamingPriceField::C2BidSize3 => "C2BIDSIZE3",
323 StreamingPriceField::C2BidSize4 => "C2BIDSIZE4",
324 StreamingPriceField::C2BidSize5 => "C2BIDSIZE5",
325 StreamingPriceField::C2AskSize1 => "C2ASKSIZE1",
326 StreamingPriceField::C2AskSize2 => "C2ASKSIZE2",
327 StreamingPriceField::C2AskSize3 => "C2ASKSIZE3",
328 StreamingPriceField::C2AskSize4 => "C2ASKSIZE4",
329 StreamingPriceField::C2AskSize5 => "C2ASKSIZE5",
330 StreamingPriceField::Currency3 => "CURRENCY3",
331 StreamingPriceField::C3BidSize1 => "C3BIDSIZE1",
332 StreamingPriceField::C3BidSize2 => "C3BIDSIZE2",
333 StreamingPriceField::C3BidSize3 => "C3BIDSIZE3",
334 StreamingPriceField::C3BidSize4 => "C3BIDSIZE4",
335 StreamingPriceField::C3BidSize5 => "C3BIDSIZE5",
336 StreamingPriceField::C3AskSize1 => "C3ASKSIZE1",
337 StreamingPriceField::C3AskSize2 => "C3ASKSIZE2",
338 StreamingPriceField::C3AskSize3 => "C3ASKSIZE3",
339 StreamingPriceField::C3AskSize4 => "C3ASKSIZE4",
340 StreamingPriceField::C3AskSize5 => "C3ASKSIZE5",
341 StreamingPriceField::Currency4 => "CURRENCY4",
342 StreamingPriceField::C4BidSize1 => "C4BIDSIZE1",
343 StreamingPriceField::C4BidSize2 => "C4BIDSIZE2",
344 StreamingPriceField::C4BidSize3 => "C4BIDSIZE3",
345 StreamingPriceField::C4BidSize4 => "C4BIDSIZE4",
346 StreamingPriceField::C4BidSize5 => "C4BIDSIZE5",
347 StreamingPriceField::C4AskSize1 => "C4ASKSIZE1",
348 StreamingPriceField::C4AskSize2 => "C4ASKSIZE2",
349 StreamingPriceField::C4AskSize3 => "C4ASKSIZE3",
350 StreamingPriceField::C4AskSize4 => "C4ASKSIZE4",
351 StreamingPriceField::C4AskSize5 => "C4ASKSIZE5",
352 StreamingPriceField::Currency5 => "CURRENCY5",
353 StreamingPriceField::C5BidSize1 => "C5BIDSIZE1",
354 StreamingPriceField::C5BidSize2 => "C5BIDSIZE2",
355 StreamingPriceField::C5BidSize3 => "C5BIDSIZE3",
356 StreamingPriceField::C5BidSize4 => "C5BIDSIZE4",
357 StreamingPriceField::C5BidSize5 => "C5BIDSIZE5",
358 StreamingPriceField::C5AskSize1 => "C5ASKSIZE1",
359 StreamingPriceField::C5AskSize2 => "C5ASKSIZE2",
360 StreamingPriceField::C5AskSize3 => "C5ASKSIZE3",
361 StreamingPriceField::C5AskSize4 => "C5ASKSIZE4",
362 StreamingPriceField::C5AskSize5 => "C5ASKSIZE5",
363 StreamingPriceField::Timestamp => "TIMESTAMP",
364 StreamingPriceField::DlgFlag => "DLG_FLAG",
365 };
366 write!(f, "{}", field_name)
367 }
368}
369
370impl Display for StreamingPriceField {
371 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
372 write!(f, "{:?}", self)
373 }
374}
375
376pub(crate) fn get_streaming_price_fields(fields: &HashSet<StreamingPriceField>) -> Vec<String> {
391 let map_field = |f: &StreamingPriceField| -> &'static str {
393 match f {
394 StreamingPriceField::MidOpen => "MID_OPEN",
396 StreamingPriceField::High => "HIGH",
397 StreamingPriceField::Low => "LOW",
398 StreamingPriceField::BidQuoteId => "BIDQUOTEID",
399 StreamingPriceField::AskQuoteId => "ASKQUOTEID",
400
401 StreamingPriceField::BidPrice1 => "BIDPRICE1",
403 StreamingPriceField::BidPrice2 => "BIDPRICE2",
404 StreamingPriceField::BidPrice3 => "BIDPRICE3",
405 StreamingPriceField::BidPrice4 => "BIDPRICE4",
406 StreamingPriceField::BidPrice5 => "BIDPRICE5",
407
408 StreamingPriceField::AskPrice1 => "ASKPRICE1",
410 StreamingPriceField::AskPrice2 => "ASKPRICE2",
411 StreamingPriceField::AskPrice3 => "ASKPRICE3",
412 StreamingPriceField::AskPrice4 => "ASKPRICE4",
413 StreamingPriceField::AskPrice5 => "ASKPRICE5",
414
415 StreamingPriceField::BidSize1 => "BIDSIZE1",
417 StreamingPriceField::BidSize2 => "BIDSIZE2",
418 StreamingPriceField::BidSize3 => "BIDSIZE3",
419 StreamingPriceField::BidSize4 => "BIDSIZE4",
420 StreamingPriceField::BidSize5 => "BIDSIZE5",
421
422 StreamingPriceField::AskSize1 => "ASKSIZE1",
424 StreamingPriceField::AskSize2 => "ASKSIZE2",
425 StreamingPriceField::AskSize3 => "ASKSIZE3",
426 StreamingPriceField::AskSize4 => "ASKSIZE4",
427 StreamingPriceField::AskSize5 => "ASKSIZE5",
428
429 StreamingPriceField::Currency0 => "CURRENCY0",
431 StreamingPriceField::Currency1 => "CURRENCY1",
432 StreamingPriceField::Currency2 => "CURRENCY2",
433 StreamingPriceField::Currency3 => "CURRENCY3",
434 StreamingPriceField::Currency4 => "CURRENCY4",
435 StreamingPriceField::Currency5 => "CURRENCY5",
436
437 StreamingPriceField::C1BidSize1 => "C1BIDSIZE1",
439 StreamingPriceField::C1BidSize2 => "C1BIDSIZE2",
440 StreamingPriceField::C1BidSize3 => "C1BIDSIZE3",
441 StreamingPriceField::C1BidSize4 => "C1BIDSIZE4",
442 StreamingPriceField::C1BidSize5 => "C1BIDSIZE5",
443 StreamingPriceField::C1AskSize1 => "C1ASKSIZE1",
445 StreamingPriceField::C1AskSize2 => "C1ASKSIZE2",
446 StreamingPriceField::C1AskSize3 => "C1ASKSIZE3",
447 StreamingPriceField::C1AskSize4 => "C1ASKSIZE4",
448 StreamingPriceField::C1AskSize5 => "C1ASKSIZE5",
449
450 StreamingPriceField::C2BidSize1 => "C2BIDSIZE1",
452 StreamingPriceField::C2BidSize2 => "C2BIDSIZE2",
453 StreamingPriceField::C2BidSize3 => "C2BIDSIZE3",
454 StreamingPriceField::C2BidSize4 => "C2BIDSIZE4",
455 StreamingPriceField::C2BidSize5 => "C2BIDSIZE5",
456 StreamingPriceField::C2AskSize1 => "C2ASKSIZE1",
458 StreamingPriceField::C2AskSize2 => "C2ASKSIZE2",
459 StreamingPriceField::C2AskSize3 => "C2ASKSIZE3",
460 StreamingPriceField::C2AskSize4 => "C2ASKSIZE4",
461 StreamingPriceField::C2AskSize5 => "C2ASKSIZE5",
462
463 StreamingPriceField::C3BidSize1 => "C3BIDSIZE1",
465 StreamingPriceField::C3BidSize2 => "C3BIDSIZE2",
466 StreamingPriceField::C3BidSize3 => "C3BIDSIZE3",
467 StreamingPriceField::C3BidSize4 => "C3BIDSIZE4",
468 StreamingPriceField::C3BidSize5 => "C3BIDSIZE5",
469 StreamingPriceField::C3AskSize1 => "C3ASKSIZE1",
471 StreamingPriceField::C3AskSize2 => "C3ASKSIZE2",
472 StreamingPriceField::C3AskSize3 => "C3ASKSIZE3",
473 StreamingPriceField::C3AskSize4 => "C3ASKSIZE4",
474 StreamingPriceField::C3AskSize5 => "C3ASKSIZE5",
475
476 StreamingPriceField::C4BidSize1 => "C4BIDSIZE1",
478 StreamingPriceField::C4BidSize2 => "C4BIDSIZE2",
479 StreamingPriceField::C4BidSize3 => "C4BIDSIZE3",
480 StreamingPriceField::C4BidSize4 => "C4BIDSIZE4",
481 StreamingPriceField::C4BidSize5 => "C4BIDSIZE5",
482 StreamingPriceField::C4AskSize1 => "C4ASKSIZE1",
484 StreamingPriceField::C4AskSize2 => "C4ASKSIZE2",
485 StreamingPriceField::C4AskSize3 => "C4ASKSIZE3",
486 StreamingPriceField::C4AskSize4 => "C4ASKSIZE4",
487 StreamingPriceField::C4AskSize5 => "C4ASKSIZE5",
488
489 StreamingPriceField::C5BidSize1 => "C5BIDSIZE1",
491 StreamingPriceField::C5BidSize2 => "C5BIDSIZE2",
492 StreamingPriceField::C5BidSize3 => "C5BIDSIZE3",
493 StreamingPriceField::C5BidSize4 => "C5BIDSIZE4",
494 StreamingPriceField::C5BidSize5 => "C5BIDSIZE5",
495 StreamingPriceField::C5AskSize1 => "C5ASKSIZE1",
497 StreamingPriceField::C5AskSize2 => "C5ASKSIZE2",
498 StreamingPriceField::C5AskSize3 => "C5ASKSIZE3",
499 StreamingPriceField::C5AskSize4 => "C5ASKSIZE4",
500 StreamingPriceField::C5AskSize5 => "C5ASKSIZE5",
501
502 StreamingPriceField::Timestamp => "TIMESTAMP",
504 StreamingPriceField::DlgFlag => "DLG_FLAG",
505 }
506 };
507
508 let mut fields_vec = Vec::with_capacity(fields.len());
509 for field in fields {
510 fields_vec.push(map_field(field).to_string());
511 }
512 fields_vec
513}
514
515#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Default, Hash)]
520#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
521pub enum StreamingAccountDataField {
522 #[default]
524 Pnl,
525 Deposit,
527 AvailableCash,
529 PnlLr,
531 PnlNlr,
533 Funds,
535 Margin,
537 MarginLr,
539 MarginNlr,
541 AvailableToDeal,
543 Equity,
545 EquityUsed,
547}
548
549impl Debug for StreamingAccountDataField {
550 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
551 let field_name = match self {
552 StreamingAccountDataField::Pnl => "PNL",
553 StreamingAccountDataField::Deposit => "DEPOSIT",
554 StreamingAccountDataField::AvailableCash => "AVAILABLE_CASH",
555 StreamingAccountDataField::PnlLr => "PNL_LR",
556 StreamingAccountDataField::PnlNlr => "PNL_NLR",
557 StreamingAccountDataField::Funds => "FUNDS",
558 StreamingAccountDataField::Margin => "MARGIN",
559 StreamingAccountDataField::MarginLr => "MARGIN_LR",
560 StreamingAccountDataField::MarginNlr => "MARGIN_NLR",
561 StreamingAccountDataField::AvailableToDeal => "AVAILABLE_TO_DEAL",
562 StreamingAccountDataField::Equity => "EQUITY",
563 StreamingAccountDataField::EquityUsed => "EQUITY_USED",
564 };
565 write!(f, "{}", field_name)
566 }
567}
568
569impl Display for StreamingAccountDataField {
570 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
571 write!(f, "{:?}", self)
572 }
573}
574
575pub(crate) fn get_streaming_account_data_fields(
590 fields: &HashSet<StreamingAccountDataField>,
591) -> Vec<String> {
592 let mut fields_vec = Vec::new();
593 for field in fields {
594 let val =
595 serde_json::to_value(field).expect("Failed to serialize StreamingAccountDataField");
596 match val {
597 serde_json::Value::String(s) => fields_vec.push(s),
598 _ => fields_vec.push(format!("{:?}", field)),
599 }
600 }
601 fields_vec
602}
603
604#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Default, Hash)]
609#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
610pub enum StreamingChartField {
611 #[default]
614 Ltv,
615 Ttv,
617 Utm,
619 DayOpenMid,
621 DayNetChgMid,
623 DayPercChgMid,
625 DayHigh,
627 DayLow,
629
630 Bid,
633 Ofr,
635 Ltp,
637
638 OfrOpen,
641 OfrHigh,
643 OfrLow,
645 OfrClose,
647 BidOpen,
649 BidHigh,
651 BidLow,
653 BidClose,
655 LtpOpen,
657 LtpHigh,
659 LtpLow,
661 LtpClose,
663 ConsEnd,
665 ConsTickCount,
667}
668
669impl std::fmt::Debug for StreamingChartField {
670 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
671 let name = match self {
672 StreamingChartField::Ltv => "LTV",
673 StreamingChartField::Ttv => "TTV",
674 StreamingChartField::Utm => "UTM",
675 StreamingChartField::DayOpenMid => "DAY_OPEN_MID",
676 StreamingChartField::DayNetChgMid => "DAY_NET_CHG_MID",
677 StreamingChartField::DayPercChgMid => "DAY_PERC_CHG_MID",
678 StreamingChartField::DayHigh => "DAY_HIGH",
679 StreamingChartField::DayLow => "DAY_LOW",
680
681 StreamingChartField::Bid => "BID",
682 StreamingChartField::Ofr => "OFR",
683 StreamingChartField::Ltp => "LTP",
684
685 StreamingChartField::OfrOpen => "OFR_OPEN",
686 StreamingChartField::OfrHigh => "OFR_HIGH",
687 StreamingChartField::OfrLow => "OFR_LOW",
688 StreamingChartField::OfrClose => "OFR_CLOSE",
689 StreamingChartField::BidOpen => "BID_OPEN",
690 StreamingChartField::BidHigh => "BID_HIGH",
691 StreamingChartField::BidLow => "BID_LOW",
692 StreamingChartField::BidClose => "BID_CLOSE",
693 StreamingChartField::LtpOpen => "LTP_OPEN",
694 StreamingChartField::LtpHigh => "LTP_HIGH",
695 StreamingChartField::LtpLow => "LTP_LOW",
696 StreamingChartField::LtpClose => "LTP_CLOSE",
697 StreamingChartField::ConsEnd => "CONS_END",
698 StreamingChartField::ConsTickCount => "CONS_TICK_COUNT",
699 };
700 write!(f, "{}", name)
701 }
702}
703
704impl std::fmt::Display for StreamingChartField {
705 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
706 write!(f, "{:?}", self)
707 }
708}
709
710pub(crate) fn get_streaming_chart_fields(fields: &HashSet<StreamingChartField>) -> Vec<String> {
724 let mut out = Vec::with_capacity(fields.len());
725 for field in fields {
726 let val = serde_json::to_value(field).expect("Failed to serialize StreamingChartField");
727 match val {
728 serde_json::Value::String(s) => out.push(s),
729 _ => out.push(format!("{:?}", field)),
730 }
731 }
732 out
733}
734
735#[cfg(test)]
736mod tests {
737 use super::*;
738
739 #[test]
740 fn test_streaming_market_field_default() {
741 let field = StreamingMarketField::default();
742 assert_eq!(field, StreamingMarketField::Offer);
743 }
744
745 #[test]
746 fn test_streaming_market_field_debug() {
747 assert_eq!(format!("{:?}", StreamingMarketField::Bid), "BID");
748 assert_eq!(format!("{:?}", StreamingMarketField::Offer), "OFFER");
749 assert_eq!(format!("{:?}", StreamingMarketField::High), "HIGH");
750 assert_eq!(format!("{:?}", StreamingMarketField::Low), "LOW");
751 assert_eq!(format!("{:?}", StreamingMarketField::Change), "CHANGE");
752 assert_eq!(
753 format!("{:?}", StreamingMarketField::ChangePct),
754 "CHANGE_PCT"
755 );
756 assert_eq!(
757 format!("{:?}", StreamingMarketField::UpdateTime),
758 "UPDATE_TIME"
759 );
760 assert_eq!(
761 format!("{:?}", StreamingMarketField::MarketDelay),
762 "MARKET_DELAY"
763 );
764 assert_eq!(
765 format!("{:?}", StreamingMarketField::MarketState),
766 "MARKET_STATE"
767 );
768 assert_eq!(format!("{:?}", StreamingMarketField::MidOpen), "MID_OPEN");
769 }
770
771 #[test]
772 fn test_streaming_market_field_display() {
773 assert_eq!(format!("{}", StreamingMarketField::Bid), "BID");
774 assert_eq!(format!("{}", StreamingMarketField::Offer), "OFFER");
775 }
776
777 #[test]
778 fn test_get_streaming_market_fields_empty() {
779 let fields: HashSet<StreamingMarketField> = HashSet::new();
780 let result = get_streaming_market_fields(&fields);
781 assert!(result.is_empty());
782 }
783
784 #[test]
785 fn test_get_streaming_market_fields_single() {
786 let mut fields = HashSet::new();
787 fields.insert(StreamingMarketField::Bid);
788 let result = get_streaming_market_fields(&fields);
789 assert_eq!(result.len(), 1);
790 assert!(result.contains(&"BID".to_string()));
791 }
792
793 #[test]
794 fn test_get_streaming_market_fields_multiple() {
795 let mut fields = HashSet::new();
796 fields.insert(StreamingMarketField::Bid);
797 fields.insert(StreamingMarketField::Offer);
798 fields.insert(StreamingMarketField::High);
799 let result = get_streaming_market_fields(&fields);
800 assert_eq!(result.len(), 3);
801 assert!(result.contains(&"BID".to_string()));
802 assert!(result.contains(&"OFFER".to_string()));
803 assert!(result.contains(&"HIGH".to_string()));
804 }
805
806 #[test]
807 fn test_streaming_price_field_default() {
808 let field = StreamingPriceField::default();
809 assert_eq!(field, StreamingPriceField::AskPrice5);
810 }
811
812 #[test]
813 fn test_streaming_price_field_debug() {
814 assert_eq!(format!("{:?}", StreamingPriceField::High), "HIGH");
815 assert_eq!(format!("{:?}", StreamingPriceField::Low), "LOW");
816 assert_eq!(format!("{:?}", StreamingPriceField::MidOpen), "MID_OPEN");
817 assert_eq!(format!("{:?}", StreamingPriceField::BidPrice1), "BIDPRICE1");
818 assert_eq!(format!("{:?}", StreamingPriceField::AskPrice1), "ASKPRICE1");
819 }
820
821 #[test]
822 fn test_streaming_price_field_display() {
823 assert_eq!(format!("{}", StreamingPriceField::High), "HIGH");
824 assert_eq!(format!("{}", StreamingPriceField::BidPrice1), "BIDPRICE1");
825 }
826
827 #[test]
828 fn test_streaming_account_field_default() {
829 let field = StreamingAccountDataField::default();
830 assert_eq!(field, StreamingAccountDataField::Pnl);
831 }
832
833 #[test]
834 fn test_streaming_account_field_debug() {
835 assert_eq!(format!("{:?}", StreamingAccountDataField::Pnl), "PNL");
836 assert_eq!(
837 format!("{:?}", StreamingAccountDataField::Deposit),
838 "DEPOSIT"
839 );
840 assert_eq!(format!("{:?}", StreamingAccountDataField::Margin), "MARGIN");
841 assert_eq!(format!("{:?}", StreamingAccountDataField::Equity), "EQUITY");
842 }
843
844 #[test]
845 fn test_streaming_account_field_display() {
846 assert_eq!(format!("{}", StreamingAccountDataField::Pnl), "PNL");
847 assert_eq!(format!("{}", StreamingAccountDataField::Equity), "EQUITY");
848 }
849
850 #[test]
851 fn test_get_streaming_account_fields_empty() {
852 let fields: HashSet<StreamingAccountDataField> = HashSet::new();
853 let result = get_streaming_account_data_fields(&fields);
854 assert!(result.is_empty());
855 }
856
857 #[test]
858 fn test_get_streaming_account_fields_multiple() {
859 let mut fields = HashSet::new();
860 fields.insert(StreamingAccountDataField::Pnl);
861 fields.insert(StreamingAccountDataField::Equity);
862 let result = get_streaming_account_data_fields(&fields);
863 assert_eq!(result.len(), 2);
864 assert!(result.contains(&"PNL".to_string()));
865 assert!(result.contains(&"EQUITY".to_string()));
866 }
867
868 #[test]
869 fn test_streaming_chart_field_default() {
870 let field = StreamingChartField::default();
871 assert_eq!(field, StreamingChartField::Ltv);
872 }
873
874 #[test]
875 fn test_streaming_chart_field_debug() {
876 assert_eq!(format!("{:?}", StreamingChartField::Bid), "BID");
877 assert_eq!(format!("{:?}", StreamingChartField::Ofr), "OFR");
878 assert_eq!(format!("{:?}", StreamingChartField::Ltp), "LTP");
879 assert_eq!(format!("{:?}", StreamingChartField::Ltv), "LTV");
880 assert_eq!(format!("{:?}", StreamingChartField::Utm), "UTM");
881 assert_eq!(format!("{:?}", StreamingChartField::DayHigh), "DAY_HIGH");
882 assert_eq!(format!("{:?}", StreamingChartField::DayLow), "DAY_LOW");
883 }
884
885 #[test]
886 fn test_streaming_chart_field_display() {
887 assert_eq!(format!("{}", StreamingChartField::Bid), "BID");
888 assert_eq!(format!("{}", StreamingChartField::Ofr), "OFR");
889 }
890
891 #[test]
892 fn test_get_streaming_chart_fields_empty() {
893 let fields: HashSet<StreamingChartField> = HashSet::new();
894 let result = get_streaming_chart_fields(&fields);
895 assert!(result.is_empty());
896 }
897
898 #[test]
899 fn test_get_streaming_chart_fields_multiple() {
900 let mut fields = HashSet::new();
901 fields.insert(StreamingChartField::Bid);
902 fields.insert(StreamingChartField::Ofr);
903 fields.insert(StreamingChartField::Ltp);
904 let result = get_streaming_chart_fields(&fields);
905 assert_eq!(result.len(), 3);
906 assert!(result.contains(&"BID".to_string()));
907 assert!(result.contains(&"OFR".to_string()));
908 assert!(result.contains(&"LTP".to_string()));
909 }
910
911 #[test]
912 fn test_streaming_market_field_serialization() {
913 let field = StreamingMarketField::Bid;
914 let json = serde_json::to_string(&field).expect("serialize failed");
915 assert_eq!(json, "\"BID\"");
916
917 let deserialized: StreamingMarketField =
918 serde_json::from_str(&json).expect("deserialize failed");
919 assert_eq!(deserialized, StreamingMarketField::Bid);
920 }
921
922 #[test]
923 fn test_streaming_account_field_serialization() {
924 let field = StreamingAccountDataField::Pnl;
925 let json = serde_json::to_string(&field).expect("serialize failed");
926 assert_eq!(json, "\"PNL\"");
927
928 let deserialized: StreamingAccountDataField =
929 serde_json::from_str(&json).expect("deserialize failed");
930 assert_eq!(deserialized, StreamingAccountDataField::Pnl);
931 }
932
933 #[test]
934 fn test_streaming_chart_field_serialization() {
935 let field = StreamingChartField::Bid;
936 let json = serde_json::to_string(&field).expect("serialize failed");
937 assert_eq!(json, "\"BID\"");
938
939 let deserialized: StreamingChartField =
940 serde_json::from_str(&json).expect("deserialize failed");
941 assert_eq!(deserialized, StreamingChartField::Bid);
942 }
943
944 #[test]
945 fn test_streaming_market_field_equality() {
946 let field1 = StreamingMarketField::Bid;
947 let field2 = StreamingMarketField::Bid;
948 let field3 = StreamingMarketField::Offer;
949
950 assert_eq!(field1, field2);
951 assert_ne!(field1, field3);
952 }
953
954 #[test]
955 fn test_streaming_market_field_hash() {
956 let mut set = HashSet::new();
957 set.insert(StreamingMarketField::Bid);
958 set.insert(StreamingMarketField::Bid); assert_eq!(set.len(), 1);
961 }
962
963 #[test]
964 fn test_streaming_market_field_clone() {
965 let field = StreamingMarketField::High;
966 let cloned = field.clone();
967 assert_eq!(field, cloned);
968 }
969}