1#![allow(missing_docs)]
2
3use std::collections::HashMap;
4
5use num_enum::{FromPrimitive, IntoPrimitive};
6use rust_decimal::Decimal;
7use serde::{Deserialize, Serialize};
8use strum_macros::{Display, EnumString};
9use time::OffsetDateTime;
10
11use crate::utils::counter::deserialize_counter_id_as_symbol;
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct FinancialReports {
22 pub list: serde_json::Value,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct DividendList {
33 pub list: Vec<DividendItem>,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct DividendItem {
40 #[serde(
42 rename = "counter_id",
43 deserialize_with = "deserialize_counter_id_as_symbol"
44 )]
45 pub symbol: String,
46 #[serde(default)]
48 pub id: String,
49 pub desc: String,
51 pub record_date: String,
53 pub ex_date: String,
55 pub payment_date: String,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct InstitutionRating {
65 pub latest: InstitutionRatingLatest,
67 pub summary: InstitutionRatingSummary,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
73pub struct InstitutionRatingLatest {
74 pub evaluate: RatingEvaluate,
76 pub target: RatingTarget,
78 pub industry_id: i64,
80 pub industry_name: String,
82 pub industry_rank: i32,
84 pub industry_total: i32,
86 pub industry_mean: i32,
88 pub industry_median: i32,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize)]
94pub struct RatingEvaluate {
95 pub buy: i32,
97 pub over: i32,
99 pub hold: i32,
101 pub under: i32,
103 pub sell: i32,
105 pub no_opinion: i32,
107 pub total: i32,
109 pub start_date: String,
111 pub end_date: String,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117pub struct RatingTarget {
118 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
120 pub highest_price: Option<Decimal>,
121 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
123 pub lowest_price: Option<Decimal>,
124 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
126 pub prev_close: Option<Decimal>,
127 pub start_date: String,
129 pub end_date: String,
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
135pub struct InstitutionRatingSummary {
136 pub ccy_symbol: String,
138 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
140 pub change: Option<Decimal>,
141 pub evaluate: RatingSummaryEvaluate,
143 pub recommend: InstitutionRecommend,
145 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
147 pub target: Option<Decimal>,
148 pub updated_at: String,
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
154pub struct RatingSummaryEvaluate {
155 pub buy: i32,
157 pub date: String,
159 pub hold: i32,
161 pub sell: i32,
163 pub strong_buy: i32,
165 pub under: i32,
167}
168
169#[derive(Debug, Clone, Serialize, Deserialize)]
173pub struct InstitutionRatingDetail {
174 pub ccy_symbol: String,
176 pub evaluate: InstitutionRatingDetailEvaluate,
178 pub target: InstitutionRatingDetailTarget,
180}
181
182#[derive(Debug, Clone, Serialize, Deserialize)]
184pub struct InstitutionRatingDetailEvaluate {
185 pub list: Vec<InstitutionRatingDetailEvaluateItem>,
187}
188
189#[derive(Debug, Clone, Serialize, Deserialize)]
191pub struct InstitutionRatingDetailEvaluateItem {
192 pub buy: i32,
194 pub date: String,
196 pub hold: i32,
198 pub sell: i32,
200 #[serde(default)]
202 pub strong_buy: i32,
203 #[serde(default)]
205 pub no_opinion: i32,
206 pub under: i32,
208}
209
210#[derive(Debug, Clone, Serialize, Deserialize)]
212pub struct InstitutionRatingDetailTarget {
213 pub data_percent: Option<Decimal>,
215 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
217 pub prediction_accuracy: Option<Decimal>,
218 pub updated_at: String,
220 pub list: Vec<InstitutionRatingDetailTargetItem>,
222}
223
224#[derive(Debug, Clone, Serialize, Deserialize)]
226pub struct InstitutionRatingDetailTargetItem {
227 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
229 pub avg_target: Option<Decimal>,
230 pub date: String,
232 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
234 pub max_target: Option<Decimal>,
235 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
237 pub min_target: Option<Decimal>,
238 pub meet: bool,
240 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
242 pub price: Option<Decimal>,
243 pub timestamp: String,
245}
246
247#[derive(Debug, Clone, Serialize, Deserialize)]
251pub struct ForecastEps {
252 pub items: Vec<ForecastEpsItem>,
254}
255
256#[derive(Debug, Clone, Serialize, Deserialize)]
258pub struct ForecastEpsItem {
259 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
261 pub forecast_eps_median: Option<Decimal>,
262 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
264 pub forecast_eps_mean: Option<Decimal>,
265 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
267 pub forecast_eps_lowest: Option<Decimal>,
268 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
270 pub forecast_eps_highest: Option<Decimal>,
271 pub institution_total: i32,
273 pub institution_up: i32,
275 pub institution_down: i32,
277 #[serde(deserialize_with = "crate::serde_utils::deserialize_timestamp")]
279 pub forecast_start_date: OffsetDateTime,
280 #[serde(deserialize_with = "crate::serde_utils::deserialize_timestamp")]
282 pub forecast_end_date: OffsetDateTime,
283}
284
285#[derive(Debug, Clone, Serialize, Deserialize)]
289pub struct FinancialConsensus {
290 pub list: Vec<ConsensusReport>,
292 pub current_index: i32,
294 pub currency: String,
296 #[serde(default)]
298 pub opt_periods: Vec<String>,
299 pub current_period: String,
301}
302
303#[derive(Debug, Clone, Serialize, Deserialize)]
305pub struct ConsensusReport {
306 pub fiscal_year: i32,
308 pub fiscal_period: String,
310 pub period_text: String,
312 pub details: Vec<ConsensusDetail>,
314}
315
316#[derive(Debug, Clone, Serialize, Deserialize)]
318pub struct ConsensusDetail {
319 pub key: String,
321 pub name: String,
323 pub description: String,
325 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
327 pub actual: Option<Decimal>,
328 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
330 pub estimate: Option<Decimal>,
331 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
333 pub comp_value: Option<Decimal>,
334 pub comp_desc: String,
336 pub comp: String,
338 pub is_released: bool,
340}
341
342#[derive(Debug, Clone, Serialize, Deserialize)]
346pub struct ValuationData {
347 pub metrics: ValuationMetricsData,
349}
350
351#[derive(Debug, Clone, Serialize, Deserialize)]
353pub struct ValuationMetricsData {
354 pub pe: Option<ValuationMetricData>,
356 pub pb: Option<ValuationMetricData>,
358 pub ps: Option<ValuationMetricData>,
360 pub dvd_yld: Option<ValuationMetricData>,
362}
363
364#[derive(Debug, Clone, Serialize, Deserialize)]
366pub struct ValuationMetricData {
367 pub desc: String,
369 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
371 pub high: Option<Decimal>,
372 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
374 pub low: Option<Decimal>,
375 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
377 pub median: Option<Decimal>,
378 pub list: Vec<ValuationPoint>,
380}
381
382#[derive(Debug, Clone, Serialize, Deserialize)]
384pub struct ValuationPoint {
385 #[serde(deserialize_with = "crate::serde_utils::deserialize_timestamp")]
387 pub timestamp: OffsetDateTime,
388 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
390 pub value: Option<Decimal>,
391}
392
393#[derive(Debug, Clone, Serialize, Deserialize)]
397pub struct ValuationHistoryResponse {
398 pub history: ValuationHistoryData,
400}
401
402#[derive(Debug, Clone, Serialize, Deserialize)]
404pub struct ValuationHistoryData {
405 pub metrics: ValuationHistoryMetrics,
407}
408
409#[derive(Debug, Clone, Serialize, Deserialize)]
411pub struct ValuationHistoryMetrics {
412 pub pe: Option<ValuationHistoryMetric>,
414 pub pb: Option<ValuationHistoryMetric>,
416 pub ps: Option<ValuationHistoryMetric>,
418}
419
420#[derive(Debug, Clone, Serialize, Deserialize)]
422pub struct ValuationHistoryMetric {
423 pub desc: String,
425 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
427 pub high: Option<Decimal>,
428 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
430 pub low: Option<Decimal>,
431 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
433 pub median: Option<Decimal>,
434 pub list: Vec<ValuationPoint>,
436}
437
438#[derive(Debug, Clone, Serialize, Deserialize)]
442pub struct IndustryValuationList {
443 pub list: Vec<IndustryValuationItem>,
445}
446
447#[derive(Debug, Clone, Serialize, Deserialize)]
449pub struct IndustryValuationItem {
450 #[serde(
452 rename = "counter_id",
453 deserialize_with = "deserialize_counter_id_as_symbol"
454 )]
455 pub symbol: String,
456 pub name: String,
458 pub currency: String,
460 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
462 pub assets: Option<Decimal>,
463 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
465 pub bps: Option<Decimal>,
466 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
468 pub eps: Option<Decimal>,
469 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
471 pub dps: Option<Decimal>,
472 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
474 pub div_yld: Option<Decimal>,
475 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
477 pub div_payout_ratio: Option<Decimal>,
478 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
480 pub five_y_avg_dps: Option<Decimal>,
481 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
483 pub pe: Option<Decimal>,
484 pub history: Vec<IndustryValuationHistory>,
486}
487
488#[derive(Debug, Clone, Serialize, Deserialize)]
490pub struct IndustryValuationHistory {
491 pub date: String,
493 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
495 pub pe: Option<Decimal>,
496 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
498 pub pb: Option<Decimal>,
499 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
501 pub ps: Option<Decimal>,
502}
503
504#[derive(Debug, Clone, Serialize, Deserialize)]
508pub struct IndustryValuationDist {
509 pub pe: Option<ValuationDist>,
511 pub pb: Option<ValuationDist>,
513 pub ps: Option<ValuationDist>,
515}
516
517#[derive(Debug, Clone, Serialize, Deserialize)]
519pub struct ValuationDist {
520 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
522 pub low: Option<Decimal>,
523 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
525 pub high: Option<Decimal>,
526 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
528 pub median: Option<Decimal>,
529 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
531 pub value: Option<Decimal>,
532 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
534 pub ranking: Option<Decimal>,
535 pub rank_index: String,
537 pub rank_total: String,
539}
540
541#[derive(Debug, Clone, Serialize, Deserialize)]
545pub struct CompanyOverview {
546 pub name: String,
548 pub company_name: String,
550 pub founded: String,
552 pub listing_date: String,
554 pub market: String,
556 pub region: String,
558 pub address: String,
560 pub office_address: String,
562 pub website: String,
564 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
566 pub issue_price: Option<Decimal>,
567 pub shares_offered: String,
569 pub chairman: String,
571 pub secretary: String,
573 pub audit_inst: String,
575 pub category: String,
577 pub year_end: String,
579 pub employees: String,
581 #[serde(rename = "Phone")]
583 pub phone: String,
584 pub fax: String,
586 pub email: String,
588 pub legal_repr: String,
590 pub manager: String,
592 pub bus_license: String,
594 pub accounting_firm: String,
596 pub securities_rep: String,
598 pub legal_counsel: String,
600 pub zip_code: String,
602 pub ticker: String,
604 pub icon: String,
606 pub profile: String,
608 #[serde(default)]
610 pub ads_ratio: String,
611 pub sector: i32,
613}
614
615#[derive(Debug, Clone, Serialize, Deserialize)]
619pub struct ExecutiveList {
620 pub professional_list: Vec<ExecutiveGroup>,
622}
623
624#[derive(Debug, Clone, Serialize, Deserialize)]
626pub struct ExecutiveGroup {
627 #[serde(
629 rename = "counter_id",
630 deserialize_with = "deserialize_counter_id_as_symbol"
631 )]
632 pub symbol: String,
633 pub forward_url: String,
635 pub total: i32,
637 pub professionals: Vec<Professional>,
639}
640
641#[derive(Debug, Clone, Serialize, Deserialize)]
643pub struct Professional {
644 pub id: String,
646 pub name: String,
648 pub name_zhcn: String,
650 pub name_en: String,
652 pub title: String,
654 pub biography: String,
656 pub photo: String,
658 pub wiki_url: String,
660}
661
662#[derive(Debug, Clone, Serialize, Deserialize)]
666pub struct ShareholderList {
667 pub shareholder_list: Vec<Shareholder>,
669 #[serde(default)]
671 pub forward_url: String,
672 pub total: i32,
674}
675
676#[derive(Debug, Clone, Serialize, Deserialize)]
678pub struct Shareholder {
679 pub shareholder_id: String,
681 pub shareholder_name: String,
683 pub institution_type: String,
685 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
687 pub percent_of_shares: Option<Decimal>,
688 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
690 pub shares_changed: Option<Decimal>,
691 pub report_date: String,
693 #[serde(default)]
695 pub stocks: Vec<ShareholderStock>,
696}
697
698#[derive(Debug, Clone, Serialize, Deserialize)]
700pub struct ShareholderStock {
701 #[serde(
703 rename = "counter_id",
704 deserialize_with = "deserialize_counter_id_as_symbol"
705 )]
706 pub symbol: String,
707 pub code: String,
709 pub market: String,
711 pub chg: String,
713}
714
715#[derive(Debug, Clone, Serialize, Deserialize)]
719pub struct FundHolders {
720 pub lists: Vec<FundHolder>,
722}
723
724#[derive(Debug, Clone, Serialize, Deserialize)]
726pub struct FundHolder {
727 pub code: String,
729 #[serde(
731 rename = "counter_id",
732 deserialize_with = "deserialize_counter_id_as_symbol"
733 )]
734 pub symbol: String,
735 pub currency: String,
737 pub name: String,
739 #[serde(with = "crate::serde_utils::decimal_empty_is_0")]
741 pub position_ratio: Decimal,
742 pub report_date: String,
744}
745
746#[derive(Debug, Clone, Serialize, Deserialize)]
750pub struct CorpActions {
751 pub items: Vec<CorpActionItem>,
753}
754
755#[derive(Debug, Clone, Serialize, Deserialize)]
757pub struct CorpActionItem {
758 pub id: String,
760 pub date: String,
762 pub date_str: String,
764 pub date_type: String,
766 pub date_zone: String,
768 pub act_type: String,
770 pub act_desc: String,
772 pub action: String,
774 pub recent: bool,
776 pub is_delay: bool,
778 pub delay_content: String,
780 pub live: Option<CorpActionLive>,
782 pub security: Option<serde_json::Value>,
784}
785
786#[derive(Debug, Clone, Serialize, Deserialize)]
788pub struct CorpActionLive {
789 pub id: String,
791 pub status: serde_json::Value, pub started_at: String,
795 pub name: String,
797 pub icon: String,
799}
800
801#[derive(Debug, Clone, Serialize, Deserialize)]
805pub struct InvestRelations {
806 #[serde(default)]
808 pub forward_url: String,
809 pub invest_securities: Vec<InvestSecurity>,
811}
812
813#[derive(Debug, Clone, Serialize, Deserialize)]
815pub struct InvestSecurity {
816 pub company_id: String,
818 pub company_name: String,
820 pub company_name_en: String,
822 pub company_name_zhcn: String,
824 #[serde(
826 rename = "counter_id",
827 deserialize_with = "deserialize_counter_id_as_symbol"
828 )]
829 pub symbol: String,
830 pub currency: String,
832 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
834 pub percent_of_shares: Option<Decimal>,
835 pub shares_rank: String,
837 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
839 pub shares_value: Option<Decimal>,
840}
841
842#[derive(Debug, Clone, Serialize, Deserialize)]
846pub struct OperatingList {
847 pub list: Vec<OperatingItem>,
849}
850
851#[derive(Debug, Clone, Serialize, Deserialize)]
853pub struct OperatingItem {
854 pub id: String,
856 pub report: String,
858 pub title: String,
860 pub txt: String,
862 pub latest: bool,
864 #[serde(default)]
866 pub keywords: Vec<serde_json::Value>,
867 #[serde(default)]
869 pub web_url: String,
870 pub financial: OperatingFinancial,
872}
873
874#[derive(Debug, Clone, Serialize, Deserialize)]
876pub struct OperatingFinancial {
877 pub code: String,
879 #[serde(
881 rename = "counter_id",
882 deserialize_with = "deserialize_counter_id_as_symbol"
883 )]
884 pub symbol: String,
885 pub currency: String,
887 pub name: String,
889 pub region: String,
891 pub report: String,
893 pub report_txt: String,
895 pub indicators: Vec<OperatingIndicator>,
897}
898
899#[derive(Debug, Clone, Serialize, Deserialize)]
901pub struct OperatingIndicator {
902 pub field_name: String,
904 pub indicator_name: String,
906 pub indicator_value: String,
908 #[serde(default, with = "crate::serde_utils::decimal_opt_str_is_none")]
910 pub yoy: Option<Decimal>,
911}
912
913#[derive(Debug, Clone, Serialize, Deserialize)]
917pub struct BuybackData {
918 #[serde(default)]
920 pub recent_buybacks: Option<RecentBuybacks>,
921 #[serde(default)]
923 pub buyback_history: Vec<BuybackHistoryItem>,
924 #[serde(default)]
926 pub buyback_ratios: Vec<BuybackRatios>,
927}
928
929#[derive(Debug, Clone, Serialize, Deserialize)]
931pub struct RecentBuybacks {
932 pub currency: String,
934 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
936 pub net_buyback_ttm: Option<Decimal>,
937 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
939 pub net_buyback_yield_ttm: Option<Decimal>,
940}
941
942#[derive(Debug, Clone, Serialize, Deserialize)]
944pub struct BuybackHistoryItem {
945 pub fiscal_year: String,
947 pub fiscal_year_range: String,
949 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
951 pub net_buyback: Option<Decimal>,
952 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
954 pub net_buyback_yield: Option<Decimal>,
955 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
957 pub net_buyback_growth_rate: Option<Decimal>,
958 pub currency: String,
960}
961
962#[derive(Debug, Clone, Serialize, Deserialize)]
964pub struct BuybackRatios {
965 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
967 pub net_buyback_payout_ratio: Option<Decimal>,
968 #[serde(with = "crate::serde_utils::decimal_opt_str_is_none")]
970 pub net_buyback_to_cashflow_ratio: Option<Decimal>,
971}
972
973#[derive(Debug, Clone, Serialize, Deserialize)]
977pub struct StockRatings {
978 #[serde(default)]
980 pub style_txt_name: String,
981 #[serde(default)]
983 pub scale_txt_name: String,
984 #[serde(default)]
986 pub report_period_txt: String,
987 #[serde(default)]
989 pub multi_score: serde_json::Value,
990 #[serde(default)]
992 pub multi_letter: String,
993 #[serde(default)]
995 pub multi_score_change: i32,
996 #[serde(default)]
998 pub industry_name: String,
999 #[serde(default)]
1001 pub industry_rank: serde_json::Value,
1002 #[serde(default)]
1004 pub industry_total: serde_json::Value,
1005 #[serde(default)]
1007 pub industry_mean_score: serde_json::Value,
1008 #[serde(default)]
1010 pub industry_median_score: serde_json::Value,
1011 #[serde(default)]
1013 pub ratings: Vec<RatingCategory>,
1014}
1015
1016#[derive(Debug, Clone, Serialize, Deserialize)]
1018pub struct RatingCategory {
1019 #[serde(rename = "type")]
1021 pub kind: i32,
1022 #[serde(default)]
1024 pub sub_indicators: Vec<RatingSubIndicatorGroup>,
1025}
1026
1027#[derive(Debug, Clone, Serialize, Deserialize)]
1029pub struct RatingSubIndicatorGroup {
1030 pub indicator: RatingIndicator,
1032 #[serde(default)]
1034 pub sub_indicators: Vec<RatingLeafIndicator>,
1035}
1036
1037#[derive(Debug, Clone, Serialize, Deserialize)]
1039pub struct RatingIndicator {
1040 pub name: String,
1042 #[serde(default)]
1044 pub score: serde_json::Value,
1045 #[serde(default)]
1047 pub letter: String,
1048}
1049
1050#[derive(Debug, Clone, Serialize, Deserialize)]
1052pub struct RatingLeafIndicator {
1053 pub name: String,
1055 #[serde(default)]
1057 pub value: String,
1058 #[serde(default)]
1060 pub value_type: String,
1061 #[serde(default)]
1063 pub score: serde_json::Value,
1064 #[serde(default)]
1066 pub letter: String,
1067}
1068
1069#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, EnumString, Display)]
1073pub enum InstitutionRecommend {
1074 Unknown,
1076 #[strum(serialize = "strong_buy")]
1078 StrongBuy,
1079 #[strum(serialize = "buy")]
1081 Buy,
1082 #[strum(serialize = "hold")]
1084 Hold,
1085 #[strum(serialize = "sell")]
1087 Sell,
1088 #[strum(serialize = "strong_sell")]
1090 StrongSell,
1091 #[strum(serialize = "underperform")]
1093 Underperform,
1094 #[strum(serialize = "no_opinion")]
1096 NoOpinion,
1097}
1098
1099impl_default_for_enum_string!(InstitutionRecommend);
1100impl_serde_for_enum_string!(InstitutionRecommend);
1101
1102#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Default)]
1104pub enum FinancialReportKind {
1105 #[serde(rename = "IS")]
1107 IncomeStatement,
1108 #[serde(rename = "BS")]
1110 BalanceSheet,
1111 #[serde(rename = "CF")]
1113 CashFlow,
1114 #[default]
1116 #[serde(rename = "ALL")]
1117 All,
1118}
1119
1120#[derive(Debug, Clone, Serialize, Deserialize)]
1124pub struct BusinessSegments {
1125 pub date: String,
1127 pub total: String,
1129 pub currency: String,
1131 #[serde(default)]
1133 pub business: Vec<BusinessSegmentItem>,
1134}
1135
1136#[derive(Debug, Clone, Serialize, Deserialize)]
1138pub struct BusinessSegmentItem {
1139 pub name: String,
1141 pub percent: String,
1143}
1144
1145#[derive(Debug, Clone, Serialize, Deserialize)]
1147pub struct BusinessSegmentsHistory {
1148 #[serde(default)]
1150 pub historical: Vec<BusinessSegmentsHistoricalItem>,
1151}
1152
1153#[derive(Debug, Clone, Serialize, Deserialize)]
1155pub struct BusinessSegmentsHistoricalItem {
1156 pub date: String,
1158 pub total: String,
1160 pub currency: String,
1162 #[serde(default)]
1164 pub business: Vec<BusinessSegmentHistoryItem>,
1165 #[serde(default)]
1167 pub regionals: Vec<BusinessSegmentHistoryItem>,
1168}
1169
1170#[derive(Debug, Clone, Serialize, Deserialize)]
1172pub struct BusinessSegmentHistoryItem {
1173 pub name: String,
1175 pub percent: String,
1177 pub value: String,
1179}
1180
1181#[derive(Debug, Clone, Serialize, Deserialize)]
1185pub struct InstitutionRatingViews {
1186 #[serde(default)]
1188 pub elist: Vec<InstitutionRatingViewItem>,
1189}
1190
1191#[derive(Debug, Clone, Serialize, Deserialize)]
1193pub struct InstitutionRatingViewItem {
1194 pub date: String,
1196 pub buy: String,
1198 pub over: String,
1200 pub hold: String,
1202 pub under: String,
1204 pub sell: String,
1206 pub total: String,
1208}
1209
1210#[derive(Debug, Clone, Serialize, Deserialize)]
1214pub struct IndustryRankResponse {
1215 #[serde(default)]
1217 pub items: Vec<IndustryRankGroup>,
1218}
1219
1220#[derive(Debug, Clone, Serialize, Deserialize)]
1222pub struct IndustryRankGroup {
1223 #[serde(default)]
1225 pub lists: Vec<IndustryRankItem>,
1226}
1227
1228#[derive(Debug, Clone, Serialize, Deserialize)]
1230pub struct IndustryRankItem {
1231 pub name: String,
1233 pub counter_id: String,
1235 pub chg: String,
1237 pub leading_name: String,
1239 pub leading_ticker: String,
1241 pub leading_chg: String,
1243 pub value_name: String,
1245 pub value_data: String,
1247}
1248
1249#[derive(Debug, Clone, Serialize, Deserialize)]
1253pub struct IndustryPeersResponse {
1254 pub top: IndustryPeersTop,
1256 pub chain: Option<IndustryPeerNode>,
1258}
1259
1260#[derive(Debug, Clone, Serialize, Deserialize)]
1262pub struct IndustryPeersTop {
1263 pub name: String,
1265 pub market: String,
1267}
1268
1269#[derive(Debug, Clone, Serialize, Deserialize)]
1271pub struct IndustryPeerNode {
1272 pub name: String,
1274 pub counter_id: String,
1276 pub stock_num: i32,
1278 pub chg: String,
1280 pub ytd_chg: String,
1282 #[serde(default)]
1284 pub next: Vec<IndustryPeerNode>,
1285}
1286
1287#[derive(Debug, Clone, Serialize, Deserialize)]
1291pub struct FinancialReportSnapshot {
1292 pub name: String,
1294 pub ticker: String,
1296 pub fp_start: String,
1298 pub fp_end: String,
1300 pub currency: String,
1302 pub report_desc: String,
1304 pub fo_revenue: Option<SnapshotForecastMetric>,
1306 pub fo_ebit: Option<SnapshotForecastMetric>,
1308 pub fo_eps: Option<SnapshotForecastMetric>,
1310 pub fr_revenue: Option<SnapshotReportedMetric>,
1312 pub fr_profit: Option<SnapshotReportedMetric>,
1314 pub fr_operate_cash: Option<SnapshotReportedMetric>,
1316 pub fr_invest_cash: Option<SnapshotReportedMetric>,
1318 pub fr_finance_cash: Option<SnapshotReportedMetric>,
1320 pub fr_total_assets: Option<SnapshotReportedMetric>,
1322 pub fr_total_liability: Option<SnapshotReportedMetric>,
1324 pub fr_roe_ttm: String,
1326 pub fr_profit_margin: String,
1328 pub fr_profit_margin_ttm: String,
1330 pub fr_asset_turn_ttm: String,
1332 pub fr_leverage_ttm: String,
1334 pub fr_debt_assets_ratio: String,
1336}
1337
1338#[derive(Debug, Clone, Serialize, Deserialize)]
1340pub struct SnapshotForecastMetric {
1341 pub value: String,
1343 pub yoy: String,
1345 pub cmp_desc: String,
1347 pub est_value: String,
1349}
1350
1351#[derive(Debug, Clone, Serialize, Deserialize)]
1353pub struct SnapshotReportedMetric {
1354 pub value: String,
1356 pub yoy: String,
1358}
1359
1360#[derive(Debug, Clone, Serialize, Deserialize)]
1364pub struct ShareholderTopResponse {
1365 pub data: serde_json::Value,
1367}
1368
1369#[derive(Debug, Clone, Serialize, Deserialize)]
1373pub struct ShareholderDetailResponse {
1374 pub data: serde_json::Value,
1376}
1377
1378#[derive(Debug, Clone, Serialize, Deserialize)]
1382pub struct ValuationHistoryPoint {
1383 pub date: String,
1385 pub pe: String,
1387 pub pb: String,
1389 pub ps: String,
1391}
1392
1393#[derive(Debug, Clone, Serialize, Deserialize)]
1395pub struct ValuationComparisonItem {
1396 pub symbol: String,
1398 pub name: String,
1400 pub currency: String,
1402 pub market_value: String,
1404 pub price_close: String,
1406 pub pe: String,
1408 pub pb: String,
1410 pub ps: String,
1412 pub roe: String,
1414 pub eps: String,
1416 pub bps: String,
1418 pub dps: String,
1420 pub div_yld: String,
1422 pub assets: String,
1424 pub history: Vec<ValuationHistoryPoint>,
1426}
1427
1428#[derive(Debug, Clone, Serialize, Deserialize)]
1430pub struct ValuationComparisonResponse {
1431 pub list: Vec<ValuationComparisonItem>,
1433}
1434
1435#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
1437pub enum FinancialReportPeriod {
1438 #[serde(rename = "af")]
1440 Annual,
1441 #[serde(rename = "saf")]
1443 SemiAnnual,
1444 #[serde(rename = "q1")]
1446 Q1,
1447 #[serde(rename = "q2")]
1449 Q2,
1450 #[serde(rename = "q3")]
1452 Q3,
1453 #[serde(rename = "qf")]
1455 QuarterlyFull,
1456 #[serde(rename = "3q")]
1458 ThreeQ,
1459}
1460
1461#[derive(Debug, FromPrimitive, IntoPrimitive, Copy, Clone, Hash, Eq, PartialEq)]
1465#[repr(i32)]
1466pub enum ElementType {
1467 #[num_enum(default)]
1469 Unknown = 0,
1470 Holdings = 1,
1472 Regional = 2,
1474 AssetClass = 3,
1476 Industry = 4,
1478}
1479
1480impl Serialize for ElementType {
1481 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1482 where
1483 S: serde::Serializer,
1484 {
1485 serializer.serialize_i32((*self).into())
1486 }
1487}
1488
1489impl<'de> Deserialize<'de> for ElementType {
1490 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1491 where
1492 D: serde::Deserializer<'de>,
1493 {
1494 Ok(ElementType::from(i32::deserialize(deserializer)?))
1495 }
1496}
1497
1498#[derive(Debug, Clone, Serialize, Deserialize)]
1500pub struct HoldingDetail {
1501 #[serde(default)]
1503 pub industry_id: String,
1504 #[serde(default)]
1506 pub industry_name: String,
1507 #[serde(default)]
1509 pub index: String,
1510 #[serde(default)]
1512 pub index_name: String,
1513 #[serde(default)]
1515 pub holding_type: String,
1516 #[serde(default)]
1518 pub holding_type_name: String,
1519}
1520
1521#[derive(Debug, Clone, Serialize, Deserialize)]
1523pub struct AssetAllocationItem {
1524 pub name: String,
1526 #[serde(default)]
1528 pub code: String,
1529 pub position_ratio: String,
1531 #[serde(
1533 rename = "counter_id",
1534 deserialize_with = "deserialize_counter_id_as_symbol",
1535 default
1536 )]
1537 pub symbol: String,
1538 #[serde(rename = "name_locales_map", default)]
1540 pub name_locales: HashMap<String, String>,
1541 #[serde(default)]
1543 pub holding_detail: Option<HoldingDetail>,
1544}
1545
1546#[derive(Debug, Clone, Serialize, Deserialize)]
1548pub struct AssetAllocationGroup {
1549 pub report_date: String,
1551 pub asset_type: ElementType,
1553 #[serde(default)]
1555 pub lists: Vec<AssetAllocationItem>,
1556}
1557
1558#[derive(Debug, Clone, Serialize, Deserialize)]
1560pub struct AssetAllocationResponse {
1561 #[serde(default)]
1563 pub info: Vec<AssetAllocationGroup>,
1564}
1565
1566#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
1570pub enum MacroeconomicCountry {
1571 #[serde(rename = "Hong Kong SAR China")]
1573 HongKong,
1574 #[serde(rename = "China (Mainland)")]
1576 China,
1577 #[serde(rename = "United States")]
1579 UnitedStates,
1580 #[serde(rename = "Euro Zone")]
1582 EuroZone,
1583 #[serde(rename = "Japan")]
1585 Japan,
1586 #[serde(rename = "Singapore")]
1588 Singapore,
1589}
1590
1591#[derive(Debug, Copy, Clone, Eq, PartialEq)]
1593pub enum MacroeconomicImportance {
1594 Low = 1,
1596 Medium = 2,
1598 High = 3,
1600}
1601
1602impl MacroeconomicImportance {
1603 pub fn from_i32(v: i32) -> Option<Self> {
1605 match v {
1606 1 => Some(Self::Low),
1607 2 => Some(Self::Medium),
1608 3 => Some(Self::High),
1609 _ => None,
1610 }
1611 }
1612}
1613
1614#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1616pub struct MultiLanguageText {
1617 #[serde(default)]
1619 pub english: String,
1620 #[serde(default)]
1622 pub simplified_chinese: String,
1623 #[serde(default)]
1625 pub traditional_chinese: String,
1626}
1627
1628#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1630pub struct MacroeconomicIndicator {
1631 pub indicator_code: String,
1633 #[serde(default)]
1635 pub source_org: String,
1636 #[serde(default)]
1638 pub country: String,
1639 #[serde(default)]
1641 pub name: String,
1642 #[serde(default)]
1644 pub adjustment_factor: String,
1645 #[serde(default)]
1647 pub periodicity: String,
1648 #[serde(default)]
1650 pub category: String,
1651 #[serde(default)]
1653 pub describe: String,
1654 #[serde(default)]
1656 pub importance: i32,
1657 #[serde(
1659 default,
1660 with = "crate::serde_utils::rfc3339_opt",
1661 rename = "start_date"
1662 )]
1663 pub start_date: Option<OffsetDateTime>,
1664}
1665
1666#[derive(Debug, Clone, Serialize, Deserialize)]
1668pub struct MacroeconomicIndicatorListResponse {
1669 #[serde(default, rename = "list")]
1671 pub data: Vec<MacroeconomicIndicator>,
1672 #[serde(default)]
1674 pub count: i32,
1675}
1676
1677#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1679pub struct Macroeconomic {
1680 #[serde(default)]
1682 pub period: String,
1683 #[serde(default, with = "crate::serde_utils::rfc3339_opt")]
1685 pub release_at: Option<OffsetDateTime>,
1686 #[serde(default)]
1688 pub actual_value: String,
1689 #[serde(default)]
1691 pub previous_value: String,
1692 #[serde(default)]
1694 pub forecast_value: String,
1695 #[serde(default)]
1697 pub revised_value: String,
1698 #[serde(default, with = "crate::serde_utils::rfc3339_opt")]
1700 pub next_release_at: Option<OffsetDateTime>,
1701 #[serde(default)]
1703 pub unit: String,
1704 #[serde(default)]
1706 pub unit_prefix: String,
1707}
1708
1709#[derive(Debug, Clone, Serialize, Deserialize)]
1711pub struct MacroeconomicResponse {
1712 #[serde(default, deserialize_with = "crate::serde_utils::null_as_default")]
1714 pub info: MacroeconomicIndicator,
1715 #[serde(default)]
1717 pub data: Vec<Macroeconomic>,
1718 #[serde(default)]
1720 pub count: i32,
1721}
1722
1723#[derive(Debug, Clone, Serialize, Deserialize)]
1727pub(crate) struct V2MacroIndicator {
1728 #[serde(default)]
1729 pub indicator_id: i32,
1730 #[serde(default)]
1731 pub indicator_name: String,
1732 #[serde(default)]
1733 pub market: String,
1734 #[serde(default)]
1735 pub importance: i32,
1736 #[serde(default)]
1737 pub description: String,
1738 #[serde(default)]
1740 pub frequence: String,
1741}
1742
1743#[derive(Debug, Clone, Serialize, Deserialize)]
1745pub(crate) struct V2MacroIndicatorListResponse {
1746 #[serde(default)]
1747 pub indicator_list: Vec<V2MacroIndicator>,
1748 #[serde(default)]
1750 pub total: i32,
1751}
1752
1753#[derive(Debug, Clone, Serialize, Deserialize)]
1755pub(crate) struct V2IndicatorDataDetail {
1756 #[serde(default)]
1757 pub actual_data: String,
1758 #[serde(default)]
1759 pub previous_data: String,
1760 #[serde(default)]
1761 pub estimated_data: String,
1762 #[serde(default)]
1763 pub published_time: String,
1764 #[serde(default)]
1765 pub observation_date: String,
1766}
1767
1768#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1770pub(crate) struct V2MacroIndicatorDetail {
1771 #[serde(default)]
1772 pub indicator_id: i32,
1773 #[serde(default)]
1774 pub indicator_name: String,
1775 #[serde(default)]
1776 pub unit: String,
1777 #[serde(default)]
1778 pub description: String,
1779 #[serde(default)]
1780 pub market: String,
1781 #[serde(default)]
1782 pub frequence: String,
1783 #[serde(default)]
1784 pub importance: i32,
1785 #[serde(default)]
1786 pub indicator_data: Vec<V2IndicatorDataDetail>,
1787}
1788
1789#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1792pub(crate) struct V2MacroIndicatorDataResponse {
1793 #[serde(default)]
1795 pub indicator: V2MacroIndicatorDetail,
1796 #[serde(default)]
1798 pub total: i32,
1799}