1use rust_decimal::Decimal;
2
3use crate::constants::{UNSET_DOUBLE, UNSET_INTEGER};
4use crate::enums::{OptionExerciseType, TriggerMethod};
5
6pub type TickerId = i32;
8pub type OrderId = i32;
10pub type FaDataType = i32;
12
13#[derive(Debug, Clone, Default, PartialEq, Eq)]
15pub struct TagValue {
16 pub tag: String,
18 pub value: String,
20}
21
22#[derive(Debug, Clone, Default, PartialEq, Eq)]
24pub struct SoftDollarTier {
25 pub name: String,
27 pub value: String,
29 pub display_name: String,
31}
32
33#[derive(Debug, Clone, Default, PartialEq, Eq)]
35pub struct IneligibilityReason {
36 pub id: String,
37 pub description: String,
38}
39
40#[derive(Debug, Clone, Default, PartialEq, Eq)]
42pub struct DepthMarketDataDescription {
43 pub exchange: String,
44 pub security_type: String,
45 pub listing_exchange: String,
46 pub service_data_type: String,
47 pub aggregate_group: i32,
48}
49
50#[derive(Debug, Clone, Copy, Default, PartialEq)]
52pub struct PriceIncrement {
53 pub low_edge: f64,
54 pub increment: f64,
55}
56
57#[derive(Debug, Clone, Default, PartialEq)]
59pub struct HistogramEntry {
60 pub price: f64,
61 pub size: Decimal,
62}
63
64#[derive(Debug, Clone, Default, PartialEq, Eq)]
66pub struct FamilyCode {
67 pub account_id: String,
68 pub family_code: String,
69}
70
71#[derive(Debug, Clone, Default, PartialEq, Eq)]
73pub struct NewsProvider {
74 pub code: String,
75 pub name: String,
76}
77
78#[derive(Debug, Clone, Default, PartialEq, Eq)]
80pub struct WshEventData {
81 pub req_id: i32,
82 pub con_id: i32,
83 pub filter: String,
84 pub fill_watchlist: bool,
85 pub fill_portfolio: bool,
86 pub fill_position: bool,
87 pub fill_account: bool,
88 pub data_json: String,
89}
90
91impl WshEventData {
92 pub fn from_json(req_id: i32, data_json: impl Into<String>) -> Self {
94 let data_json = data_json.into();
95 #[derive(serde::Deserialize, Default)]
96 struct Raw {
97 #[serde(rename = "conId", default)]
98 con_id: i32,
99 #[serde(default)]
100 filter: String,
101 #[serde(rename = "fillWatchlist", default)]
102 fill_watchlist: bool,
103 #[serde(rename = "fillPortfolio", default)]
104 fill_portfolio: bool,
105 #[serde(rename = "fillPosition", default)]
106 fill_position: bool,
107 #[serde(rename = "fillAccount", default)]
108 fill_account: bool,
109 }
110 let raw = serde_json::from_str::<Raw>(&data_json).unwrap_or_default();
111 Self {
112 req_id,
113 con_id: raw.con_id,
114 filter: raw.filter,
115 fill_watchlist: raw.fill_watchlist,
116 fill_portfolio: raw.fill_portfolio,
117 fill_position: raw.fill_position,
118 fill_account: raw.fill_account,
119 data_json,
120 }
121 }
122}
123
124#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
126#[repr(i32)]
127pub enum LegOpenClose {
128 #[default]
130 SamePosition = 0,
131 OpenPosition = 1,
133 ClosePosition = 2,
135 Unknown = 3,
137}
138
139#[derive(Debug, Clone, PartialEq, Eq)]
141pub struct ComboLeg {
142 pub con_id: i32,
144 pub ratio: i32,
146 pub action: String,
148 pub exchange: String,
150 pub open_close: LegOpenClose,
152 pub short_sale_slot: i32,
154 pub designated_location: String,
156 pub exempt_code: i32,
158}
159
160impl Default for ComboLeg {
161 fn default() -> Self {
162 Self {
163 con_id: 0,
164 ratio: 0,
165 action: String::new(),
166 exchange: String::new(),
167 open_close: LegOpenClose::SamePosition,
168 short_sale_slot: 0,
169 designated_location: String::new(),
170 exempt_code: -1,
171 }
172 }
173}
174
175#[derive(Debug, Clone, Default, PartialEq)]
177pub struct DeltaNeutralContract {
178 pub con_id: i32,
180 pub delta: f64,
182 pub price: f64,
184}
185
186#[derive(Debug, Clone, PartialEq)]
188pub struct Contract {
189 pub con_id: i32,
191 pub symbol: String,
193 pub sec_type: String,
195 pub last_trade_date_or_contract_month: String,
197 pub last_trade_date: String,
199 pub strike: f64,
201 pub right: String,
203 pub multiplier: String,
205 pub exchange: String,
207 pub primary_exchange: String,
209 pub currency: String,
211 pub local_symbol: String,
213 pub trading_class: String,
215 pub include_expired: bool,
217 pub sec_id_type: String,
219 pub sec_id: String,
221 pub description: String,
223 pub issuer_id: String,
225 pub combo_legs_description: String,
227 pub combo_legs: Vec<ComboLeg>,
229 pub delta_neutral_contract: Option<DeltaNeutralContract>,
231}
232
233impl Default for Contract {
234 fn default() -> Self {
235 Self {
236 con_id: 0,
237 symbol: String::new(),
238 sec_type: String::new(),
239 last_trade_date_or_contract_month: String::new(),
240 last_trade_date: String::new(),
241 strike: UNSET_DOUBLE,
242 right: String::new(),
243 multiplier: String::new(),
244 exchange: String::new(),
245 primary_exchange: String::new(),
246 currency: String::new(),
247 local_symbol: String::new(),
248 trading_class: String::new(),
249 include_expired: false,
250 sec_id_type: String::new(),
251 sec_id: String::new(),
252 description: String::new(),
253 issuer_id: String::new(),
254 combo_legs_description: String::new(),
255 combo_legs: Vec::new(),
256 delta_neutral_contract: None,
257 }
258 }
259}
260
261#[derive(Debug, Clone, Default, PartialEq)]
263pub struct ContractDetails {
264 pub contract: Contract,
266 pub market_name: String,
268 pub min_tick: f64,
270 pub order_types: String,
272 pub valid_exchanges: String,
274 pub price_magnifier: i32,
276 pub under_con_id: i32,
278 pub long_name: String,
280 pub contract_month: String,
282 pub industry: String,
284 pub category: String,
286 pub subcategory: String,
288 pub time_zone_id: String,
290 pub trading_hours: String,
292 pub liquid_hours: String,
294 pub ev_rule: String,
296 pub ev_multiplier: f64,
298 pub sec_id_list: Vec<TagValue>,
300 pub aggregate_group: i32,
302 pub under_symbol: String,
304 pub under_sec_type: String,
306 pub market_rule_ids: String,
308 pub cusip: String,
310 pub issue_date: String,
312 pub ratings: String,
314 pub bond_type: String,
316 pub coupon: f64,
318 pub coupon_type: String,
320 pub convertible: bool,
322 pub callable: bool,
324 pub puttable: bool,
326 pub desc_append: String,
328 pub next_option_date: String,
330 pub next_option_type: String,
332 pub next_option_partial: bool,
334 pub bond_notes: String,
336 pub real_expiration_date: String,
338 pub stock_type: String,
340 pub min_size: Decimal,
342 pub size_increment: Decimal,
344 pub suggested_size_increment: Decimal,
346 pub fund_name: String,
348 pub fund_family: String,
350 pub fund_type: String,
352 pub fund_front_load: String,
354 pub fund_back_load: String,
356 pub fund_back_load_time_interval: String,
358 pub fund_management_fee: String,
360 pub fund_closed: bool,
362 pub fund_closed_for_new_investors: bool,
364 pub fund_closed_for_new_money: bool,
366 pub fund_notify_amount: String,
368 pub fund_minimum_initial_purchase: String,
370 pub fund_minimum_subsequent_purchase: String,
372 pub fund_blue_sky_states: String,
374 pub fund_blue_sky_territories: String,
376 pub fund_distribution_policy_indicator: String,
378 pub fund_asset_type: String,
380 pub ineligibility_reason_list: Vec<IneligibilityReason>,
382 pub event_contract1: String,
384 pub event_contract_description1: String,
386 pub event_contract_description2: String,
388 pub min_algo_size: Decimal,
390 pub last_price_precision: Decimal,
392 pub last_size_precision: Decimal,
394}
395
396#[derive(Debug, Clone, PartialEq)]
398pub struct OrderComboLeg {
399 pub price: f64,
401}
402
403impl Default for OrderComboLeg {
404 fn default() -> Self {
405 Self {
406 price: UNSET_DOUBLE,
407 }
408 }
409}
410
411#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
413#[repr(i32)]
414pub enum Origin {
415 #[default]
417 Customer = 0,
418 Firm = 1,
420 Unknown = 2,
422}
423
424#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
426#[repr(i32)]
427pub enum AuctionStrategy {
428 #[default]
430 Unset = 0,
431 Match = 1,
433 Improvement = 2,
435 Transparent = 3,
437}
438
439#[derive(Debug, Clone, PartialEq)]
441pub struct Order {
442 pub soft_dollar_tier: SoftDollarTier,
444 pub order_id: i32,
446 pub client_id: i32,
448 pub perm_id: i64,
450 pub action: String,
452 pub total_quantity: Decimal,
454 pub order_type: String,
456 pub limit_price: f64,
458 pub aux_price: f64,
460 pub tif: String,
462 pub active_start_time: String,
464 pub active_stop_time: String,
466 pub oca_group: String,
468 pub oca_type: i32,
470 pub order_ref: String,
472 pub transmit: bool,
474 pub parent_id: i32,
476 pub block_order: bool,
478 pub sweep_to_fill: bool,
480 pub display_size: i32,
482 pub trigger_method: i32,
484 pub outside_rth: bool,
486 pub hidden: bool,
488 pub good_after_time: String,
490 pub good_till_date: String,
492 pub rule80a: String,
494 pub all_or_none: bool,
496 pub min_qty: i32,
498 pub percent_offset: f64,
500 pub override_percentage_constraints: bool,
502 pub trail_stop_price: f64,
504 pub trailing_percent: f64,
506 pub fa_group: String,
508 pub fa_method: String,
510 pub fa_percentage: String,
512 pub designated_location: String,
514 pub open_close: String,
516 pub origin: Origin,
518 pub short_sale_slot: i32,
520 pub exempt_code: i32,
522 pub discretionary_amount: f64,
524 pub opt_out_smart_routing: bool,
526 pub auction_strategy: AuctionStrategy,
528 pub starting_price: f64,
530 pub stock_ref_price: f64,
532 pub delta: f64,
534 pub stock_range_lower: f64,
536 pub stock_range_upper: f64,
538 pub randomize_price: bool,
540 pub randomize_size: bool,
542 pub volatility: f64,
544 pub volatility_type: i32,
546 pub delta_neutral_order_type: String,
548 pub delta_neutral_aux_price: f64,
550 pub delta_neutral_con_id: i32,
552 pub delta_neutral_settling_firm: String,
554 pub delta_neutral_clearing_account: String,
556 pub delta_neutral_clearing_intent: String,
558 pub delta_neutral_open_close: String,
560 pub delta_neutral_short_sale: bool,
562 pub delta_neutral_short_sale_slot: i32,
564 pub delta_neutral_designated_location: String,
566 pub continuous_update: bool,
568 pub reference_price_type: i32,
570 pub basis_points: f64,
572 pub basis_points_type: i32,
574 pub scale_init_level_size: i32,
576 pub scale_subs_level_size: i32,
578 pub scale_price_increment: f64,
580 pub scale_price_adjust_value: f64,
582 pub scale_price_adjust_interval: i32,
584 pub scale_profit_offset: f64,
586 pub scale_auto_reset: bool,
588 pub scale_init_position: i32,
590 pub scale_init_fill_qty: i32,
592 pub scale_random_percent: bool,
594 pub scale_table: String,
596 pub hedge_type: String,
598 pub hedge_param: String,
600 pub hedge_max_size: i32,
602 pub account: String,
604 pub settling_firm: String,
606 pub clearing_account: String,
608 pub clearing_intent: String,
610 pub model_code: String,
612 pub algo_strategy: String,
614 pub algo_params: Vec<TagValue>,
616 pub smart_combo_routing_params: Vec<TagValue>,
618 pub algo_id: String,
620 pub what_if: bool,
622 pub not_held: bool,
624 pub solicited: bool,
626 pub order_combo_legs: Vec<OrderComboLeg>,
628 pub order_misc_options: Vec<TagValue>,
630 pub reference_contract_id: i32,
632 pub pegged_change_amount: f64,
634 pub is_pegged_change_amount_decrease: bool,
636 pub reference_change_amount: f64,
638 pub reference_exchange_id: String,
640 pub adjusted_order_type: String,
642 pub trigger_price: f64,
644 pub adjusted_stop_price: f64,
646 pub adjusted_stop_limit_price: f64,
648 pub adjusted_trailing_amount: f64,
650 pub adjustable_trailing_unit: i32,
652 pub limit_price_offset: f64,
654 pub conditions: Vec<OrderCondition>,
656 pub conditions_cancel_order: bool,
658 pub conditions_ignore_rth: bool,
660 pub ext_operator: String,
662 pub cash_qty: f64,
664 pub mifid2_decision_maker: String,
666 pub mifid2_decision_algo: String,
668 pub mifid2_execution_trader: String,
670 pub mifid2_execution_algo: String,
672 pub dont_use_auto_price_for_hedge: bool,
674 pub is_oms_container: bool,
676 pub discretionary_up_to_limit_price: bool,
678 pub auto_cancel_date: String,
680 pub filled_quantity: Decimal,
682 pub ref_futures_con_id: i32,
684 pub auto_cancel_parent: bool,
686 pub shareholder: String,
688 pub imbalance_only: bool,
690 pub route_marketable_to_bbo: i32,
692 pub parent_perm_id: i64,
694 pub use_price_mgmt_algo: i32,
696 pub duration: i32,
698 pub post_to_ats: i32,
700 pub advanced_error_override: String,
702 pub manual_order_time: String,
704 pub min_trade_qty: i32,
706 pub min_compete_size: i32,
708 pub compete_against_best_offset: f64,
710 pub mid_offset_at_whole: f64,
712 pub mid_offset_at_half: f64,
714 pub customer_account: String,
716 pub professional_customer: bool,
718 pub bond_accrued_interest: String,
720 pub include_overnight: bool,
722 pub manual_order_indicator: i32,
724 pub submitter: String,
726 pub post_only: bool,
728 pub allow_pre_open: bool,
730 pub ignore_open_auction: bool,
732 pub deactivate: bool,
734 pub seek_price_improvement: i32,
736 pub what_if_type: i32,
738 pub stop_loss_order_id: i32,
740 pub stop_loss_order_type: String,
742 pub profit_taker_order_id: i32,
744 pub profit_taker_order_type: String,
746}
747
748impl Default for Order {
749 fn default() -> Self {
750 Self {
751 soft_dollar_tier: SoftDollarTier::default(),
752 order_id: 0,
753 client_id: 0,
754 perm_id: 0,
755 action: String::new(),
756 total_quantity: Decimal::from_i128_with_scale(0, 0),
757 order_type: String::new(),
758 limit_price: UNSET_DOUBLE,
759 aux_price: UNSET_DOUBLE,
760 tif: String::new(),
761 active_start_time: String::new(),
762 active_stop_time: String::new(),
763 oca_group: String::new(),
764 oca_type: 0,
765 order_ref: String::new(),
766 transmit: true,
767 parent_id: 0,
768 block_order: false,
769 sweep_to_fill: false,
770 display_size: 0,
771 trigger_method: 0,
772 outside_rth: false,
773 hidden: false,
774 good_after_time: String::new(),
775 good_till_date: String::new(),
776 rule80a: String::new(),
777 all_or_none: false,
778 min_qty: UNSET_INTEGER,
779 percent_offset: UNSET_DOUBLE,
780 override_percentage_constraints: false,
781 trail_stop_price: UNSET_DOUBLE,
782 trailing_percent: UNSET_DOUBLE,
783 fa_group: String::new(),
784 fa_method: String::new(),
785 fa_percentage: String::new(),
786 designated_location: String::new(),
787 open_close: String::new(),
788 origin: Origin::Customer,
789 short_sale_slot: 0,
790 exempt_code: -1,
791 discretionary_amount: 0.0,
792 opt_out_smart_routing: false,
793 auction_strategy: AuctionStrategy::Unset,
794 starting_price: UNSET_DOUBLE,
795 stock_ref_price: UNSET_DOUBLE,
796 delta: UNSET_DOUBLE,
797 stock_range_lower: UNSET_DOUBLE,
798 stock_range_upper: UNSET_DOUBLE,
799 randomize_price: false,
800 randomize_size: false,
801 volatility: UNSET_DOUBLE,
802 volatility_type: UNSET_INTEGER,
803 delta_neutral_order_type: String::new(),
804 delta_neutral_aux_price: UNSET_DOUBLE,
805 delta_neutral_con_id: 0,
806 delta_neutral_settling_firm: String::new(),
807 delta_neutral_clearing_account: String::new(),
808 delta_neutral_clearing_intent: String::new(),
809 delta_neutral_open_close: String::new(),
810 delta_neutral_short_sale: false,
811 delta_neutral_short_sale_slot: 0,
812 delta_neutral_designated_location: String::new(),
813 continuous_update: false,
814 reference_price_type: UNSET_INTEGER,
815 basis_points: UNSET_DOUBLE,
816 basis_points_type: UNSET_INTEGER,
817 scale_init_level_size: UNSET_INTEGER,
818 scale_subs_level_size: UNSET_INTEGER,
819 scale_price_increment: UNSET_DOUBLE,
820 scale_price_adjust_value: UNSET_DOUBLE,
821 scale_price_adjust_interval: UNSET_INTEGER,
822 scale_profit_offset: UNSET_DOUBLE,
823 scale_auto_reset: false,
824 scale_init_position: UNSET_INTEGER,
825 scale_init_fill_qty: UNSET_INTEGER,
826 scale_random_percent: false,
827 scale_table: String::new(),
828 hedge_type: String::new(),
829 hedge_param: String::new(),
830 hedge_max_size: UNSET_INTEGER,
831 account: String::new(),
832 settling_firm: String::new(),
833 clearing_account: String::new(),
834 clearing_intent: String::new(),
835 model_code: String::new(),
836 algo_strategy: String::new(),
837 algo_params: Vec::new(),
838 smart_combo_routing_params: Vec::new(),
839 algo_id: String::new(),
840 what_if: false,
841 not_held: false,
842 solicited: false,
843 order_combo_legs: Vec::new(),
844 order_misc_options: Vec::new(),
845 reference_contract_id: 0,
846 pegged_change_amount: 0.0,
847 is_pegged_change_amount_decrease: false,
848 reference_change_amount: 0.0,
849 reference_exchange_id: String::new(),
850 adjusted_order_type: String::new(),
851 trigger_price: UNSET_DOUBLE,
852 adjusted_stop_price: UNSET_DOUBLE,
853 adjusted_stop_limit_price: UNSET_DOUBLE,
854 adjusted_trailing_amount: UNSET_DOUBLE,
855 adjustable_trailing_unit: 0,
856 limit_price_offset: UNSET_DOUBLE,
857 conditions: Vec::new(),
858 conditions_cancel_order: false,
859 conditions_ignore_rth: false,
860 ext_operator: String::new(),
861 cash_qty: UNSET_DOUBLE,
862 mifid2_decision_maker: String::new(),
863 mifid2_decision_algo: String::new(),
864 mifid2_execution_trader: String::new(),
865 mifid2_execution_algo: String::new(),
866 dont_use_auto_price_for_hedge: false,
867 is_oms_container: false,
868 discretionary_up_to_limit_price: false,
869 auto_cancel_date: String::new(),
870 filled_quantity: Decimal::from_i128_with_scale(0, 0),
871 ref_futures_con_id: 0,
872 auto_cancel_parent: false,
873 shareholder: String::new(),
874 imbalance_only: false,
875 route_marketable_to_bbo: UNSET_INTEGER,
876 parent_perm_id: 0,
877 use_price_mgmt_algo: UNSET_INTEGER,
878 duration: UNSET_INTEGER,
879 post_to_ats: UNSET_INTEGER,
880 advanced_error_override: String::new(),
881 manual_order_time: String::new(),
882 min_trade_qty: UNSET_INTEGER,
883 min_compete_size: UNSET_INTEGER,
884 compete_against_best_offset: UNSET_DOUBLE,
885 mid_offset_at_whole: UNSET_DOUBLE,
886 mid_offset_at_half: UNSET_DOUBLE,
887 customer_account: String::new(),
888 professional_customer: false,
889 bond_accrued_interest: String::new(),
890 include_overnight: false,
891 manual_order_indicator: UNSET_INTEGER,
892 submitter: String::new(),
893 post_only: false,
894 allow_pre_open: false,
895 ignore_open_auction: false,
896 deactivate: false,
897 seek_price_improvement: UNSET_INTEGER,
898 what_if_type: UNSET_INTEGER,
899 stop_loss_order_id: UNSET_INTEGER,
900 stop_loss_order_type: String::new(),
901 profit_taker_order_id: UNSET_INTEGER,
902 profit_taker_order_type: String::new(),
903 }
904 }
905}
906
907#[derive(Debug, Clone, Default, PartialEq, Eq)]
909pub struct OrderCancel {
910 pub manual_order_cancel_time: String,
912 pub ext_operator: String,
914 pub manual_order_indicator: i32,
916}
917
918#[derive(Debug, Clone, PartialEq, Eq)]
920pub struct ExecutionFilter {
921 pub client_id: i32,
923 pub acct_code: String,
925 pub time: String,
927 pub symbol: String,
929 pub sec_type: String,
931 pub exchange: String,
933 pub side: String,
935 pub last_n_days: i32,
937 pub specific_dates: Vec<i32>,
939}
940
941impl Default for ExecutionFilter {
942 fn default() -> Self {
943 Self {
944 client_id: 0,
945 acct_code: String::new(),
946 time: String::new(),
947 symbol: String::new(),
948 sec_type: String::new(),
949 exchange: String::new(),
950 side: String::new(),
951 last_n_days: UNSET_INTEGER,
952 specific_dates: Vec::new(),
953 }
954 }
955}
956
957#[derive(Debug, Clone, Default, PartialEq)]
959pub struct Execution {
960 pub order_id: i32,
962 pub exec_id: String,
964 pub time: String,
966 pub acct_number: String,
968 pub exchange: String,
970 pub side: String,
972 pub shares: Decimal,
974 pub price: f64,
976 pub perm_id: i64,
978 pub client_id: i32,
980 pub liquidation: i32,
982 pub cum_qty: Decimal,
984 pub avg_price: f64,
986 pub order_ref: String,
988 pub ev_rule: String,
990 pub ev_multiplier: f64,
992 pub model_code: String,
994 pub last_liquidity: i32,
996 pub pending_price_revision: bool,
998 pub submitter: String,
1000 pub opt_exercise_or_lapse_type: i32,
1002}
1003
1004#[derive(Debug, Clone, Default, PartialEq)]
1006pub struct OrderAllocation {
1007 pub account: String,
1009 pub position: Decimal,
1011 pub position_desired: Decimal,
1013 pub position_after: Decimal,
1015 pub desired_alloc_qty: Decimal,
1017 pub allowed_alloc_qty: Decimal,
1019 pub is_monetary: bool,
1021}
1022
1023#[derive(Debug, Clone, Default, PartialEq)]
1025pub struct OrderState {
1026 pub status: String,
1028 pub init_margin_before: f64,
1030 pub maint_margin_before: f64,
1032 pub equity_with_loan_before: f64,
1034 pub init_margin_change: f64,
1036 pub maint_margin_change: f64,
1038 pub equity_with_loan_change: f64,
1040 pub init_margin_after: f64,
1042 pub maint_margin_after: f64,
1044 pub equity_with_loan_after: f64,
1046 pub commission_and_fees: f64,
1048 pub min_commission_and_fees: f64,
1050 pub max_commission_and_fees: f64,
1052 pub commission_and_fees_currency: String,
1054 pub margin_currency: String,
1056 pub init_margin_before_outside_rth: f64,
1058 pub maint_margin_before_outside_rth: f64,
1060 pub equity_with_loan_before_outside_rth: f64,
1062 pub init_margin_change_outside_rth: f64,
1064 pub maint_margin_change_outside_rth: f64,
1066 pub equity_with_loan_change_outside_rth: f64,
1068 pub init_margin_after_outside_rth: f64,
1070 pub maint_margin_after_outside_rth: f64,
1072 pub equity_with_loan_after_outside_rth: f64,
1074 pub suggested_size: String,
1076 pub reject_reason: String,
1078 pub order_allocations: Vec<OrderAllocation>,
1080 pub warning_text: String,
1082 pub completed_time: String,
1084 pub completed_status: String,
1086}
1087
1088#[derive(Debug, Clone, Default, PartialEq)]
1090pub struct CommissionAndFeesReport {
1091 pub exec_id: String,
1093 pub commission_and_fees: f64,
1095 pub currency: String,
1097 pub realized_pnl: f64,
1099 pub bond_yield: f64,
1101 pub yield_redemption_date: String,
1103}
1104
1105#[derive(Debug, Clone, Default, PartialEq)]
1107pub struct ContractDescription {
1108 pub contract: Contract,
1110 pub derivative_sec_types: Vec<String>,
1112}
1113
1114#[derive(Debug, Clone, Default, PartialEq, Eq)]
1116pub struct SmartComponent {
1117 pub bit_number: i32,
1119 pub exchange: String,
1121 pub exchange_letter: String,
1123}
1124
1125#[derive(Debug, Clone, Default, PartialEq, Eq)]
1127pub struct HistoricalSession {
1128 pub start_date_time: String,
1130 pub end_date_time: String,
1132 pub ref_date: String,
1134}
1135
1136#[derive(Debug, Clone, Default, PartialEq)]
1138pub struct HistoricalTick {
1139 pub time: i64,
1141 pub price: f64,
1143 pub size: Decimal,
1145}
1146
1147#[derive(Debug, Clone, Default, PartialEq, Eq)]
1149pub struct TickAttribBidAsk {
1150 pub bid_past_low: bool,
1152 pub ask_past_high: bool,
1154}
1155
1156#[derive(Debug, Clone, Default, PartialEq, Eq)]
1158pub struct TickAttribLast {
1159 pub past_limit: bool,
1161 pub unreported: bool,
1163}
1164
1165#[derive(Debug, Clone, Default, PartialEq)]
1167pub struct HistoricalTickBidAsk {
1168 pub time: i64,
1170 pub tick_attrib_bid_ask: TickAttribBidAsk,
1172 pub price_bid: f64,
1174 pub price_ask: f64,
1176 pub size_bid: Decimal,
1178 pub size_ask: Decimal,
1180}
1181
1182#[derive(Debug, Clone, Default, PartialEq)]
1184pub struct HistoricalTickLast {
1185 pub time: i64,
1187 pub tick_attrib_last: TickAttribLast,
1189 pub price: f64,
1191 pub size: Decimal,
1193 pub exchange: String,
1195 pub special_conditions: String,
1197}
1198
1199#[derive(Debug, Clone, PartialEq)]
1201pub enum TickByTick {
1202 Last(HistoricalTickLast),
1204 BidAsk(HistoricalTickBidAsk),
1206 MidPoint(HistoricalTick),
1208}
1209
1210#[derive(Debug, Clone, Default, PartialEq)]
1212pub struct ScannerSubscription {
1213 pub number_of_rows: i32,
1215 pub instrument: String,
1217 pub location_code: String,
1219 pub scan_code: String,
1221 pub above_price: f64,
1223 pub below_price: f64,
1225 pub above_volume: i32,
1227 pub market_cap_above: f64,
1229 pub market_cap_below: f64,
1231 pub moody_rating_above: String,
1233 pub moody_rating_below: String,
1235 pub sp_rating_above: String,
1237 pub sp_rating_below: String,
1239 pub maturity_date_above: String,
1241 pub maturity_date_below: String,
1243 pub coupon_rate_above: f64,
1245 pub coupon_rate_below: f64,
1247 pub exclude_convertible: bool,
1249 pub average_option_volume_above: i32,
1251 pub scanner_setting_pairs: String,
1253 pub stock_type_filter: String,
1255}
1256
1257#[derive(Debug, Clone, PartialEq)]
1259pub enum OrderCondition {
1260 Price {
1262 is_conjunction_connection: bool,
1264 trigger_method: i32,
1266 con_id: i32,
1268 exchange: String,
1270 is_more: bool,
1272 price: f64,
1274 },
1275 Time {
1277 is_conjunction_connection: bool,
1279 is_more: bool,
1281 time: String,
1283 },
1284 Margin {
1286 is_conjunction_connection: bool,
1288 is_more: bool,
1290 percent: f64,
1292 },
1293 Execution {
1295 is_conjunction_connection: bool,
1297 sec_type: String,
1299 exchange: String,
1301 symbol: String,
1303 },
1304 Volume {
1306 is_conjunction_connection: bool,
1308 con_id: i32,
1310 exchange: String,
1312 is_more: bool,
1314 volume: i32,
1316 },
1317 PercentChange {
1319 is_conjunction_connection: bool,
1321 con_id: i32,
1323 exchange: String,
1325 is_more: bool,
1327 change_percent: f64,
1329 },
1330}
1331
1332impl OrderCondition {
1333 pub fn trigger_method(&self) -> Option<TriggerMethod> {
1335 match self {
1336 Self::Price { trigger_method, .. } => Some(TriggerMethod::from_i32(*trigger_method)),
1337 _ => None,
1338 }
1339 }
1340}
1341
1342impl Execution {
1343 pub const fn option_exercise_type(&self) -> OptionExerciseType {
1345 OptionExerciseType::from_i32(self.opt_exercise_or_lapse_type)
1346 }
1347
1348 pub const fn liquidity(&self) -> crate::enums::Liquidities {
1350 crate::enums::Liquidities::from_i32(self.last_liquidity)
1351 }
1352}
1353
1354#[derive(Debug, Clone, Default, PartialEq)]
1356pub struct BarData {
1357 pub date: String,
1359 pub open: f64,
1361 pub high: f64,
1363 pub low: f64,
1365 pub close: f64,
1367 pub volume: Decimal,
1369 pub wap: Decimal,
1371 pub bar_count: i32,
1373}
1374
1375#[derive(Debug, Clone, Default, PartialEq)]
1378pub struct RealTimeBar {
1379 pub time: i64,
1380 pub end_time: i64,
1381 pub open: f64,
1382 pub high: f64,
1383 pub low: f64,
1384 pub close: f64,
1385 pub volume: Decimal,
1386 pub wap: Decimal,
1387 pub count: i32,
1388}