Skip to main content

twsapi/core/
order.rs

1//! Types related to orders
2use std::fmt::{Display, Error, Formatter};
3
4use num_derive::FromPrimitive;
5
6use serde::{Deserialize, Serialize};
7
8use crate::core::common::{TagValue, UNSET_DOUBLE, UNSET_INTEGER};
9use crate::core::order::AuctionStrategy::AuctionUnset;
10use crate::core::order::Origin::Customer;
11use crate::core::order_condition::{Condition, OrderConditionEnum};
12
13//==================================================================================================
14#[repr(i32)]
15#[derive(Serialize, Deserialize, Clone, Debug, FromPrimitive, Copy)]
16pub enum Origin {
17    Customer = 0,
18    Firm = 1,
19    Unknown = 2,
20}
21
22impl Default for Origin {
23    fn default() -> Self {
24        Origin::Unknown
25    }
26}
27
28// enum AuctionStrategy
29//==================================================================================================
30#[repr(i32)]
31#[derive(Serialize, Deserialize, Clone, Debug, FromPrimitive, Copy)]
32pub enum AuctionStrategy {
33    AuctionUnset = 0,
34    AuctionMatch = 1,
35    AuctionImprovement = 2,
36    AuctionTransparent = 3,
37}
38
39impl Default for AuctionStrategy {
40    fn default() -> Self {
41        AuctionStrategy::AuctionUnset
42    }
43}
44
45//==================================================================================================
46#[derive(Serialize, Deserialize, Clone, Debug, Default)]
47pub struct SoftDollarTier {
48    pub name: String,
49    pub val: String,
50    pub display_name: String,
51}
52
53impl SoftDollarTier {
54    pub fn new(name: String, val: String, display_name: String) -> Self {
55        SoftDollarTier {
56            name,
57            val,
58            display_name,
59        }
60    }
61}
62
63impl Display for SoftDollarTier {
64    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
65        write!(
66            f,
67            "name: {}, value: {}, display_name: {}",
68            self.name, self.val, self.display_name
69        )
70    }
71}
72
73//==================================================================================================
74#[derive(Serialize, Deserialize, Clone, Debug, Default)]
75pub struct OrderState {
76    pub status: String,
77    pub init_margin_before: String,
78    pub maint_margin_before: String,
79    pub equity_with_loan_before: String,
80    pub init_margin_change: String,
81    pub maint_margin_change: String,
82    pub equity_with_loan_change: String,
83    pub init_margin_after: String,
84    pub maint_margin_after: String,
85    pub equity_with_loan_after: String,
86    pub commission: f64,
87    pub min_commission: f64,
88    pub max_commission: f64,
89    pub commission_currency: String,
90    pub warning_text: String,
91    pub completed_time: String,
92    pub completed_status: String,
93}
94
95impl OrderState {
96    pub fn new(
97        status: String,
98        init_margin_before: String,
99        maint_margin_before: String,
100        equity_with_loan_before: String,
101        init_margin_change: String,
102        maint_margin_change: String,
103        equity_with_loan_change: String,
104        init_margin_after: String,
105        maint_margin_after: String,
106        equity_with_loan_after: String,
107        commission: f64,
108        min_commission: f64,
109        max_commission: f64,
110        commission_currency: String,
111        warning_text: String,
112        completed_time: String,
113        completed_status: String,
114    ) -> Self {
115        OrderState {
116            status,
117            init_margin_before,
118            maint_margin_before,
119            equity_with_loan_before,
120            init_margin_change,
121            maint_margin_change,
122            equity_with_loan_change,
123            init_margin_after,
124            maint_margin_after,
125            equity_with_loan_after,
126            commission,
127            min_commission,
128            max_commission,
129            commission_currency,
130            warning_text,
131            completed_time,
132            completed_status,
133        }
134    }
135}
136
137impl Display for OrderState {
138    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
139        write!(
140            f,
141            "status: {},
142             init_margin_before: {},
143             maint_margin_before: {},
144             equity_with_loan_before: {},
145             init_margin_change: {},
146             maint_margin_change: {},
147             equity_with_loan_change: {},
148             init_margin_after: {},
149             maint_margin_after: {},
150             equity_with_loan_after: {},
151             commission: {},
152             min_commission: {},
153             max_commission: {},
154             commission_currency: {},
155             warning_text: {},
156             completed_time: {},
157             completed_status: {},\n",
158            self.status,
159            self.init_margin_before,
160            self.maint_margin_before,
161            self.equity_with_loan_before,
162            self.init_margin_change,
163            self.maint_margin_change,
164            self.equity_with_loan_change,
165            self.init_margin_after,
166            self.maint_margin_after,
167            self.equity_with_loan_after,
168            if self.commission == UNSET_DOUBLE {
169                format!("{:E}", self.commission)
170            } else {
171                format!("{:?}", self.commission)
172            },
173            if self.min_commission == UNSET_DOUBLE {
174                format!("{:E}", self.min_commission)
175            } else {
176                format!("{:?}", self.min_commission)
177            },
178            if self.max_commission == UNSET_DOUBLE {
179                format!("{:E}", self.max_commission)
180            } else {
181                format!("{:?}", self.max_commission)
182            },
183            self.commission_currency,
184            self.warning_text,
185            self.completed_time,
186            self.completed_status,
187        )
188    }
189}
190
191//==================================================================================================
192#[derive(Serialize, Deserialize, Clone, Debug, Default)]
193pub struct OrderComboLeg {
194    pub(crate) price: f64, // type: float
195}
196
197impl OrderComboLeg {
198    pub fn new(price: f64) -> Self {
199        OrderComboLeg { price }
200    }
201}
202
203impl Display for OrderComboLeg {
204    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
205        write!(f, "{}", self.price)
206    }
207}
208
209//==================================================================================================
210#[derive(Serialize, Deserialize, Clone, Debug)]
211pub struct Order {
212    pub soft_dollar_tier: SoftDollarTier,
213    // order identifier
214    pub order_id: i32,
215    pub client_id: i32,
216    pub perm_id: i32,
217
218    // main order fields
219    pub action: String,
220    pub total_quantity: f64,
221    pub order_type: String,
222    pub lmt_price: f64,
223    pub aux_price: f64,
224
225    // extended order fields
226    pub tif: String,
227    // "Time in Force" - DAY, GTC, etc.
228    pub active_start_time: String,
229    // for GTC orders
230    pub active_stop_time: String,
231    // for GTC orders
232    pub oca_group: String,
233    // one cancels all group name
234    pub oca_type: i32,
235    // 1 = CANCEL_WITH_BLOCK, 2 = REDUCE_WITH_BLOCK, 3 = REDUCE_NON_BLOCK
236    pub order_ref: String,
237    pub transmit: bool,
238    // if false, order will be created but not transmited
239    pub parent_id: i32,
240    // Parent order Id, to associate Auto STP or TRAIL orders with the original order.
241    pub block_order: bool,
242    pub sweep_to_fill: bool,
243    pub display_size: i32,
244    pub trigger_method: i32,
245    // 0=Default, 1=Double_Bid_Ask, 2=Last, 3=Double_Last, 4=Bid_Ask, 7=Last_or_Bid_Ask, 8=Mid-point
246    pub outside_rth: bool,
247    pub hidden: bool,
248    pub good_after_time: String,
249    // Format: 20060505 08:00:00 {time zone}
250    pub good_till_date: String,
251    // Format: 20060505 08:00:00 {time zone}
252    pub rule80a: String,
253    // Individual = 'I', Agency = 'A', AgentOtherMember = 'W', IndividualPTIA = 'J', AgencyPTIA = 'U', AgentOtherMemberPTIA = 'M', IndividualPT = 'K', AgencyPT = 'Y', AgentOtherMemberPT = 'N'
254    pub all_or_none: bool,
255    pub min_qty: i32,
256    //type: int
257    pub percent_offset: f64,
258    // type: float; REL orders only
259    pub override_percentage_constraints: bool,
260    pub trail_stop_price: f64,
261    // type: float
262    pub trailing_percent: f64, // type: float; TRAILLIMIT orders only
263
264    // financial advisors only
265    pub fa_group: String,
266    pub fa_profile: String,
267    pub fa_method: String,
268    pub fa_percentage: String,
269
270    // institutional (ie non-cleared) only
271    pub designated_location: String,
272    //used only when short_sale_slot=2
273    pub open_close: String,
274    // O=Open, C=Close
275    pub origin: Origin,
276    // 0=Customer, 1=Firm
277    pub short_sale_slot: i32,
278    // type: int; 1 if you hold the shares, 2 if they will be delivered from elsewhere.  Only for Action=SSHORT
279    pub exempt_code: i32,
280
281    // SMART routing only
282    pub discretionary_amt: f64,
283    pub e_trade_only: bool,
284    pub firm_quote_only: bool,
285    pub nbbo_price_cap: f64,
286    // type: float
287    pub opt_out_smart_routing: bool,
288
289    // BOX exchange orders only
290    pub auction_strategy: AuctionStrategy,
291    // type: int; AuctionMatch, AuctionImprovement, AuctionTransparent
292    pub starting_price: f64,
293    // type: float
294    pub stock_ref_price: f64,
295    // type: float
296    pub delta: f64, // type: float
297
298    // pegged to stock and VOL orders only
299    pub stock_range_lower: f64,
300    // type: float
301    pub stock_range_upper: f64, // type: float
302
303    pub randomize_price: bool,
304    pub randomize_size: bool,
305
306    // VOLATILITY ORDERS ONLY
307    pub volatility: f64,
308    // type: float
309    pub volatility_type: i32,
310    // type: int   // 1=daily, 2=annual
311    pub delta_neutral_order_type: String,
312    pub delta_neutral_aux_price: f64,
313    // type: float
314    pub delta_neutral_con_id: i32,
315    pub delta_neutral_settling_firm: String,
316    pub delta_neutral_clearing_account: String,
317    pub delta_neutral_clearing_intent: String,
318    pub delta_neutral_open_close: String,
319    pub delta_neutral_short_sale: bool,
320    pub delta_neutral_short_sale_slot: i32,
321    pub delta_neutral_designated_location: String,
322    pub continuous_update: bool,
323    pub reference_price_type: i32, // type: int; 1=Average, 2 = BidOrAsk
324
325    // COMBO ORDERS ONLY
326    pub basis_points: f64,
327    // type: float; EFP orders only
328    pub basis_points_type: i32, // type: int;  EFP orders only
329
330    // SCALE ORDERS ONLY
331    pub scale_init_level_size: i32,
332    // type: int
333    pub scale_subs_level_size: i32,
334    // type: int
335    pub scale_price_increment: f64,
336    // type: float
337    pub scale_price_adjust_value: f64,
338    // type: float
339    pub scale_price_adjust_interval: i32,
340    // type: int
341    pub scale_profit_offset: f64,
342    // type: float
343    pub scale_auto_reset: bool,
344    pub scale_init_position: i32,
345    // type: int
346    pub scale_init_fill_qty: i32,
347    // type: int
348    pub scale_random_percent: bool,
349    pub scale_table: String,
350
351    // HEDGE ORDERS
352    pub hedge_type: String,
353    // 'D' - delta, 'B' - beta, 'F' - FX, 'P' - pair
354    pub hedge_param: String, // 'beta=X' value for beta hedge, 'ratio=Y' for pair hedge
355
356    // Clearing info
357    pub account: String,
358    // IB account
359    pub settling_firm: String,
360    pub clearing_account: String,
361    //True beneficiary of the order
362    pub clearing_intent: String, // "" (Default), "IB", "Away", "PTA" (PostTrade)
363
364    // ALGO ORDERS ONLY
365    pub algo_strategy: String,
366
367    pub algo_params: Vec<TagValue>,
368    //TagValueList
369    pub smart_combo_routing_params: Vec<TagValue>, //TagValueList
370
371    pub algo_id: String,
372
373    // What-if
374    pub what_if: bool,
375
376    // Not Held
377    pub not_held: bool,
378    pub solicited: bool,
379
380    // models
381    pub model_code: String,
382
383    // order combo legs
384    pub order_combo_legs: Vec<OrderComboLeg>, // OrderComboLegListSPtr
385
386    pub order_misc_options: Vec<TagValue>, // TagValueList
387
388    // VER PEG2BENCH fields:
389    pub reference_contract_id: i32,
390    pub pegged_change_amount: f64,
391    pub is_pegged_change_amount_decrease: bool,
392    pub reference_change_amount: f64,
393    pub reference_exchange_id: String,
394    pub adjusted_order_type: String,
395
396    pub trigger_price: f64,
397    pub adjusted_stop_price: f64,
398    pub adjusted_stop_limit_price: f64,
399    pub adjusted_trailing_amount: f64,
400    pub adjustable_trailing_unit: i32,
401    pub lmt_price_offset: f64,
402
403    pub conditions: Vec<OrderConditionEnum>,
404    // std::vector<std::shared_ptr<OrderCondition>>
405    pub conditions_cancel_order: bool,
406    pub conditions_ignore_rth: bool,
407
408    // ext operator
409    pub ext_operator: String,
410
411    // native cash quantity
412    pub cash_qty: f64,
413
414    pub mifid2decision_maker: String,
415    pub mifid2decision_algo: String,
416    pub mifid2execution_trader: String,
417    pub mifid2execution_algo: String,
418
419    pub dont_use_auto_price_for_hedge: bool,
420
421    pub is_oms_container: bool,
422
423    pub discretionary_up_to_limit_price: bool,
424
425    pub auto_cancel_date: String,
426    pub filled_quantity: f64,
427    pub ref_futures_con_id: i32,
428    pub auto_cancel_parent: bool,
429    pub shareholder: String,
430    pub imbalance_only: bool,
431    pub route_marketable_to_bbo: bool,
432    pub parent_perm_id: i32,
433
434    pub use_price_mgmt_algo: bool,
435}
436
437impl Order {
438    pub fn new(
439        soft_dollar_tier: SoftDollarTier,
440        order_id: i32,
441        client_id: i32,
442        perm_id: i32,
443        action: String,
444        total_quantity: f64,
445        order_type: String,
446        lmt_price: f64,
447        aux_price: f64,
448        tif: String,
449        active_start_time: String,
450        active_stop_time: String,
451        oca_group: String,
452        oca_type: i32,
453        order_ref: String,
454        transmit: bool,
455        parent_id: i32,
456        block_order: bool,
457        sweep_to_fill: bool,
458        display_size: i32,
459        trigger_method: i32,
460        outside_rth: bool,
461        hidden: bool,
462        good_after_time: String,
463        good_till_date: String,
464        rule80a: String,
465        all_or_none: bool,
466        min_qty: i32,
467        percent_offset: f64,
468        override_percentage_constraints: bool,
469        trail_stop_price: f64,
470        trailing_percent: f64,
471        fa_group: String,
472        fa_profile: String,
473        fa_method: String,
474        fa_percentage: String,
475        designated_location: String,
476        open_close: String,
477        origin: Origin,
478        short_sale_slot: i32,
479        exempt_code: i32,
480        discretionary_amt: f64,
481        e_trade_only: bool,
482        firm_quote_only: bool,
483        nbbo_price_cap: f64,
484        opt_out_smart_routing: bool,
485        auction_strategy: AuctionStrategy,
486        starting_price: f64,
487        stock_ref_price: f64,
488        delta: f64,
489        stock_range_lower: f64,
490        stock_range_upper: f64,
491        randomize_price: bool,
492        randomize_size: bool,
493        volatility: f64,
494        volatility_type: i32,
495        delta_neutral_order_type: String,
496        delta_neutral_aux_price: f64,
497        delta_neutral_con_id: i32,
498        delta_neutral_settling_firm: String,
499        delta_neutral_clearing_account: String,
500        delta_neutral_clearing_intent: String,
501        delta_neutral_open_close: String,
502        delta_neutral_short_sale: bool,
503        delta_neutral_short_sale_slot: i32,
504        delta_neutral_designated_location: String,
505        continuous_update: bool,
506        reference_price_type: i32,
507        basis_points: f64,
508        basis_points_type: i32,
509        scale_init_level_size: i32,
510        scale_subs_level_size: i32,
511        scale_price_increment: f64,
512        scale_price_adjust_value: f64,
513        scale_price_adjust_interval: i32,
514        scale_profit_offset: f64,
515        scale_auto_reset: bool,
516        scale_init_position: i32,
517        scale_init_fill_qty: i32,
518        scale_random_percent: bool,
519        scale_table: String,
520        hedge_type: String,
521        hedge_param: String,
522        account: String,
523        settling_firm: String,
524        clearing_account: String,
525        clearing_intent: String,
526        algo_strategy: String,
527        algo_params: Vec<TagValue>,
528        smart_combo_routing_params: Vec<TagValue>,
529        algo_id: String,
530        what_if: bool,
531        not_held: bool,
532        solicited: bool,
533        model_code: String,
534        order_combo_legs: Vec<OrderComboLeg>,
535        order_misc_options: Vec<TagValue>,
536        reference_contract_id: i32,
537        pegged_change_amount: f64,
538        is_pegged_change_amount_decrease: bool,
539        reference_change_amount: f64,
540        reference_exchange_id: String,
541        adjusted_order_type: String,
542        trigger_price: f64,
543        adjusted_stop_price: f64,
544        adjusted_stop_limit_price: f64,
545        adjusted_trailing_amount: f64,
546        adjustable_trailing_unit: i32,
547        lmt_price_offset: f64,
548        conditions: Vec<OrderConditionEnum>,
549        conditions_cancel_order: bool,
550        conditions_ignore_rth: bool,
551        ext_operator: String,
552        cash_qty: f64,
553        mifid2decision_maker: String,
554        mifid2decision_algo: String,
555        mifid2execution_trader: String,
556        mifid2execution_algo: String,
557        dont_use_auto_price_for_hedge: bool,
558        is_oms_container: bool,
559        discretionary_up_to_limit_price: bool,
560        auto_cancel_date: String,
561        filled_quantity: f64,
562        ref_futures_con_id: i32,
563        auto_cancel_parent: bool,
564        shareholder: String,
565        imbalance_only: bool,
566        route_marketable_to_bbo: bool,
567        parent_perm_id: i32,
568        use_price_mgmt_algo: bool,
569    ) -> Self {
570        Order {
571            soft_dollar_tier,
572            order_id,
573            client_id,
574            perm_id,
575            action,
576            total_quantity,
577            order_type,
578            lmt_price,
579            aux_price,
580            tif,
581            active_start_time,
582            active_stop_time,
583            oca_group,
584            oca_type,
585            order_ref,
586            transmit,
587            parent_id,
588            block_order,
589            sweep_to_fill,
590            display_size,
591            trigger_method,
592            outside_rth,
593            hidden,
594            good_after_time,
595            good_till_date,
596            rule80a,
597            all_or_none,
598            min_qty,
599            percent_offset,
600            override_percentage_constraints,
601            trail_stop_price,
602            trailing_percent,
603            fa_group,
604            fa_profile,
605            fa_method,
606            fa_percentage,
607            designated_location,
608            open_close,
609            origin,
610            short_sale_slot,
611            exempt_code,
612            discretionary_amt,
613            e_trade_only,
614            firm_quote_only,
615            nbbo_price_cap,
616            opt_out_smart_routing,
617            auction_strategy,
618            starting_price,
619            stock_ref_price,
620            delta,
621            stock_range_lower,
622            stock_range_upper,
623            randomize_price,
624            randomize_size,
625            volatility,
626            volatility_type,
627            delta_neutral_order_type,
628            delta_neutral_aux_price,
629            delta_neutral_con_id,
630            delta_neutral_settling_firm,
631            delta_neutral_clearing_account,
632            delta_neutral_clearing_intent,
633            delta_neutral_open_close,
634            delta_neutral_short_sale,
635            delta_neutral_short_sale_slot,
636            delta_neutral_designated_location,
637            continuous_update,
638            reference_price_type,
639            basis_points,
640            basis_points_type,
641            scale_init_level_size,
642            scale_subs_level_size,
643            scale_price_increment,
644            scale_price_adjust_value,
645            scale_price_adjust_interval,
646            scale_profit_offset,
647            scale_auto_reset,
648            scale_init_position,
649            scale_init_fill_qty,
650            scale_random_percent,
651            scale_table,
652            hedge_type,
653            hedge_param,
654            account,
655            settling_firm,
656            clearing_account,
657            clearing_intent,
658            algo_strategy,
659            algo_params,
660            smart_combo_routing_params,
661            algo_id,
662            what_if,
663            not_held,
664            solicited,
665            model_code,
666            order_combo_legs,
667            order_misc_options,
668            reference_contract_id,
669            pegged_change_amount,
670            is_pegged_change_amount_decrease,
671            reference_change_amount,
672            reference_exchange_id,
673            adjusted_order_type,
674            trigger_price,
675            adjusted_stop_price,
676            adjusted_stop_limit_price,
677            adjusted_trailing_amount,
678            adjustable_trailing_unit,
679            lmt_price_offset,
680            conditions,
681            conditions_cancel_order,
682            conditions_ignore_rth,
683            ext_operator,
684            cash_qty,
685            mifid2decision_maker,
686            mifid2decision_algo,
687            mifid2execution_trader,
688            mifid2execution_algo,
689            dont_use_auto_price_for_hedge,
690            is_oms_container,
691            discretionary_up_to_limit_price,
692            auto_cancel_date,
693            filled_quantity,
694            ref_futures_con_id,
695            auto_cancel_parent,
696            shareholder,
697            imbalance_only,
698            route_marketable_to_bbo,
699            parent_perm_id,
700            use_price_mgmt_algo,
701        }
702    }
703}
704
705impl Display for Order {
706    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
707        write!(
708            f,
709            "order_id = {},
710             client_id = {},
711             perm_id = {},
712             order_type = {},
713             action = {},
714             total_quantity = {},
715             lmt_price = {},
716             tif = {},
717             what_if = {},
718             algo_strategy = {},
719             algo_params = ({}),
720             CMB = ({}),
721             COND = ({}),\n",
722            self.order_id,
723            self.client_id,
724            self.perm_id,
725            self.order_type,
726            self.action,
727            self.total_quantity,
728            if self.lmt_price == UNSET_DOUBLE {
729                format!("{:E}", self.lmt_price)
730            } else {
731                format!("{:?}", self.lmt_price)
732            },
733            self.tif,
734            self.what_if,
735            self.algo_strategy,
736            if !self.algo_params.is_empty() {
737                self.algo_params
738                    .iter()
739                    .map(|t| format!("{} = {}", t.tag, t.value))
740                    .collect::<Vec<String>>()
741                    .join(",")
742            } else {
743                "".to_string()
744            },
745            if !self.order_combo_legs.is_empty() {
746                self.order_combo_legs
747                    .iter()
748                    .map(|x| format!("{}", x))
749                    .collect::<Vec<String>>()
750                    .join(",")
751            } else {
752                "".to_string()
753            },
754            if !self.conditions.is_empty() {
755                self.conditions
756                    .iter()
757                    .map(|x| format!("{}|", x.make_fields().unwrap().as_slice().join(",")))
758                    .collect::<String>()
759            } else {
760                "".to_string()
761            },
762        )
763    }
764}
765
766impl Default for Order {
767    fn default() -> Self {
768        Order {
769            soft_dollar_tier: SoftDollarTier::new("".to_string(), "".to_string(), "".to_string()),
770            // order identifier
771            order_id: 0,
772            client_id: 0,
773            perm_id: 0,
774
775            // main order fields
776            action: "".to_string(),
777            total_quantity: 0.0,
778            order_type: "".to_string(),
779            lmt_price: UNSET_DOUBLE,
780            aux_price: UNSET_DOUBLE,
781
782            // extended order fields
783            tif: "".to_string(),               // "Time in Force" - DAY, GTC, etc.
784            active_start_time: "".to_string(), // for GTC orders
785            active_stop_time: "".to_string(),  // for GTC orders
786            oca_group: "".to_string(),         // one cancels all group name
787            oca_type: 0, // 1 = CANCEL_WITH_BLOCK, 2 = REDUCE_WITH_BLOCK, 3 = REDUCE_NON_BLOCK
788            order_ref: "".to_string(),
789            transmit: true, // if false, order will be created but not transmited
790            parent_id: 0, // Parent order Id, to associate Auto STP or TRAIL orders with the original order.
791            block_order: false,
792            sweep_to_fill: false,
793            display_size: 0,
794            trigger_method: 0, // 0=Default, 1=Double_Bid_Ask, 2=Last, 3=Double_Last, 4=Bid_Ask, 7=Last_or_Bid_Ask, 8=Mid-point
795            outside_rth: false,
796            hidden: false,
797            good_after_time: "".to_string(), // Format: 20060505 08:00:00 {time zone}
798            good_till_date: "".to_string(),  // Format: 20060505 08:00:00 {time zone}
799            rule80a: "".to_string(), // Individual = 'I', Agency = 'A', AgentOtherMember = 'W', IndividualPTIA = 'J', AgencyPTIA = 'U', AgentOtherMemberPTIA = 'M', IndividualPT = 'K', AgencyPT = 'Y', AgentOtherMemberPT = 'N'
800            all_or_none: false,
801            min_qty: UNSET_INTEGER,       //type: int
802            percent_offset: UNSET_DOUBLE, // type: float; REL orders only
803            override_percentage_constraints: false,
804            trail_stop_price: UNSET_DOUBLE, // type: float
805            trailing_percent: UNSET_DOUBLE, // type: float; TRAILLIMIT orders only
806
807            // financial advisors only
808            fa_group: "".to_string(),
809            fa_profile: "".to_string(),
810            fa_method: "".to_string(),
811            fa_percentage: "".to_string(),
812
813            // institutional (ie non-cleared) only
814            designated_location: "".to_string(), //used only when shortSaleSlot=2
815            open_close: "O".to_string(),         // O=Open, C=Close
816            origin: Customer,                    // 0=Customer, 1=Firm
817            short_sale_slot: 0, // type: int; 1 if you hold the shares, 2 if they will be delivered from elsewhere.  Only for Action=SSHORT
818            exempt_code: -1,
819
820            // SMART routing only
821            discretionary_amt: 0.0,
822            e_trade_only: true,
823            firm_quote_only: true,
824            nbbo_price_cap: UNSET_DOUBLE, // type: float
825            opt_out_smart_routing: false,
826
827            // BOX exchange orders only
828            auction_strategy: AuctionUnset, // type: int; AUCTION_MATCH, AUCTION_IMPROVEMENT, AUCTION_TRANSPARENT
829            starting_price: UNSET_DOUBLE,   // type: float
830            stock_ref_price: UNSET_DOUBLE,  // type: float
831            delta: UNSET_DOUBLE,            // type: float
832
833            // pegged to stock and VOL orders only
834            stock_range_lower: UNSET_DOUBLE, // type: float
835            stock_range_upper: UNSET_DOUBLE, // type: float
836
837            randomize_price: false,
838            randomize_size: false,
839
840            // VOLATILITY ORDERS ONLY
841            volatility: UNSET_DOUBLE,       // type: float
842            volatility_type: UNSET_INTEGER, // type: int   // 1=daily, 2=annual
843            delta_neutral_order_type: "".to_string(),
844            delta_neutral_aux_price: UNSET_DOUBLE, // type: float
845            delta_neutral_con_id: 0,
846            delta_neutral_settling_firm: "".to_string(),
847            delta_neutral_clearing_account: "".to_string(),
848            delta_neutral_clearing_intent: "".to_string(),
849            delta_neutral_open_close: "".to_string(),
850            delta_neutral_short_sale: false,
851            delta_neutral_short_sale_slot: 0,
852            delta_neutral_designated_location: "".to_string(),
853            continuous_update: false,
854            reference_price_type: UNSET_INTEGER, // type: int; 1=Average, 2 = BidOrAsk
855
856            // COMBO ORDERS ONLY
857            basis_points: UNSET_DOUBLE, // type: float; EFP orders only
858            basis_points_type: UNSET_INTEGER, // type: int;  EFP orders only
859
860            // SCALE ORDERS ONLY
861            scale_init_level_size: UNSET_INTEGER,   // type: int
862            scale_subs_level_size: UNSET_INTEGER,   // type: int
863            scale_price_increment: UNSET_DOUBLE,    // type: float
864            scale_price_adjust_value: UNSET_DOUBLE, // type: float
865            scale_price_adjust_interval: UNSET_INTEGER, // type: int
866            scale_profit_offset: UNSET_DOUBLE,      // type: float
867            scale_auto_reset: false,
868            scale_init_position: UNSET_INTEGER, // type: int
869            scale_init_fill_qty: UNSET_INTEGER, // type: int
870            scale_random_percent: false,
871            scale_table: "".to_string(),
872
873            // HEDGE ORDERS
874            hedge_type: "".to_string(), // 'D' - delta, 'B' - beta, 'F' - FX, 'P' - pair
875            hedge_param: "".to_string(), // 'beta=X' value for beta hedge, 'ratio=Y' for pair hedge
876
877            // Clearing info
878            account: "".to_string(), // IB account
879            settling_firm: "".to_string(),
880            clearing_account: "".to_string(), //True beneficiary of the order
881            clearing_intent: "".to_string(),  // "" (Default), "IB", "Away", "PTA" (PostTrade)
882
883            // ALGO ORDERS ONLY
884            algo_strategy: "".to_string(),
885
886            algo_params: vec![],                //TagValueList
887            smart_combo_routing_params: vec![], //TagValueList
888
889            algo_id: "".to_string(),
890
891            // What-if
892            what_if: false,
893
894            // Not Held
895            not_held: false,
896            solicited: false,
897
898            // models
899            model_code: "".to_string(),
900
901            // order combo legs
902            order_combo_legs: vec![], // OrderComboLegListSPtr
903
904            order_misc_options: vec![], // TagValueList
905
906            // VER PEG2BENCH fields:
907            reference_contract_id: 0,
908            pegged_change_amount: 0.0,
909            is_pegged_change_amount_decrease: false,
910            reference_change_amount: 0.0,
911            reference_exchange_id: "".to_string(),
912            adjusted_order_type: "".to_string(),
913
914            trigger_price: UNSET_DOUBLE,
915            adjusted_stop_price: UNSET_DOUBLE,
916            adjusted_stop_limit_price: UNSET_DOUBLE,
917            adjusted_trailing_amount: UNSET_DOUBLE,
918            adjustable_trailing_unit: 0,
919            lmt_price_offset: UNSET_DOUBLE,
920
921            conditions: vec![], // std::vector<std::shared_ptr<OrderCondition>>
922            conditions_cancel_order: false,
923            conditions_ignore_rth: false,
924
925            // ext operator
926            ext_operator: "".to_string(),
927
928            // native cash quantity
929            cash_qty: UNSET_DOUBLE,
930
931            mifid2decision_maker: "".to_string(),
932            mifid2decision_algo: "".to_string(),
933            mifid2execution_trader: "".to_string(),
934            mifid2execution_algo: "".to_string(),
935
936            dont_use_auto_price_for_hedge: false,
937
938            is_oms_container: false,
939
940            discretionary_up_to_limit_price: false,
941
942            auto_cancel_date: "".to_string(),
943            filled_quantity: UNSET_DOUBLE,
944            ref_futures_con_id: 0,
945            auto_cancel_parent: false,
946            shareholder: "".to_string(),
947            imbalance_only: false,
948            route_marketable_to_bbo: false,
949            parent_perm_id: 0,
950
951            use_price_mgmt_algo: false,
952        }
953    }
954}