1use std::fmt::Display;
3use std::fmt::{self, Error, Formatter};
4use strum_macros::EnumString;
5
6use num_derive::FromPrimitive;
7
8use serde::{Deserialize, Serialize};
9
10pub const NO_VALID_ID: i32 = -1;
11pub const MAX_MSG_LEN: i64 = 0xFFFFFF; pub const UNSET_INTEGER: i32 = std::i32::MAX;
14pub const UNSET_DOUBLE: f64 = 1.7976931348623157E308_f64;
15pub const UNSET_LONG: i64 = std::i64::MAX;
16pub const UNSET_INTEGER_I32_AS_I64: i64 = std::i32::MAX as i64;
17pub const UNSET_INTEGER_I32_AS_U64: u64 = std::i32::MAX as u64;
18
19#[repr(i32)]
22#[derive(EnumString, Serialize, Deserialize, Clone, Debug, FromPrimitive, Copy)]
23pub enum TickType {
24 BidSize = 0,
25 Bid = 1,
26 Ask = 2,
27 AskSize = 3,
28 Last = 4,
29 LastSize = 5,
30 High = 6,
31 Low = 7,
32 Volume = 8,
33 Close = 9,
34 BidOptionComputation = 10,
35 AskOptionComputation = 11,
36 LastOptionComputation = 12,
37 ModelOption = 13,
38 Open = 14,
39 Low13Week = 15,
40 High13Week = 16,
41 Low26Week = 17,
42 High26Week = 18,
43 Low52Week = 19,
44 High52Week = 20,
45 AvgVolume = 21,
46 OpenInterest = 22,
47 OptionHistoricalVol = 23,
48 OptionImpliedVol = 24,
49 OptionBidExch = 25,
50 OptionAskExch = 26,
51 OptionCallOpenInterest = 27,
52 OptionPutOpenInterest = 28,
53 OptionCallVolume = 29,
54 OptionPutVolume = 30,
55 IndexFuturePremium = 31,
56 BidExch = 32,
57 AskExch = 33,
58 AuctionVolume = 34,
59 AuctionPrice = 35,
60 AuctionImbalance = 36,
61 MarkPrice = 37,
62 BidEfpComputation = 38,
63 AskEfpComputation = 39,
64 LastEfpComputation = 40,
65 OpenEfpComputation = 41,
66 HighEfpComputation = 42,
67 LowEfpComputation = 43,
68 CloseEfpComputation = 44,
69 LastTimestamp = 45,
70 Shortable = 46,
71 FundamentalRatios = 47,
72 RtVolume = 48,
73 Halted = 49,
74 BidYield = 50,
75 AskYield = 51,
76 LastYield = 52,
77 CustOptionComputation = 53,
78 TradeCount = 54,
79 TradeRate = 55,
80 VolumeRate = 56,
81 LastRthTrade = 57,
82 RtHistoricalVol = 58,
83 IbDividends = 59,
84 BondFactorMultiplier = 60,
85 RegulatoryImbalance = 61,
86 NewsTick = 62,
87 ShortTermVolume3Min = 63,
88 ShortTermVolume5Min = 64,
89 ShortTermVolume10Min = 65,
90 DelayedBid = 66,
91 DelayedAsk = 67,
92 DelayedLast = 68,
93 DelayedBidSize = 69,
94 DelayedAskSize = 70,
95 DelayedLastSize = 71,
96 DelayedHigh = 72,
97 DelayedLow = 73,
98 DelayedVolume = 74,
99 DelayedClose = 75,
100 DelayedOpen = 76,
101 RtTrdVolume = 77,
102 CreditmanMarkPrice = 78,
103 CreditmanSlowMarkPrice = 79,
104 DelayedBidOption = 80,
105 DelayedAskOption = 81,
106 DelayedLastOption = 82,
107 DelayedModelOption = 83,
108 LastExch = 84,
109 LastRegTime = 85,
110 FuturesOpenInterest = 86,
111 AvgOptVolume = 87,
112 DelayedLastTimestamp = 88,
113 ShortableShares = 89,
114 NotSet = UNSET_INTEGER,
115}
116
117impl fmt::Display for TickType {
118 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
119 match *self {
120 TickType::BidSize => write!(fmt, "bidSize"),
121 TickType::Bid => write!(fmt, "bidPrice"),
122 TickType::Ask => write!(fmt, "askPrice"),
123 TickType::AskSize => write!(fmt, "askSize"),
124 TickType::Last => write!(fmt, "lastPrice"),
125 TickType::LastSize => write!(fmt, "lastSize"),
126 TickType::High => write!(fmt, "high"),
127 TickType::Low => write!(fmt, "low"),
128 TickType::Volume => write!(fmt, "volume"),
129 TickType::Close => write!(fmt, "close"),
130 TickType::BidOptionComputation => write!(fmt, "bidOptComp"),
131 TickType::AskOptionComputation => write!(fmt, "askOptComp"),
132 TickType::LastOptionComputation => write!(fmt, "lastOptComp"),
133 TickType::ModelOption => write!(fmt, "modelOptComp"),
134 TickType::Open => write!(fmt, "open"),
135 TickType::Low13Week => write!(fmt, "13WeekLow"),
136 TickType::High13Week => write!(fmt, "13WeekHigh"),
137 TickType::Low26Week => write!(fmt, "26WeekLow"),
138 TickType::High26Week => write!(fmt, "26WeekHigh"),
139 TickType::Low52Week => write!(fmt, "52WeekLow"),
140 TickType::High52Week => write!(fmt, "52WeekHigh"),
141 TickType::AvgVolume => write!(fmt, "AvgVolume"),
142 TickType::OpenInterest => write!(fmt, "OpenInterest"),
143 TickType::OptionHistoricalVol => write!(fmt, "OptionHistoricalVolatility"),
144 TickType::OptionImpliedVol => write!(fmt, "OptionImpliedVolatility"),
145 TickType::OptionBidExch => write!(fmt, "OptionBidExch"),
146 TickType::OptionAskExch => write!(fmt, "OptionAskExch"),
147 TickType::OptionCallOpenInterest => write!(fmt, "OptionCallOpenInterest"),
148 TickType::OptionPutOpenInterest => write!(fmt, "OptionPutOpenInterest"),
149 TickType::OptionCallVolume => write!(fmt, "OptionCallVolume"),
150 TickType::OptionPutVolume => write!(fmt, "OptionPutVolume"),
151 TickType::IndexFuturePremium => write!(fmt, "IndexFuturePremium"),
152 TickType::BidExch => write!(fmt, "bidExch"),
153 TickType::AskExch => write!(fmt, "askExch"),
154 TickType::AuctionVolume => write!(fmt, "auctionVolume"),
155 TickType::AuctionPrice => write!(fmt, "auctionPrice"),
156 TickType::AuctionImbalance => write!(fmt, "auctionImbalance"),
157 TickType::MarkPrice => write!(fmt, "markPrice"),
158 TickType::BidEfpComputation => write!(fmt, "bidEFP"),
159 TickType::AskEfpComputation => write!(fmt, "askEFP"),
160 TickType::LastEfpComputation => write!(fmt, "lastEFP"),
161 TickType::OpenEfpComputation => write!(fmt, "openEFP"),
162 TickType::HighEfpComputation => write!(fmt, "highEFP"),
163 TickType::LowEfpComputation => write!(fmt, "lowEFP"),
164 TickType::CloseEfpComputation => write!(fmt, "closeEFP"),
165 TickType::LastTimestamp => write!(fmt, "lastTimestamp"),
166 TickType::Shortable => write!(fmt, "shortable"),
167 TickType::FundamentalRatios => write!(fmt, "fundamentals"),
168 TickType::RtVolume => write!(fmt, "RTVolume"),
169 TickType::Halted => write!(fmt, "halted"),
170 TickType::BidYield => write!(fmt, "bidYield"),
171 TickType::AskYield => write!(fmt, "askYield"),
172 TickType::LastYield => write!(fmt, "lastYield"),
173 TickType::CustOptionComputation => write!(fmt, "custOptComp"),
174 TickType::TradeCount => write!(fmt, "tradeCount"),
175 TickType::TradeRate => write!(fmt, "tradeRate"),
176 TickType::VolumeRate => write!(fmt, "volumeRate"),
177 TickType::LastRthTrade => write!(fmt, "lastRTHTrade"),
178 TickType::RtHistoricalVol => write!(fmt, "RTHistoricalVol"),
179 TickType::IbDividends => write!(fmt, "IBDividends"),
180 TickType::BondFactorMultiplier => write!(fmt, "bondFactorMultiplier"),
181 TickType::RegulatoryImbalance => write!(fmt, "regulatoryImbalance"),
182 TickType::NewsTick => write!(fmt, "newsTick"),
183 TickType::ShortTermVolume3Min => write!(fmt, "shortTermVolume3Min"),
184 TickType::ShortTermVolume5Min => write!(fmt, "shortTermVolume5Min"),
185 TickType::ShortTermVolume10Min => write!(fmt, "shortTermVolume10Min"),
186 TickType::DelayedBid => write!(fmt, "delayedBid"),
187 TickType::DelayedAsk => write!(fmt, "delayedAsk"),
188 TickType::DelayedLast => write!(fmt, "delayedLast"),
189 TickType::DelayedBidSize => write!(fmt, "delayedBidSize"),
190 TickType::DelayedAskSize => write!(fmt, "delayedAskSize"),
191 TickType::DelayedLastSize => write!(fmt, "delayedLastSize"),
192 TickType::DelayedHigh => write!(fmt, "delayedHigh"),
193 TickType::DelayedLow => write!(fmt, "delayedLow"),
194 TickType::DelayedVolume => write!(fmt, "delayedVolume"),
195 TickType::DelayedClose => write!(fmt, "delayedClose"),
196 TickType::DelayedOpen => write!(fmt, "delayedOpen"),
197 TickType::RtTrdVolume => write!(fmt, "rtTrdVolume"),
198 TickType::CreditmanMarkPrice => write!(fmt, "creditmanMarkPrice"),
199 TickType::CreditmanSlowMarkPrice => write!(fmt, "creditmanSlowMarkPrice"),
200 TickType::DelayedBidOption => write!(fmt, "delayedBidOptComp"),
201 TickType::DelayedAskOption => write!(fmt, "delayedAskOptComp"),
202 TickType::DelayedLastOption => write!(fmt, "delayedLastOptComp"),
203 TickType::DelayedModelOption => write!(fmt, "delayedModelOptComp"),
204 TickType::LastExch => write!(fmt, "lastExchange"),
205 TickType::LastRegTime => write!(fmt, "lastRegTime"),
206 TickType::FuturesOpenInterest => write!(fmt, "futuresOpenInterest"),
207 TickType::AvgOptVolume => write!(fmt, "avgOptVolume"),
208 TickType::DelayedLastTimestamp => write!(fmt, "delayedLastTimestamp"),
209 TickType::ShortableShares => write!(fmt, "shortableShares"),
210 TickType::NotSet => write!(fmt, "unknown"),
211 }
212 }
213}
214
215#[repr(i32)]
218#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
219pub enum FaDataType {
220 NA = 0,
221 GROUPS = 1,
222 PROFILES = 2,
223 ALIASES = 3,
224}
225
226impl fmt::Display for FaDataType {
227 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
228 write!(f, "Type: {}", self)
229 }
230}
231
232#[derive(Serialize, Deserialize, Clone, Debug)]
233pub enum TickMsgType {
234 AllLast {
235 price: f64,
236 size: i32,
237 tick_attrib_last: TickAttribLast,
238 exchange: String,
239 special_conditions: String,
240 },
241 BidAsk {
242 bid_price: f64,
243 ask_price: f64,
244 bid_size: i32,
245 ask_size: i32,
246 tick_attrib_bid_ask: TickAttribBidAsk,
247 },
248 MidPoint {
249 mid_point: f64,
250 },
251}
252
253#[repr(i32)]
256#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
257pub enum TickByTickType {
258 NA = 0,
259 Last = 1,
260 AllLast = 2,
261 BidAsk = 3,
262 MidPoint = 4,
263}
264
265impl fmt::Display for TickByTickType {
266 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
267 match self {
268 TickByTickType::NA => write!(f, "N/A"),
269 TickByTickType::Last => write!(f, "Last"),
270 TickByTickType::AllLast => write!(f, "AllLast"),
271 TickByTickType::BidAsk => write!(f, "BidAsk"),
272 TickByTickType::MidPoint => write!(f, "MidPoint"),
273 }
274 }
275}
276
277#[derive(Serialize, Deserialize, Clone, Debug, Default)]
290pub struct BarData {
291 pub date: String,
292 pub open: f64,
293 pub high: f64,
294 pub low: f64,
295 pub close: f64,
296 pub volume: i64,
297 pub bar_count: i32,
298 pub average: f64,
299}
300
301impl BarData {
302 pub fn new(
303 date: String,
304 open: f64,
305 high: f64,
306 low: f64,
307 close: f64,
308 volume: i64,
309 bar_count: i32,
310 average: f64,
311 ) -> Self {
312 BarData {
313 date,
314 open,
315 high,
316 low,
317 close,
318 volume,
319 bar_count,
320 average,
321 }
322 }
323}
324
325impl fmt::Display for BarData {
326 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
327 write!(f, "date: {}, open: {}, high: {}, low: {}, close: {}, volume: {}, average: {}, barcount: {}", self.date, self.open, self.high,
328 self.low, self.close, self.volume, self.average, self.bar_count)
329 }
330}
331
332#[derive(Serialize, Deserialize, Clone, Debug, Default)]
345pub struct RealTimeBar {
346 pub date_time: String,
347 pub open: f64,
348 pub high: f64,
349 pub low: f64,
350 pub close: f64,
351 pub volume: i64,
352 pub wap: f64,
353 pub count: i32,
354}
355
356impl RealTimeBar {
357 pub fn new(
358 date_time: String,
359 open: f64,
360 high: f64,
361 low: f64,
362 close: f64,
363 volume: i64,
364 wap: f64,
365 count: i32,
366 ) -> Self {
367 RealTimeBar {
368 date_time,
369 open,
370 high,
371 low,
372 close,
373 volume,
374 wap,
375 count,
376 }
377 }
378}
379
380impl fmt::Display for RealTimeBar {
381 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
382 write!(
383 f,
384 "date_time: {},open: {}, high: {}, low: {}, close: {}, volume: {}, wap: {}, count: {}",
385 self.date_time,
386 self.open,
387 self.high,
388 self.low,
389 self.close,
390 self.volume,
391 self.wap,
392 self.count
393 )
394 }
395}
396
397#[derive(Serialize, Deserialize, Clone, Debug, Default)]
399pub struct HistogramData {
400 pub price: f64,
401 pub count: i32,
402}
403
404impl HistogramData {
405 pub fn new(price: f64, count: i32) -> Self {
406 HistogramData { price, count }
407 }
408}
409
410impl fmt::Display for HistogramData {
411 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
412 write!(f, "price: {}, count: {}", self.price, self.count)
413 }
414}
415
416#[derive(Serialize, Deserialize, Clone, Debug, Default)]
418pub struct DepthMktDataDescription {
419 pub exchange: String,
420 pub sec_type: String,
421 pub listing_exch: String,
422 pub service_data_type: String,
423 pub agg_group: i32,
424}
425
426impl DepthMktDataDescription {
427 pub fn new(
428 exchange: String,
429 sec_type: String,
430 listing_exch: String,
431 service_data_type: String,
432 agg_group: i32,
433 ) -> Self {
434 DepthMktDataDescription {
435 exchange,
436 sec_type,
437 listing_exch,
438 service_data_type,
439 agg_group,
440 }
441 }
442}
443
444impl fmt::Display for DepthMktDataDescription {
445 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
446 write!(
447 f,
448 "exchange: {}, sectype: {}, listing_exchange: {}, service_data_type: {}, agggroup: {}, ",
449 self.exchange,
450 self.sec_type,
451 self.listing_exch,
452 self.service_data_type,
453 if self.agg_group != UNSET_INTEGER {
454 format!("{}", self.agg_group)
455 } else {
456 "".to_string()
457 }
458 )
459 }
460}
461
462#[derive(Serialize, Deserialize, Clone, Debug, Default)]
464pub struct SmartComponent {
465 pub bit_number: i32,
466 pub exchange: String,
467 pub exchange_letter: String,
468}
469
470impl SmartComponent {
471 pub fn new(bit_number: i32, exchange: String, exchange_letter: String) -> Self {
472 SmartComponent {
473 bit_number,
474 exchange,
475 exchange_letter,
476 }
477 }
478}
479
480impl fmt::Display for SmartComponent {
481 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
482 write!(
483 f,
484 "bit_number: {}, exchange: {}, exchange_letter: {}",
485 self.bit_number, self.exchange, self.exchange_letter
486 )
487 }
488}
489
490#[derive(Serialize, Deserialize, Clone, Debug, Default)]
492pub struct TickAttrib {
493 pub can_auto_execute: bool,
494 pub past_limit: bool,
495 pub pre_open: bool,
496}
497
498impl TickAttrib {
499 pub fn new(can_auto_execute: bool, past_limit: bool, pre_open: bool) -> Self {
500 TickAttrib {
501 can_auto_execute,
502 past_limit,
503 pre_open,
504 }
505 }
506}
507
508impl fmt::Display for TickAttrib {
509 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
510 write!(
511 f,
512 "can_auto_execute: {}, past_limit: {}, pre_open: {}",
513 self.can_auto_execute, self.past_limit, self.pre_open
514 )
515 }
516}
517
518#[derive(Serialize, Deserialize, Clone, Debug, Default)]
520pub struct TickAttribBidAsk {
521 pub bid_past_low: bool,
522 pub ask_past_high: bool,
523}
524
525impl TickAttribBidAsk {
526 pub fn new(bid_past_low: bool, ask_past_high: bool) -> Self {
527 TickAttribBidAsk {
528 bid_past_low,
529 ask_past_high,
530 }
531 }
532}
533
534impl fmt::Display for TickAttribBidAsk {
535 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
536 write!(
537 f,
538 "bid_past_low: {}, ask_past_high: {}",
539 self.bid_past_low, self.ask_past_high
540 )
541 }
542}
543
544#[derive(Serialize, Deserialize, Clone, Debug, Default)]
546pub struct TickAttribLast {
547 pub past_limit: bool,
548 pub unreported: bool,
549}
550
551impl TickAttribLast {
552 pub fn new(past_limit: bool, unreported: bool) -> Self {
553 TickAttribLast {
554 past_limit,
555 unreported,
556 }
557 }
558}
559
560impl fmt::Display for TickAttribLast {
561 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
562 write!(
563 f,
564 "past_limit: {}, unreported: {}",
565 self.past_limit, self.unreported
566 )
567 }
568}
569
570#[derive(Serialize, Deserialize, Clone, Debug, Default)]
572pub struct FamilyCode {
573 pub account_id: String,
574 pub family_code_str: String,
575}
576
577impl FamilyCode {
578 pub fn new(account_id: String, family_code_str: String) -> Self {
579 FamilyCode {
580 account_id,
581 family_code_str,
582 }
583 }
584}
585
586impl fmt::Display for FamilyCode {
587 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
588 write!(
589 f,
590 "account_id: {}, family_code_str: {}",
591 self.account_id, self.family_code_str
592 )
593 }
594}
595
596#[derive(Serialize, Deserialize, Clone, Debug, Default)]
598pub struct PriceIncrement {
599 pub low_edge: f64,
600 pub increment: f64,
601}
602
603impl PriceIncrement {
604 pub fn new(low_edge: f64, increment: f64) -> Self {
605 PriceIncrement {
606 low_edge,
607 increment,
608 }
609 }
610}
611
612impl fmt::Display for PriceIncrement {
613 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
614 write!(
615 f,
616 "low_edge: {}, increment: {}",
617 self.low_edge, self.increment
618 )
619 }
620}
621
622#[derive(Serialize, Deserialize, Clone, Debug, Default)]
624pub struct HistoricalTick {
625 pub time: i32,
626 pub price: f64,
627 pub size: i32,
628}
629
630impl HistoricalTick {
631 pub fn new(time: i32, price: f64, size: i32) -> Self {
632 HistoricalTick { time, price, size }
633 }
634}
635
636impl fmt::Display for HistoricalTick {
637 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
638 write!(
639 f,
640 "time: {}, price: {}, size: {}",
641 self.time, self.price, self.size
642 )
643 }
644}
645
646#[derive(Serialize, Deserialize, Clone, Debug, Default)]
648pub struct HistoricalTickBidAsk {
649 pub time: i32,
650 pub tick_attrib_bid_ask: TickAttribBidAsk,
651 pub price_bid: f64,
652 pub price_ask: f64,
653 pub size_bid: i32,
654 pub size_ask: i32,
655}
656
657impl HistoricalTickBidAsk {
658 pub fn new(
659 time: i32,
660 tick_attrib_bid_ask: TickAttribBidAsk,
661 price_bid: f64,
662 price_ask: f64,
663 size_bid: i32,
664 size_ask: i32,
665 ) -> Self {
666 HistoricalTickBidAsk {
667 time,
668 tick_attrib_bid_ask,
669 price_bid,
670 price_ask,
671 size_bid,
672 size_ask,
673 }
674 }
675}
676
677impl fmt::Display for HistoricalTickBidAsk {
678 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
679 write!(
680 f,
681 "time: {}, tick_attrib_bid_ask: {}, price_bid: {}, price_ask: {}, size_bid: {}, size_ask: {}",
682 self.time,
683 self.tick_attrib_bid_ask,
684 self.price_bid,
685 self.price_ask,
686 self.size_bid,
687 self.size_ask
688 )
689 }
690}
691
692#[derive(Serialize, Deserialize, Clone, Debug, Default)]
694pub struct HistoricalTickLast {
695 pub time: i32,
696 pub tick_attrib_last: TickAttribLast,
697 pub price: f64,
698 pub size: i32,
699 pub exchange: String,
700 pub special_conditions: String,
701}
702
703impl HistoricalTickLast {
704 pub fn new(
705 time: i32,
706 tick_attrib_last: TickAttribLast,
707 price: f64,
708 size: i32,
709 exchange: String,
710 special_conditions: String,
711 ) -> Self {
712 HistoricalTickLast {
713 time,
714 tick_attrib_last,
715 price,
716 size,
717 exchange,
718 special_conditions,
719 }
720 }
721}
722
723impl fmt::Display for HistoricalTickLast {
724 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
725 write!(f, "time: {}, tick_attrib_last: {}, price: {}, size: {}, exchange: {}, special_conditions: {}",
726 self.time,
727 self.tick_attrib_last,
728 self.price,
729 self.size,
730 self.exchange,
731 self.special_conditions)
732 }
733}
734
735#[derive(Serialize, Deserialize, Clone, Debug, Default)]
737pub struct CommissionReport {
738 pub exec_id: String,
739 pub commission: f64,
740 pub currency: String,
741 pub realized_pnl: f64,
742 pub yield_: f64,
743 pub yield_redemption_date: String, }
745
746impl CommissionReport {
747 pub fn new(
748 exec_id: String,
749 commission: f64,
750 currency: String,
751 realized_pnl: f64,
752 yield_: f64,
753 yield_redemption_date: String,
754 ) -> Self {
755 CommissionReport {
756 exec_id,
757 commission,
758 currency,
759 realized_pnl,
760 yield_,
761 yield_redemption_date,
762 }
763 }
764}
765
766impl fmt::Display for CommissionReport {
767 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
768 write!(f, "exec_id: {}, commission: {}, currency: {}, realized_pnl: {}, yield_: {}, yield_redemption_date: {}",
769 self.exec_id,
770 self.commission,
771 self.currency,
772 if self.realized_pnl != UNSET_DOUBLE { format!("{}", self.realized_pnl) } else { "".to_string() },
773 if self.yield_ != UNSET_DOUBLE { format!("{}", self.yield_) } else { "".to_string() },
774 self.yield_redemption_date)
775 }
776}
777
778#[derive(Serialize, Deserialize, Clone, Debug, Default)]
780pub struct NewsProvider {
781 pub code: String,
782 pub name: String,
783}
784
785impl NewsProvider {
786 pub fn new(code: String, name: String) -> Self {
787 NewsProvider { code, name }
788 }
789}
790
791impl fmt::Display for NewsProvider {
792 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
793 write!(f, "code: {}, name: {}", self.code, self.name,)
794 }
795}
796
797#[derive(Serialize, Deserialize, Clone, Debug, Default)]
799pub struct TagValue {
800 pub tag: String,
801 pub value: String,
802}
803
804impl TagValue {
805 pub fn new(tag: String, value: String) -> Self {
806 TagValue { tag, value }
807 }
808}
809
810impl fmt::Display for TagValue {
811 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
812 write!(f, "{}={};", self.tag, self.value,)
813 }
814}
815
816#[repr(i32)]
818#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
819pub enum ComboParam {
820 NonGuaranteed,
821 PriceCondConid,
822 CondPriceMax,
823 CondPriceMin,
824 ChangeToMktTime1,
825 ChangeToMktTime2,
826 DiscretionaryPct,
827 DontLeginNext,
828 LeginPrio,
829 MaxSegSize,
830}
831
832impl Display for ComboParam {
833 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
834 match *self {
835 ComboParam::NonGuaranteed => write!(f, "NonGuaranteed"),
836 ComboParam::PriceCondConid => write!(f, "PriceCondConid"),
837 ComboParam::CondPriceMax => write!(f, "CondPriceMax"),
838 ComboParam::CondPriceMin => write!(f, "CondPriceMin"),
839 ComboParam::ChangeToMktTime1 => write!(f, "ChangeToMktTime1"),
840 ComboParam::ChangeToMktTime2 => write!(f, "ChangeToMktTime2"),
841 ComboParam::DiscretionaryPct => write!(f, "DiscretionaryPct"),
842 ComboParam::DontLeginNext => write!(f, "DontLeginNext"),
843 ComboParam::LeginPrio => write!(f, "LeginPrio"),
844 ComboParam::MaxSegSize => write!(f, "MaxSegSize"),
845 }
846 }
847}
848
849#[repr(i32)]
851#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
852pub enum HedgeType {
853 None,
854 Delta,
855 Beta,
856 Fx,
857 Pair,
858}
859
860impl Display for HedgeType {
861 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
862 match *self {
863 HedgeType::None => write!(f, ""),
864 HedgeType::Delta => write!(f, "Delta"),
865 HedgeType::Beta => write!(f, "Beta"),
866 HedgeType::Fx => write!(f, "Fx"),
867 HedgeType::Pair => write!(f, "Pair"),
868 }
869 }
870}
871
872#[repr(i32)]
874#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
875pub enum Right {
876 None,
877 Put,
878 Call,
879}
880
881impl Display for Right {
882 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
883 match *self {
884 Right::None => write!(f, ""),
885 Right::Put => write!(f, "P"),
886 Right::Call => write!(f, "C"),
887 }
888 }
889}
890
891#[repr(i32)]
893#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
894pub enum VolatilityType {
895 None,
896 Daily,
897 Annual,
898}
899
900impl Display for VolatilityType {
901 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
902 match *self {
903 VolatilityType::None => write!(f, "None"),
904 VolatilityType::Daily => write!(f, "Daily"),
905 VolatilityType::Annual => write!(f, "Annual"),
906 }
907 }
908}
909
910#[repr(i32)]
912#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
913pub enum ReferencePriceType {
914 None,
915 Midpoint,
916 BidOrAsk,
917}
918
919impl Display for ReferencePriceType {
920 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
921 match *self {
922 ReferencePriceType::None => write!(f, "None"),
923 ReferencePriceType::Midpoint => write!(f, "Midpoint"),
924 ReferencePriceType::BidOrAsk => write!(f, "BidOrAsk"),
925 }
926 }
927}
928
929#[repr(i32)]
931#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
932pub enum TriggerMethod {
933 Default,
934 DoubleBidAsk,
935 Last,
936 DoubleLast,
937 BidAsk,
938 LastOrBidAsk,
939 Midpoint,
940}
941
942impl Display for TriggerMethod {
943 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
944 match *self {
945 TriggerMethod::Default => write!(f, "Default"),
946 TriggerMethod::DoubleBidAsk => write!(f, "DoubleBidAsk"),
947 TriggerMethod::Last => write!(f, "Last"),
948 TriggerMethod::DoubleLast => write!(f, "DoubleLast"),
949 TriggerMethod::BidAsk => write!(f, "BidAsk"),
950 TriggerMethod::LastOrBidAsk => write!(f, "LastOrBidAsk"),
951 TriggerMethod::Midpoint => write!(f, "Midpoint"),
952 }
953 }
954}
955
956#[repr(i32)]
958#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
959pub enum Action {
960 BUY,
961 SELL,
962 SSHORT,
963}
964
965impl Display for Action {
966 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
967 match *self {
968 Action::BUY => write!(f, "BUY"),
969 Action::SELL => write!(f, "SELL"),
970 Action::SSHORT => write!(f, "SSHORT"),
971 }
972 }
973}
974
975#[repr(i32)]
977#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
978pub enum Rule80A {
979 None,
980 Individual,
981 Agency,
982 AgentOtherMember,
983 IndividualPTIA,
984 AgencyPTIA,
985 AgentOtherMemberPTIA,
986 IndividualPT,
987 AgencyPT,
988 AgentOtherMemberPT,
989}
990
991impl Display for Rule80A {
992 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
993 match self {
994 Rule80A::None => write!(f, ""),
995 Rule80A::Individual => write!(f, "I"),
996 Rule80A::Agency => write!(f, "A"),
997 Rule80A::AgentOtherMember => write!(f, "W"),
998 Rule80A::IndividualPTIA => write!(f, "J"),
999 Rule80A::AgencyPTIA => write!(f, "U"),
1000 Rule80A::AgentOtherMemberPTIA => write!(f, "M"),
1001 Rule80A::IndividualPT => write!(f, "K"),
1002 Rule80A::AgencyPT => write!(f, "Y"),
1003 Rule80A::AgentOtherMemberPT => write!(f, "N"),
1004 }
1005 }
1006}
1007
1008#[repr(i32)]
1010#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1011pub enum OcaType {
1012 None,
1013 CancelWithBlocking,
1014 ReduceWithBlocking,
1015 ReduceWithoutBlocking,
1016}
1017
1018impl Display for OcaType {
1019 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1020 match *self {
1021 OcaType::None => write!(f, "None"),
1022 OcaType::CancelWithBlocking => write!(f, "CancelWithBlocking"),
1023 OcaType::ReduceWithBlocking => write!(f, "ReduceWithBlocking"),
1024 OcaType::ReduceWithoutBlocking => write!(f, "ReduceWithoutBlocking"),
1025 }
1026 }
1027}
1028
1029#[repr(i32)]
1031#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1032pub enum TimeInForce {
1033 DAY,
1034 GTC,
1035 OPG,
1036 IOC,
1037 GTD,
1038 GTT,
1039 AUC,
1040 FOK,
1041 GTX,
1042 DTC,
1043}
1044
1045impl Display for TimeInForce {
1046 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1047 match *self {
1048 TimeInForce::DAY => write!(f, "DAY"),
1049 TimeInForce::GTC => write!(f, "GTC"),
1050 TimeInForce::OPG => write!(f, "OPG"),
1051 TimeInForce::IOC => write!(f, "IOC"),
1052 TimeInForce::GTD => write!(f, "GTD"),
1053 TimeInForce::GTT => write!(f, "GTT"),
1054 TimeInForce::AUC => write!(f, "AUC"),
1055 TimeInForce::FOK => write!(f, "FOK"),
1056 TimeInForce::GTX => write!(f, "GTX"),
1057 TimeInForce::DTC => write!(f, "DTC"),
1058 }
1059 }
1060}
1061
1062#[repr(i32)]
1064#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1065pub enum ExerciseType {
1066 None,
1067 Exercise,
1068 Lapse,
1069}
1070
1071impl Display for ExerciseType {
1072 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1073 match *self {
1074 ExerciseType::None => write!(f, ""),
1075 ExerciseType::Exercise => write!(f, "Exercise"),
1076 ExerciseType::Lapse => write!(f, "Lapse"),
1077 }
1078 }
1079}
1080
1081#[repr(i32)]
1083#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1084pub enum FundamentalType {
1085 ReportSnapshot,
1086 ReportsFinSummary,
1087 ReportRatios,
1088 ReportsFinStatements,
1089 RESC,
1090 CalendarReport,
1091 ReportsOwnership,
1092}
1093
1094impl Display for FundamentalType {
1095 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1096 match *self {
1097 FundamentalType::ReportSnapshot => write!(f, "Company overview"),
1098 FundamentalType::ReportsFinSummary => write!(f, "Financial summary"),
1099 FundamentalType::ReportRatios => write!(f, "Financial ratios"),
1100 FundamentalType::ReportsFinStatements => write!(f, "Financial statements"),
1101 FundamentalType::RESC => write!(f, "Analyst estimates"),
1102 FundamentalType::CalendarReport => write!(f, "Company calendar"),
1103 FundamentalType::ReportsOwnership => write!(f, "Company ownership"),
1104 }
1105 }
1106}
1107
1108#[repr(i32)]
1110#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1111pub enum WhatToShow {
1112 Trades,
1113 Midpoint,
1114 Bid,
1115 Ask,
1116 BidAsk,
1118 HistoricalVolatility,
1119 OptionImpliedVolatility,
1120 YieldAsk,
1121 YieldBid,
1122 YieldBidAsk,
1123 YieldLast,
1124 AdjustedLast,
1125}
1126
1127impl Display for WhatToShow {
1128 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1129 match *self {
1130 WhatToShow::Trades => write!(f, "TRADES"),
1131 WhatToShow::Midpoint => write!(f, "MIDPOINT"),
1132 WhatToShow::Bid => write!(f, "BID"),
1133 WhatToShow::Ask => write!(f, "ASK"),
1134 WhatToShow::BidAsk => write!(f, "BID_ASK"),
1135 WhatToShow::HistoricalVolatility => write!(f, "HISTORICAL_VOLATILITY"),
1136 WhatToShow::OptionImpliedVolatility => write!(f, "OPTION_IMPLIED_VOLATILITY"),
1137 WhatToShow::YieldAsk => write!(f, "YIELD_ASK"),
1138 WhatToShow::YieldBid => write!(f, "YIELD_ASK"),
1139 WhatToShow::YieldBidAsk => write!(f, "YIELD_BID_ASK"),
1140 WhatToShow::YieldLast => write!(f, "YIELD_LAST"),
1141 WhatToShow::AdjustedLast => write!(f, "ADJUSTED_LAST"),
1142 }
1143 }
1144}
1145
1146#[repr(i32)]
1148#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1149pub enum BarSize {
1150 _1Secs,
1151 _5Secs,
1152 _10Secs,
1153 _15Secs,
1154 _30Secs,
1155 _1Min,
1156 _2Mins,
1157 _3Mins,
1158 _5Mins,
1159 _10Mins,
1160 _15Mins,
1161 _20Mins,
1162 _30Mins,
1163 _1Hour,
1164 _4Hours,
1165 _1Day,
1166 _1Week,
1167 _1Month,
1168}
1169
1170impl Display for BarSize {
1171 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1172 match *self {
1173 BarSize::_1Secs => write!(f, "1 secs"),
1174 BarSize::_5Secs => write!(f, "5 secs"),
1175 BarSize::_10Secs => write!(f, "10 secs"),
1176 BarSize::_15Secs => write!(f, "15 secs"),
1177 BarSize::_30Secs => write!(f, "30 secs"),
1178 BarSize::_1Min => write!(f, "1 min"),
1179 BarSize::_2Mins => write!(f, "2 mins"),
1180 BarSize::_3Mins => write!(f, "3 mins"),
1181 BarSize::_5Mins => write!(f, "5 mins"),
1182 BarSize::_10Mins => write!(f, "10 mins"),
1183 BarSize::_15Mins => write!(f, "15 mins"),
1184 BarSize::_20Mins => write!(f, "20 mins"),
1185 BarSize::_30Mins => write!(f, "30 mins"),
1186 BarSize::_1Hour => write!(f, "1 hour"),
1187 BarSize::_4Hours => write!(f, "4 hours"),
1188 BarSize::_1Day => write!(f, "1 day"),
1189 BarSize::_1Week => write!(f, "1 week"),
1190 BarSize::_1Month => write!(f, "1 month"),
1191 }
1192 }
1193}
1194
1195#[repr(i32)]
1197#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1198pub enum DurationUnit {
1199 SECOND,
1200 DAY,
1201 WEEK,
1202 MONTH,
1203 YEAR,
1204}
1205
1206impl Display for DurationUnit {
1207 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1208 match *self {
1209 DurationUnit::SECOND => write!(f, "SECOND"),
1210 DurationUnit::DAY => write!(f, "DAY"),
1211 DurationUnit::WEEK => write!(f, "WEEK"),
1212 DurationUnit::MONTH => write!(f, "MONTH"),
1213 DurationUnit::YEAR => write!(f, "YEAR"),
1214 }
1215 }
1216}
1217
1218#[repr(i32)]
1220#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1221pub enum DeepType {
1222 INSERT,
1223 UPDATE,
1224 DELETE,
1225}
1226
1227impl Display for DeepType {
1228 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1229 match *self {
1230 DeepType::INSERT => write!(f, "INSERT"),
1231 DeepType::UPDATE => write!(f, "UPDATE"),
1232 DeepType::DELETE => write!(f, "DELETE"),
1233 }
1234 }
1235}
1236
1237#[repr(i32)]
1238#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1239pub enum DeepSide {
1240 Sell,
1241 Buy,
1242}
1243
1244impl Display for DeepSide {
1245 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1246 match *self {
1247 DeepSide::Buy => write!(f, "BUY"),
1248 DeepSide::Sell => write!(f, "SELL"),
1249 }
1250 }
1251}
1252
1253#[repr(i32)]
1255#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1256pub enum NewsType {
1257 Unknown,
1258 BBS,
1259 LiveExch,
1260 DeadExch,
1261 HTML,
1262 PopupText,
1263 PopupHtml,
1264}
1265
1266impl Display for NewsType {
1267 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1268 match *self {
1269 NewsType::Unknown => write!(f, "UNKNOWN"),
1270 NewsType::BBS => write!(f, "BBS"),
1271 NewsType::LiveExch => write!(f, "LIVE_EXCH"),
1272 NewsType::DeadExch => write!(f, "DEAD_EXCH"),
1273 NewsType::HTML => write!(f, "HTML"),
1274 NewsType::PopupText => write!(f, "POPUP_TEXT"),
1275 NewsType::PopupHtml => write!(f, "POPUP_HTML"),
1276 }
1277 }
1278}
1279
1280#[repr(i32)]
1282#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1283pub enum SecIdType {
1284 None,
1285 CUSIP,
1286 SEDOL,
1287 ISIN,
1288 RIC,
1289}
1290
1291impl Display for SecIdType {
1292 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1293 match *self {
1294 SecIdType::None => write!(f, ""),
1295 SecIdType::CUSIP => write!(f, "CUSIP"),
1296 SecIdType::SEDOL => write!(f, "SEDOL"),
1297 SecIdType::ISIN => write!(f, "ISIN"),
1298 SecIdType::RIC => write!(f, "RIC"),
1299 }
1300 }
1301}
1302
1303#[repr(i32)]
1305#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1306pub enum SecType {
1307 None,
1308 STK,
1309 OPT,
1310 FUT,
1311 CONTFUT,
1312 CASH,
1313 BOND,
1314 CFD,
1315 FOP,
1316 WAR,
1317 IOPT,
1318 FWD,
1319 BAG,
1320 IND,
1321 BILL,
1322 FUND,
1323 FIXED,
1324 SLB,
1325 NEWS,
1326 CMDTY,
1327 BSK,
1328 ICU,
1329 ICS,
1330}
1331
1332impl Display for SecType {
1333 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1334 match *self {
1335 SecType::None => write!(f, ""),
1336 SecType::STK => write!(f, "STK"),
1337 SecType::OPT => write!(f, "OPT"),
1338 SecType::FUT => write!(f, "FUT"),
1339 SecType::CONTFUT => write!(f, "CONTFUT"),
1340 SecType::CASH => write!(f, "CASH"),
1341 SecType::BOND => write!(f, "BOND"),
1342 SecType::CFD => write!(f, "CFD"),
1343 SecType::FOP => write!(f, "FOP"),
1344 SecType::WAR => write!(f, "WAR"),
1345 SecType::IOPT => write!(f, "IOPT"),
1346 SecType::FWD => write!(f, "FWD"),
1347 SecType::BAG => write!(f, "BAG"),
1348 SecType::IND => write!(f, "IND"),
1349 SecType::BILL => write!(f, "BILL"),
1350 SecType::FUND => write!(f, "FUND"),
1351 SecType::FIXED => write!(f, "FIXED"),
1352 SecType::SLB => write!(f, "SLB"),
1353 SecType::NEWS => write!(f, "NEWS"),
1354 SecType::CMDTY => write!(f, "CMDTY"),
1355 SecType::BSK => write!(f, "BSK"),
1356 SecType::ICU => write!(f, "ICU"),
1357 SecType::ICS => write!(f, "ICS"),
1358 }
1359 }
1360}
1361
1362#[repr(i32)]
1364#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1365pub enum MarketDataTypeEnum {
1366 Unknown,
1367 Realtime,
1368 Frozen,
1369 Delayed,
1370 DelayedFrozen, }
1374
1375impl Display for MarketDataTypeEnum {
1376 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1377 match self {
1378 MarketDataTypeEnum::Unknown => write!(f, "N/A"),
1379 MarketDataTypeEnum::Realtime => write!(f, "REALTIME"),
1380 MarketDataTypeEnum::Frozen => write!(f, "FROZEN"),
1381 MarketDataTypeEnum::Delayed => write!(f, "DELAYED"),
1382 MarketDataTypeEnum::DelayedFrozen => write!(f, "DELAYED_FROZEN"),
1383 }
1384 }
1385}
1386
1387#[repr(i32)]
1389#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1390pub enum Method {
1391 None,
1392 EqualQuantity,
1393 AvailableEquity,
1394 NetLiq,
1395 PctChange,
1396}
1397
1398impl Display for Method {
1399 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
1400 match self {
1401 Method::None => write!(f, ""),
1402 Method::EqualQuantity => write!(f, "EqualQuantity"),
1403 Method::AvailableEquity => write!(f, "AvailableEquity"),
1404 Method::NetLiq => write!(f, "NetLiq"),
1405 Method::PctChange => write!(f, "PctChange"),
1406 }
1407 }
1408}
1409
1410#[repr(i32)]
1412#[derive(Serialize, Deserialize, Clone, FromPrimitive, Debug)]
1413pub enum UsePriceMgmtAlgo {
1414 Default,
1415 NotUse,
1416 Use,
1417}
1418
1419impl UsePriceMgmtAlgo {
1420 pub fn value(&self) -> Option<bool> {
1421 match *self {
1422 UsePriceMgmtAlgo::Default => None,
1423 UsePriceMgmtAlgo::NotUse => Some(false),
1424 UsePriceMgmtAlgo::Use => Some(true),
1425 }
1426 }
1427}