Skip to main content

truefix_twsapi_client/
constants.rs

1use rust_decimal::Decimal;
2
3/// TWS API's sentinel for "no valid request/order id".
4pub const NO_VALID_ID: i32 = -1;
5
6/// Maximum message length used by the official client: 16 MiB minus one byte.
7pub const MAX_MSG_LEN: usize = 0xFF_FFFF;
8
9/// TWS API integer unset sentinel.
10pub const UNSET_INTEGER: i32 = i32::MAX;
11
12/// TWS API double unset sentinel.
13pub const UNSET_DOUBLE: f64 = f64::MAX;
14
15/// TWS API long unset sentinel.
16pub const UNSET_LONG: i64 = i64::MAX;
17
18/// TWS API's sentinel for an unset decimal field.
19pub const UNSET_DECIMAL: Decimal = Decimal::MAX;
20
21/// String representation used by the official client for positive infinity.
22pub const INFINITY_STR: &str = "Infinity";
23
24/// PEG BEST sentinel requesting competition up to the midpoint.
25pub const COMPETE_AGAINST_BEST_OFFSET_UP_TO_MID: f64 = f64::INFINITY;
26
27/// Standard tags accepted by `reqAccountSummary`.
28pub struct AccountSummaryTags;
29
30impl AccountSummaryTags {
31    pub const ACCOUNT_TYPE: &str = "AccountType";
32    pub const NET_LIQUIDATION: &str = "NetLiquidation";
33    pub const TOTAL_CASH_VALUE: &str = "TotalCashValue";
34    pub const SETTLED_CASH: &str = "SettledCash";
35    pub const ACCRUED_CASH: &str = "AccruedCash";
36    pub const BUYING_POWER: &str = "BuyingPower";
37    pub const EQUITY_WITH_LOAN_VALUE: &str = "EquityWithLoanValue";
38    pub const PREVIOUS_DAY_EQUITY_WITH_LOAN_VALUE: &str = "PreviousDayEquityWithLoanValue";
39    pub const GROSS_POSITION_VALUE: &str = "GrossPositionValue";
40    pub const REQ_T_EQUITY: &str = "ReqTEquity";
41    pub const REQ_T_MARGIN: &str = "ReqTMargin";
42    pub const SMA: &str = "SMA";
43    pub const INIT_MARGIN_REQ: &str = "InitMarginReq";
44    pub const MAINT_MARGIN_REQ: &str = "MaintMarginReq";
45    pub const AVAILABLE_FUNDS: &str = "AvailableFunds";
46    pub const EXCESS_LIQUIDITY: &str = "ExcessLiquidity";
47    pub const CUSHION: &str = "Cushion";
48    pub const FULL_INIT_MARGIN_REQ: &str = "FullInitMarginReq";
49    pub const FULL_MAINT_MARGIN_REQ: &str = "FullMaintMarginReq";
50    pub const FULL_AVAILABLE_FUNDS: &str = "FullAvailableFunds";
51    pub const FULL_EXCESS_LIQUIDITY: &str = "FullExcessLiquidity";
52    pub const LOOK_AHEAD_NEXT_CHANGE: &str = "LookAheadNextChange";
53    pub const LOOK_AHEAD_INIT_MARGIN_REQ: &str = "LookAheadInitMarginReq";
54    pub const LOOK_AHEAD_MAINT_MARGIN_REQ: &str = "LookAheadMaintMarginReq";
55    pub const LOOK_AHEAD_AVAILABLE_FUNDS: &str = "LookAheadAvailableFunds";
56    pub const LOOK_AHEAD_EXCESS_LIQUIDITY: &str = "LookAheadExcessLiquidity";
57    pub const HIGHEST_SEVERITY: &str = "HighestSeverity";
58    pub const DAY_TRADES_REMAINING: &str = "DayTradesRemaining";
59    pub const LEVERAGE: &str = "Leverage";
60
61    /// All tags in the order used by the official Python client.
62    pub const ALL: &str = "AccountType,NetLiquidation,TotalCashValue,SettledCash,AccruedCash,BuyingPower,EquityWithLoanValue,PreviousDayEquityWithLoanValue,GrossPositionValue,ReqTEquity,ReqTMargin,SMA,InitMarginReq,MaintMarginReq,AvailableFunds,ExcessLiquidity,Cushion,FullInitMarginReq,FullMaintMarginReq,FullAvailableFunds,FullExcessLiquidity,LookAheadNextChange,LookAheadInitMarginReq,LookAheadMaintMarginReq,LookAheadAvailableFunds,LookAheadExcessLiquidity,HighestSeverity,DayTradesRemaining,Leverage";
63    /// Descriptive alias for [`Self::ALL`].
64    pub const ALL_TAGS: &str = Self::ALL;
65}
66
67/// TWS error code and its standard description prefix.
68#[derive(Debug, Clone, Copy, PartialEq, Eq)]
69pub struct ErrorCode {
70    pub code: i32,
71    pub message: &'static str,
72}
73
74impl ErrorCode {
75    pub const ALREADY_CONNECTED: Self = Self {
76        code: 501,
77        message: "Already connected.",
78    };
79    pub const CONNECT_FAIL: Self = Self {
80        code: 502,
81        message: "Couldn't connect to TWS.",
82    };
83    pub const UPDATE_TWS: Self = Self {
84        code: 503,
85        message: "The TWS is out of date and must be upgraded.",
86    };
87    pub const NOT_CONNECTED: Self = Self {
88        code: 504,
89        message: "Not connected",
90    };
91    pub const UNKNOWN_ID: Self = Self {
92        code: 505,
93        message: "Fatal Error: Unknown message id.",
94    };
95    pub const BAD_LENGTH: Self = Self {
96        code: 507,
97        message: "Bad message length",
98    };
99    pub const BAD_MESSAGE: Self = Self {
100        code: 508,
101        message: "Bad message",
102    };
103    pub const FAIL_SEND_ACCT: Self = Self {
104        code: 513,
105        message: "Account Update Request Sending Error - ",
106    };
107    pub const FAIL_SEND_EXEC: Self = Self {
108        code: 514,
109        message: "Request For Executions Sending Error - ",
110    };
111    pub const FAIL_SEND_CORDER: Self = Self {
112        code: 515,
113        message: "Cancel Order Sending Error - ",
114    };
115    pub const FAIL_SEND_OORDER: Self = Self {
116        code: 516,
117        message: "Request Open Order Sending Error - ",
118    };
119    pub const FAIL_SEND_REQ_MKT_DEPTH: Self = Self {
120        code: 519,
121        message: "Request Market Depth Sending Error - ",
122    };
123    pub const FAIL_CREATE_SOCK: Self = Self {
124        code: 520,
125        message: "Failed to create socket",
126    };
127    pub const FAIL_SEND_SERVER_LOG_LEVEL: Self = Self {
128        code: 521,
129        message: "Set Server Log Level Sending Error - ",
130    };
131    pub const FAIL_SEND_FA_REQUEST: Self = Self {
132        code: 522,
133        message: "FA Information Request Sending Error - ",
134    };
135    pub const FAIL_SEND_FA_REPLACE: Self = Self {
136        code: 523,
137        message: "FA Information Replace Sending Error - ",
138    };
139    pub const FAIL_SEND_REQ_SCANNER: Self = Self {
140        code: 524,
141        message: "Request Scanner Subscription Sending Error - ",
142    };
143    pub const FAIL_SEND_CAN_SCANNER: Self = Self {
144        code: 525,
145        message: "Cancel Scanner Subscription Sending Error - ",
146    };
147    pub const FAIL_SEND_REQ_SCANNER_PARAMETERS: Self = Self {
148        code: 526,
149        message: "Request Scanner Parameter Sending Error - ",
150    };
151    pub const FAIL_SEND_REQ_CALC_IMPLIED_VOLAT: Self = Self {
152        code: 534,
153        message: "Request Calculate Implied Volatility Sending Error - ",
154    };
155    pub const FAIL_SEND_REQ_CALC_OPTION_PRICE: Self = Self {
156        code: 535,
157        message: "Request Calculate Option Price Sending Error - ",
158    };
159    pub const FAIL_SEND_CAN_CALC_IMPLIED_VOLAT: Self = Self {
160        code: 536,
161        message: "Cancel Calculate Implied Volatility Sending Error - ",
162    };
163    pub const FAIL_SEND_CAN_CALC_OPTION_PRICE: Self = Self {
164        code: 537,
165        message: "Cancel Calculate Option Price Sending Error - ",
166    };
167    pub const FAIL_SEND_REQ_GLOBAL_CANCEL: Self = Self {
168        code: 538,
169        message: "Request Global Cancel Sending Error - ",
170    };
171    pub const FAIL_SEND_REQ_MARKET_DATA_TYPE: Self = Self {
172        code: 539,
173        message: "Request Market Data Type Sending Error - ",
174    };
175    pub const FAIL_SEND_CAN_ACCOUNT_DATA: Self = Self {
176        code: 543,
177        message: "Cancel Account Data Sending Error - ",
178    };
179    pub const FAIL_SEND_VERIFY_REQUEST: Self = Self {
180        code: 544,
181        message: "Verify Request Sending Error - ",
182    };
183    pub const FAIL_SEND_VERIFY_MESSAGE: Self = Self {
184        code: 545,
185        message: "Verify Message Sending Error - ",
186    };
187    pub const FAIL_SEND_QUERY_DISPLAY_GROUPS: Self = Self {
188        code: 546,
189        message: "Query Display Groups Sending Error - ",
190    };
191    pub const FAIL_SEND_SUBSCRIBE_TO_GROUP_EVENTS: Self = Self {
192        code: 547,
193        message: "Subscribe To Group Events Sending Error - ",
194    };
195    pub const FAIL_SEND_UPDATE_DISPLAY_GROUP: Self = Self {
196        code: 548,
197        message: "Update Display Group Sending Error - ",
198    };
199    pub const FAIL_SEND_UNSUBSCRIBE_FROM_GROUP_EVENTS: Self = Self {
200        code: 549,
201        message: "Unsubscribe From Group Events Sending Error - ",
202    };
203    pub const FAIL_SEND_START_API: Self = Self {
204        code: 550,
205        message: "Start API Sending Error - ",
206    };
207    pub const FAIL_SEND_VERIFY_AND_AUTH_REQUEST: Self = Self {
208        code: 551,
209        message: "Verify And Auth Request Sending Error - ",
210    };
211    pub const FAIL_SEND_VERIFY_AND_AUTH_MESSAGE: Self = Self {
212        code: 552,
213        message: "Verify And Auth Message Sending Error - ",
214    };
215    pub const FAIL_SEND_REQ_POSITIONS_MULTI: Self = Self {
216        code: 553,
217        message: "Request Positions Multi Sending Error - ",
218    };
219    pub const FAIL_SEND_CAN_POSITIONS_MULTI: Self = Self {
220        code: 554,
221        message: "Cancel Positions Multi Sending Error - ",
222    };
223    pub const FAIL_SEND_REQ_ACCOUNT_UPDATES_MULTI: Self = Self {
224        code: 555,
225        message: "Request Account Updates Multi Sending Error - ",
226    };
227    pub const FAIL_SEND_CAN_ACCOUNT_UPDATES_MULTI: Self = Self {
228        code: 556,
229        message: "Cancel Account Updates Multi Sending Error - ",
230    };
231    pub const FAIL_SEND_REQ_SEC_DEF_OPT_PARAMS: Self = Self {
232        code: 557,
233        message: "Request Security Definition Option Params Sending Error - ",
234    };
235    pub const FAIL_SEND_REQ_SOFT_DOLLAR_TIERS: Self = Self {
236        code: 558,
237        message: "Request Soft Dollar Tiers Sending Error - ",
238    };
239    pub const FAIL_SEND_REQ_FAMILY_CODES: Self = Self {
240        code: 559,
241        message: "Request Family Codes Sending Error - ",
242    };
243    pub const FAIL_SEND_REQ_MATCHING_SYMBOLS: Self = Self {
244        code: 560,
245        message: "Request Matching Symbols Sending Error - ",
246    };
247    pub const FAIL_SEND_REQ_MKT_DEPTH_EXCHANGES: Self = Self {
248        code: 561,
249        message: "Request Market Depth Exchanges Sending Error - ",
250    };
251    pub const FAIL_SEND_REQ_SMART_COMPONENTS: Self = Self {
252        code: 562,
253        message: "Request Smart Components Sending Error - ",
254    };
255    pub const FAIL_SEND_REQ_NEWS_PROVIDERS: Self = Self {
256        code: 563,
257        message: "Request News Providers Sending Error - ",
258    };
259    pub const FAIL_SEND_REQ_NEWS_ARTICLE: Self = Self {
260        code: 564,
261        message: "Request News Article Sending Error - ",
262    };
263    pub const FAIL_SEND_REQ_HISTORICAL_NEWS: Self = Self {
264        code: 565,
265        message: "Request Historical News Sending Error - ",
266    };
267    pub const FAIL_SEND_REQ_HEAD_TIMESTAMP: Self = Self {
268        code: 566,
269        message: "Request Head Time Stamp Sending Error - ",
270    };
271    pub const FAIL_SEND_REQ_HISTOGRAM_DATA: Self = Self {
272        code: 567,
273        message: "Request Histogram Data Sending Error - ",
274    };
275    pub const FAIL_SEND_CANCEL_HISTOGRAM_DATA: Self = Self {
276        code: 568,
277        message: "Cancel Request Histogram Data Sending Error - ",
278    };
279    pub const FAIL_SEND_CANCEL_HEAD_TIMESTAMP: Self = Self {
280        code: 569,
281        message: "Cancel Head Time Stamp Sending Error - ",
282    };
283    pub const FAIL_SEND_REQ_MARKET_RULE: Self = Self {
284        code: 570,
285        message: "Request Market Rule Sending Error - ",
286    };
287    pub const FAIL_SEND_REQ_PNL: Self = Self {
288        code: 571,
289        message: "Request PnL Sending Error - ",
290    };
291    pub const FAIL_SEND_CANCEL_PNL: Self = Self {
292        code: 572,
293        message: "Cancel PnL Sending Error - ",
294    };
295    pub const FAIL_SEND_REQ_PNL_SINGLE: Self = Self {
296        code: 573,
297        message: "Request PnL Single Error - ",
298    };
299    pub const FAIL_SEND_CANCEL_PNL_SINGLE: Self = Self {
300        code: 574,
301        message: "Cancel PnL Single Sending Error - ",
302    };
303    pub const FAIL_SEND_REQ_HISTORICAL_TICKS: Self = Self {
304        code: 575,
305        message: "Request Historical Ticks Error - ",
306    };
307    pub const FAIL_SEND_REQ_TICK_BY_TICK_DATA: Self = Self {
308        code: 576,
309        message: "Request Tick-By-Tick Data Sending Error - ",
310    };
311    pub const FAIL_SEND_CANCEL_TICK_BY_TICK_DATA: Self = Self {
312        code: 577,
313        message: "Cancel Tick-By-Tick Data Sending Error - ",
314    };
315    pub const FAIL_SEND_REQ_COMPLETED_ORDERS: Self = Self {
316        code: 578,
317        message: "Request Completed Orders Sending Error - ",
318    };
319    pub const FAIL_SEND_REQ_WSH_META_DATA: Self = Self {
320        code: 580,
321        message: "Request WSH Meta Data Sending Error - ",
322    };
323    pub const FAIL_SEND_CAN_WSH_META_DATA: Self = Self {
324        code: 581,
325        message: "Cancel WSH Meta Data Sending Error - ",
326    };
327    pub const FAIL_SEND_REQ_WSH_EVENT_DATA: Self = Self {
328        code: 582,
329        message: "Request WSH Event Data Sending Error - ",
330    };
331    pub const FAIL_SEND_CAN_WSH_EVENT_DATA: Self = Self {
332        code: 583,
333        message: "Cancel WSH Event Data Sending Error - ",
334    };
335    pub const FAIL_SEND_REQ_USER_INFO: Self = Self {
336        code: 584,
337        message: "Request User Info Sending Error - ",
338    };
339    pub const FA_PROFILE_NOT_SUPPORTED: Self = Self {
340        code: 585,
341        message: "FA Profile is not supported anymore, use FA Group instead - ",
342    };
343    pub const FAIL_SEND_REQ_CURRENT_TIME_IN_MILLIS: Self = Self {
344        code: 587,
345        message: "Request Current Time In Millis Sending Error - ",
346    };
347    pub const FAIL_SEND_CAN_MKT_DEPTH: Self = Self {
348        code: 589,
349        message: "Cancel Market Depth Sending Error - ",
350    };
351    pub const FAIL_SEND_CANCEL_CONTRACT_DATA: Self = Self {
352        code: 590,
353        message: "Cancel Contract Data Sending Error - ",
354    };
355    pub const FAIL_SEND_CANCEL_HISTORICAL_TICKS: Self = Self {
356        code: 591,
357        message: "Cancel Historical Ticks Sending Error - ",
358    };
359    pub const FAIL_SEND_REQ_CONFIG: Self = Self {
360        code: 592,
361        message: "Request Config Sending Error - ",
362    };
363    pub const FAIL_SEND_UPDATE_CONFIG: Self = Self {
364        code: 593,
365        message: "Update Config Request Sending Error - ",
366    };
367    pub const FAIL_SEND_REQ_MKT_DATA: Self = Self {
368        code: 510,
369        message: "Request Market Data Sending Error - ",
370    };
371    pub const FAIL_SEND_CAN_MKT_DATA: Self = Self {
372        code: 511,
373        message: "Cancel Market Data Sending Error - ",
374    };
375    pub const FAIL_SEND_ORDER: Self = Self {
376        code: 512,
377        message: "Order Sending Error - ",
378    };
379    pub const FAIL_SEND_CANCEL_ORDER: Self = Self::FAIL_SEND_CORDER;
380    pub const FAIL_SEND_REQ_CONTRACT_DATA: Self = Self {
381        code: 518,
382        message: "Request Contract Data Sending Error - ",
383    };
384    pub const FAIL_SEND_REQ_HISTORICAL_DATA: Self = Self {
385        code: 527,
386        message: "Request Historical Data Sending Error - ",
387    };
388    pub const FAIL_SEND_CAN_HISTORICAL_DATA: Self = Self {
389        code: 528,
390        message: "Request Historical Data Sending Error - ",
391    };
392    pub const FAIL_SEND_REQ_REAL_TIME_BARS: Self = Self {
393        code: 529,
394        message: "Request Real-time Bar Data Sending Error - ",
395    };
396    pub const FAIL_SEND_CAN_REAL_TIME_BARS: Self = Self {
397        code: 530,
398        message: "Cancel Real-time Bar Data Sending Error - ",
399    };
400    pub const FAIL_SEND_REQ_CURRENT_TIME: Self = Self {
401        code: 531,
402        message: "Request Current Time Sending Error - ",
403    };
404    pub const FAIL_SEND_REQ_POSITIONS: Self = Self {
405        code: 540,
406        message: "Request Positions Sending Error - ",
407    };
408    pub const FAIL_SEND_CAN_POSITIONS: Self = Self {
409        code: 541,
410        message: "Cancel Positions Sending Error - ",
411    };
412    pub const FAIL_SEND_REQ_ACCOUNT_DATA: Self = Self {
413        code: 542,
414        message: "Request Account Data Sending Error - ",
415    };
416    pub const INVALID_SYMBOL: Self = Self {
417        code: 579,
418        message: "Invalid symbol in string - ",
419    };
420    pub const ERROR_ENCODING_PROTOBUF: Self = Self {
421        code: 588,
422        message: "Error encoding protobuf - ",
423    };
424
425    /// Common client-side errors from the official Python error catalog.
426    pub const ALL: &[Self] = &[
427        Self {
428            code: 501,
429            message: "Already connected.",
430        },
431        Self {
432            code: 502,
433            message: "Couldn't connect to TWS.",
434        },
435        Self {
436            code: 503,
437            message: "The TWS is out of date and must be upgraded.",
438        },
439        Self {
440            code: 504,
441            message: "Not connected",
442        },
443        Self {
444            code: 505,
445            message: "Fatal Error: Unknown message id.",
446        },
447        Self {
448            code: 507,
449            message: "Bad message length",
450        },
451        Self {
452            code: 508,
453            message: "Bad message",
454        },
455        Self {
456            code: 510,
457            message: "Request Market Data Sending Error - ",
458        },
459        Self {
460            code: 511,
461            message: "Cancel Market Data Sending Error - ",
462        },
463        Self {
464            code: 512,
465            message: "Order Sending Error - ",
466        },
467        Self {
468            code: 513,
469            message: "Account Update Request Sending Error - ",
470        },
471        Self {
472            code: 514,
473            message: "Request For Executions Sending Error - ",
474        },
475        Self {
476            code: 515,
477            message: "Cancel Order Sending Error - ",
478        },
479        Self {
480            code: 516,
481            message: "Request Open Order Sending Error - ",
482        },
483        Self {
484            code: 518,
485            message: "Request Contract Data Sending Error - ",
486        },
487        Self {
488            code: 519,
489            message: "Request Market Depth Sending Error - ",
490        },
491        Self {
492            code: 520,
493            message: "Failed to create socket",
494        },
495        Self {
496            code: 521,
497            message: "Set Server Log Level Sending Error - ",
498        },
499        Self {
500            code: 522,
501            message: "FA Information Request Sending Error - ",
502        },
503        Self {
504            code: 523,
505            message: "FA Information Replace Sending Error - ",
506        },
507        Self {
508            code: 524,
509            message: "Request Scanner Subscription Sending Error - ",
510        },
511        Self {
512            code: 525,
513            message: "Cancel Scanner Subscription Sending Error - ",
514        },
515        Self {
516            code: 526,
517            message: "Request Scanner Parameter Sending Error - ",
518        },
519        Self {
520            code: 527,
521            message: "Request Historical Data Sending Error - ",
522        },
523        Self {
524            code: 528,
525            message: "Request Historical Data Sending Error - ",
526        },
527        Self {
528            code: 529,
529            message: "Request Real-time Bar Data Sending Error - ",
530        },
531        Self {
532            code: 530,
533            message: "Cancel Real-time Bar Data Sending Error - ",
534        },
535        Self {
536            code: 531,
537            message: "Request Current Time Sending Error - ",
538        },
539        Self {
540            code: 534,
541            message: "Request Calculate Implied Volatility Sending Error - ",
542        },
543        Self {
544            code: 535,
545            message: "Request Calculate Option Price Sending Error - ",
546        },
547        Self {
548            code: 536,
549            message: "Cancel Calculate Implied Volatility Sending Error - ",
550        },
551        Self {
552            code: 537,
553            message: "Cancel Calculate Option Price Sending Error - ",
554        },
555        Self {
556            code: 538,
557            message: "Request Global Cancel Sending Error - ",
558        },
559        Self {
560            code: 539,
561            message: "Request Market Data Type Sending Error - ",
562        },
563        Self {
564            code: 540,
565            message: "Request Positions Sending Error - ",
566        },
567        Self {
568            code: 541,
569            message: "Cancel Positions Sending Error - ",
570        },
571        Self {
572            code: 542,
573            message: "Request Account Data Sending Error - ",
574        },
575        Self {
576            code: 543,
577            message: "Cancel Account Data Sending Error - ",
578        },
579        Self {
580            code: 544,
581            message: "Verify Request Sending Error - ",
582        },
583        Self {
584            code: 545,
585            message: "Verify Message Sending Error - ",
586        },
587        Self {
588            code: 546,
589            message: "Query Display Groups Sending Error - ",
590        },
591        Self {
592            code: 547,
593            message: "Subscribe To Group Events Sending Error - ",
594        },
595        Self {
596            code: 548,
597            message: "Update Display Group Sending Error - ",
598        },
599        Self {
600            code: 549,
601            message: "Unsubscribe From Group Events Sending Error - ",
602        },
603        Self {
604            code: 550,
605            message: "Start API Sending Error - ",
606        },
607        Self {
608            code: 551,
609            message: "Verify And Auth Request Sending Error - ",
610        },
611        Self {
612            code: 552,
613            message: "Verify And Auth Message Sending Error - ",
614        },
615        Self {
616            code: 553,
617            message: "Request Positions Multi Sending Error - ",
618        },
619        Self {
620            code: 554,
621            message: "Cancel Positions Multi Sending Error - ",
622        },
623        Self {
624            code: 555,
625            message: "Request Account Updates Multi Sending Error - ",
626        },
627        Self {
628            code: 556,
629            message: "Cancel Account Updates Multi Sending Error - ",
630        },
631        Self {
632            code: 557,
633            message: "Request Security Definition Option Params Sending Error - ",
634        },
635        Self {
636            code: 558,
637            message: "Request Soft Dollar Tiers Sending Error - ",
638        },
639        Self {
640            code: 559,
641            message: "Request Family Codes Sending Error - ",
642        },
643        Self {
644            code: 560,
645            message: "Request Matching Symbols Sending Error - ",
646        },
647        Self {
648            code: 561,
649            message: "Request Market Depth Exchanges Sending Error - ",
650        },
651        Self {
652            code: 562,
653            message: "Request Smart Components Sending Error - ",
654        },
655        Self {
656            code: 563,
657            message: "Request News Providers Sending Error - ",
658        },
659        Self {
660            code: 564,
661            message: "Request News Article Sending Error - ",
662        },
663        Self {
664            code: 565,
665            message: "Request Historical News Sending Error - ",
666        },
667        Self {
668            code: 566,
669            message: "Request Head Time Stamp Sending Error - ",
670        },
671        Self {
672            code: 567,
673            message: "Request Histogram Data Sending Error - ",
674        },
675        Self {
676            code: 568,
677            message: "Cancel Request Histogram Data Sending Error - ",
678        },
679        Self {
680            code: 569,
681            message: "Cancel Head Time Stamp Sending Error - ",
682        },
683        Self {
684            code: 570,
685            message: "Request Market Rule Sending Error - ",
686        },
687        Self {
688            code: 571,
689            message: "Request PnL Sending Error - ",
690        },
691        Self {
692            code: 572,
693            message: "Cancel PnL Sending Error - ",
694        },
695        Self {
696            code: 573,
697            message: "Request PnL Single Error - ",
698        },
699        Self {
700            code: 574,
701            message: "Cancel PnL Single Sending Error - ",
702        },
703        Self {
704            code: 575,
705            message: "Request Historical Ticks Error - ",
706        },
707        Self {
708            code: 576,
709            message: "Request Tick-By-Tick Data Sending Error - ",
710        },
711        Self {
712            code: 577,
713            message: "Cancel Tick-By-Tick Data Sending Error - ",
714        },
715        Self {
716            code: 578,
717            message: "Request Completed Orders Sending Error - ",
718        },
719        Self {
720            code: 579,
721            message: "Invalid symbol in string - ",
722        },
723        Self {
724            code: 580,
725            message: "Request WSH Meta Data Sending Error - ",
726        },
727        Self {
728            code: 581,
729            message: "Cancel WSH Meta Data Sending Error - ",
730        },
731        Self {
732            code: 582,
733            message: "Request WSH Event Data Sending Error - ",
734        },
735        Self {
736            code: 583,
737            message: "Cancel WSH Event Data Sending Error - ",
738        },
739        Self {
740            code: 584,
741            message: "Request User Info Sending Error - ",
742        },
743        Self {
744            code: 585,
745            message: "FA Profile is not supported anymore, use FA Group instead - ",
746        },
747        Self {
748            code: 587,
749            message: "Request Current Time In Millis Sending Error - ",
750        },
751        Self {
752            code: 588,
753            message: "Error encoding protobuf - ",
754        },
755        Self {
756            code: 589,
757            message: "Cancel Market Depth Sending Error - ",
758        },
759        Self {
760            code: 590,
761            message: "Cancel Contract Data Sending Error - ",
762        },
763        Self {
764            code: 591,
765            message: "Cancel Historical Ticks Sending Error - ",
766        },
767        Self {
768            code: 592,
769            message: "Request Config Sending Error - ",
770        },
771        Self {
772            code: 593,
773            message: "Update Config Request Sending Error - ",
774        },
775    ];
776
777    pub fn from_code(code: i32) -> Option<Self> {
778        Self::ALL.iter().find(|error| error.code == code).copied()
779    }
780}
781
782/// News bulletin message types.
783pub mod news {
784    pub const NEWS_MSG: i32 = 1;
785    pub const EXCHANGE_AVAIL_MSG: i32 = 2;
786    pub const EXCHANGE_UNAVAIL_MSG: i32 = 3;
787}