fmp_rs/models/
financials.rs

1//! Financial statement models.
2
3use serde::{Deserialize, Serialize};
4
5/// Income statement
6#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
7#[serde(rename_all = "camelCase")]
8pub struct IncomeStatement {
9    pub date: String,
10    pub symbol: String,
11    pub reported_currency: String,
12    pub cik: String,
13    pub filling_date: String,
14    pub accepted_date: String,
15    pub calendar_year: String,
16    pub period: String,
17    pub revenue: i64,
18    pub cost_of_revenue: i64,
19    pub gross_profit: i64,
20    pub gross_profit_ratio: f64,
21    pub research_and_development_expenses: i64,
22    pub general_and_administrative_expenses: i64,
23    pub selling_and_marketing_expenses: i64,
24    pub selling_general_and_administrative_expenses: i64,
25    pub other_expenses: i64,
26    pub operating_expenses: i64,
27    pub cost_and_expenses: i64,
28    pub interest_income: i64,
29    pub interest_expense: i64,
30    pub depreciation_and_amortization: i64,
31    pub ebitda: i64,
32    pub ebitda_ratio: f64,
33    pub operating_income: i64,
34    pub operating_income_ratio: f64,
35    pub total_other_income_expenses_net: i64,
36    pub income_before_tax: i64,
37    pub income_before_tax_ratio: f64,
38    pub income_tax_expense: i64,
39    pub net_income: i64,
40    pub net_income_ratio: f64,
41    pub eps: f64,
42    pub eps_diluted: f64,
43    pub weighted_average_shs_out: i64,
44    pub weighted_average_shs_out_dil: i64,
45    pub link: String,
46    pub final_link: String,
47}
48
49/// Balance sheet statement
50#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
51#[serde(rename_all = "camelCase")]
52pub struct BalanceSheet {
53    pub date: String,
54    pub symbol: String,
55    pub reported_currency: String,
56    pub cik: String,
57    pub filling_date: String,
58    pub accepted_date: String,
59    pub calendar_year: String,
60    pub period: String,
61    pub cash_and_cash_equivalents: i64,
62    pub short_term_investments: i64,
63    pub cash_and_short_term_investments: i64,
64    pub net_receivables: i64,
65    pub inventory: i64,
66    pub other_current_assets: i64,
67    pub total_current_assets: i64,
68    pub property_plant_equipment_net: i64,
69    pub goodwill: i64,
70    pub intangible_assets: i64,
71    pub goodwill_and_intangible_assets: i64,
72    pub long_term_investments: i64,
73    pub tax_assets: i64,
74    pub other_non_current_assets: i64,
75    pub total_non_current_assets: i64,
76    pub other_assets: i64,
77    pub total_assets: i64,
78    pub account_payables: i64,
79    pub short_term_debt: i64,
80    pub tax_payables: i64,
81    pub deferred_revenue: i64,
82    pub other_current_liabilities: i64,
83    pub total_current_liabilities: i64,
84    pub long_term_debt: i64,
85    pub deferred_revenue_non_current: i64,
86    pub deferred_tax_liabilities_non_current: i64,
87    pub other_non_current_liabilities: i64,
88    pub total_non_current_liabilities: i64,
89    pub other_liabilities: i64,
90    pub capital_lease_obligations: i64,
91    pub total_liabilities: i64,
92    pub preferred_stock: i64,
93    pub common_stock: i64,
94    pub retained_earnings: i64,
95    pub accumulated_other_comprehensive_income_loss: i64,
96    pub othertotal_stockholders_equity: i64,
97    pub total_stockholders_equity: i64,
98    pub total_equity: i64,
99    pub total_liabilities_and_stockholders_equity: i64,
100    pub minority_interest: i64,
101    pub total_liabilities_and_total_equity: i64,
102    pub total_investments: i64,
103    pub total_debt: i64,
104    pub net_debt: i64,
105    pub link: String,
106    pub final_link: String,
107}
108
109/// Cash flow statement
110#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
111#[serde(rename_all = "camelCase")]
112pub struct CashFlowStatement {
113    pub date: String,
114    pub symbol: String,
115    pub reported_currency: String,
116    pub cik: String,
117    pub filling_date: String,
118    pub accepted_date: String,
119    pub calendar_year: String,
120    pub period: String,
121    pub net_income: i64,
122    pub depreciation_and_amortization: i64,
123    pub deferred_income_tax: i64,
124    pub stock_based_compensation: i64,
125    pub change_in_working_capital: i64,
126    pub accounts_receivables: i64,
127    pub inventory: i64,
128    pub accounts_payables: i64,
129    pub other_working_capital: i64,
130    pub other_non_cash_items: i64,
131    pub net_cash_provided_by_operating_activities: i64,
132    pub investments_in_property_plant_and_equipment: i64,
133    pub acquisitions_net: i64,
134    pub purchases_of_investments: i64,
135    pub sales_maturities_of_investments: i64,
136    pub other_investing_activites: i64,
137    pub net_cash_used_for_investing_activites: i64,
138    pub debt_repayment: i64,
139    pub common_stock_issued: i64,
140    pub common_stock_repurchased: i64,
141    pub dividends_paid: i64,
142    pub other_financing_activites: i64,
143    pub net_cash_used_provided_by_financing_activities: i64,
144    pub effect_of_forex_changes_on_cash: i64,
145    pub net_change_in_cash: i64,
146    pub cash_at_end_of_period: i64,
147    pub cash_at_beginning_of_period: i64,
148    pub operating_cash_flow: i64,
149    pub capital_expenditure: i64,
150    pub free_cash_flow: i64,
151    pub link: String,
152    pub final_link: String,
153}
154
155/// Financial ratios
156#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
157#[serde(rename_all = "camelCase")]
158pub struct FinancialRatios {
159    pub symbol: String,
160    pub date: String,
161    pub calendar_year: String,
162    pub period: String,
163    pub current_ratio: f64,
164    pub quick_ratio: f64,
165    pub cash_ratio: f64,
166    pub days_of_sales_outstanding: f64,
167    pub days_of_inventory_outstanding: f64,
168    pub operating_cycle: f64,
169    pub days_of_payables_outstanding: f64,
170    pub cash_conversion_cycle: f64,
171    pub gross_profit_margin: f64,
172    pub operating_profit_margin: f64,
173    pub pretax_profit_margin: f64,
174    pub net_profit_margin: f64,
175    pub effective_tax_rate: f64,
176    pub return_on_assets: f64,
177    pub return_on_equity: f64,
178    pub return_on_capital_employed: f64,
179    pub net_income_per_ebt: f64,
180    pub ebt_per_ebit: f64,
181    pub ebit_per_revenue: f64,
182    pub debt_ratio: f64,
183    pub debt_equity_ratio: f64,
184    pub long_term_debt_to_capitalization: f64,
185    pub total_debt_to_capitalization: f64,
186    pub interest_coverage: f64,
187    pub cash_flow_to_debt_ratio: f64,
188    pub company_equity_multiplier: f64,
189    pub receivables_turnover: f64,
190    pub payables_turnover: f64,
191    pub inventory_turnover: f64,
192    pub fixed_asset_turnover: f64,
193    pub asset_turnover: f64,
194    pub operating_cash_flow_per_share: f64,
195    pub free_cash_flow_per_share: f64,
196    pub cash_per_share: f64,
197    pub payout_ratio: f64,
198    pub operating_cash_flow_sales_ratio: f64,
199    pub free_cash_flow_operating_cash_flow_ratio: f64,
200    pub cash_flow_coverage_ratios: f64,
201    pub short_term_coverage_ratios: f64,
202    pub capital_expenditure_coverage_ratio: f64,
203    pub dividend_paid_and_capex_coverage_ratio: f64,
204    pub dividend_payout_ratio: f64,
205    pub price_book_value_ratio: f64,
206    pub price_to_book_ratio: f64,
207    pub price_to_sales_ratio: f64,
208    pub price_earnings_ratio: f64,
209    pub price_to_free_cash_flows_ratio: f64,
210    pub price_to_operating_cash_flows_ratio: f64,
211    pub price_cash_flow_ratio: f64,
212    pub price_earnings_to_growth_ratio: f64,
213    pub price_sales_ratio: f64,
214    pub dividend_yield: f64,
215    pub enterprise_value_multiple: f64,
216    pub price_fair_value: f64,
217}
218
219/// Key metrics
220#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
221#[serde(rename_all = "camelCase")]
222pub struct KeyMetrics {
223    pub symbol: String,
224    pub date: String,
225    pub calendar_year: String,
226    pub period: String,
227    pub revenue_per_share: f64,
228    pub net_income_per_share: f64,
229    pub operating_cash_flow_per_share: f64,
230    pub free_cash_flow_per_share: f64,
231    pub cash_per_share: f64,
232    pub book_value_per_share: f64,
233    pub tangible_book_value_per_share: f64,
234    pub shareholders_equity_per_share: f64,
235    pub interest_debt_per_share: f64,
236    pub market_cap: i64,
237    pub enterprise_value: i64,
238    pub pe_ratio: f64,
239    pub price_to_sales_ratio: f64,
240    pub pocf_ratio: f64,
241    pub pfcf_ratio: f64,
242    pub pb_ratio: f64,
243    pub ptb_ratio: f64,
244    pub ev_to_sales: f64,
245    pub enterprise_value_over_ebitda: f64,
246    pub ev_to_operating_cash_flow: f64,
247    pub ev_to_free_cash_flow: f64,
248    pub earnings_yield: f64,
249    pub free_cash_flow_yield: f64,
250    pub debt_to_equity: f64,
251    pub debt_to_assets: f64,
252    pub net_debt_to_ebitda: f64,
253    pub current_ratio: f64,
254    pub interest_coverage: f64,
255    pub income_quality: f64,
256    pub dividend_yield: f64,
257    pub payout_ratio: f64,
258    pub sales_general_and_administrative_to_revenue: f64,
259    pub research_and_ddevelopement_to_revenue: f64,
260    pub intangibles_to_total_assets: f64,
261    pub capex_to_operating_cash_flow: f64,
262    pub capex_to_revenue: f64,
263    pub capex_to_depreciation: f64,
264    pub stock_based_compensation_to_revenue: f64,
265    pub graham_number: f64,
266    pub roic: f64,
267    pub return_on_tangible_assets: f64,
268    pub graham_net_net: f64,
269    pub working_capital: i64,
270    pub tangible_asset_value: i64,
271    pub net_current_asset_value: i64,
272    pub invested_capital: i64,
273    pub average_receivables: i64,
274    pub average_payables: i64,
275    pub average_inventory: i64,
276    pub days_sales_outstanding: f64,
277    pub days_payables_outstanding: f64,
278    pub days_of_inventory_on_hand: f64,
279    pub receivables_turnover: f64,
280    pub payables_turnover: f64,
281    pub inventory_turnover: f64,
282    pub roe: f64,
283    pub capex_per_share: f64,
284}
285
286/// Financial growth metrics
287#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
288#[serde(rename_all = "camelCase")]
289pub struct FinancialGrowth {
290    pub date: String,
291    pub symbol: String,
292    pub period: String,
293    pub calendar_year: String,
294    pub revenue_growth: f64,
295    pub gross_profit_growth: f64,
296    pub ebit_growth: f64,
297    pub operating_income_growth: f64,
298    pub net_income_growth: f64,
299    pub eps_growth: f64,
300    pub eps_diluted_growth: f64,
301    pub weighted_average_shares_growth: f64,
302    pub weighted_average_shares_diluted_growth: f64,
303    pub dividends_per_share_growth: f64,
304    pub operating_cash_flow_growth: f64,
305    pub free_cash_flow_growth: f64,
306    pub ten_y_revenue_growth_per_share: f64,
307    pub five_y_revenue_growth_per_share: f64,
308    pub three_y_revenue_growth_per_share: f64,
309    pub ten_y_operating_cf_growth_per_share: f64,
310    pub five_y_operating_cf_growth_per_share: f64,
311    pub three_y_operating_cf_growth_per_share: f64,
312    pub ten_y_net_income_growth_per_share: f64,
313    pub five_y_net_income_growth_per_share: f64,
314    pub three_y_net_income_growth_per_share: f64,
315    pub ten_y_shareholders_equity_growth_per_share: f64,
316    pub five_y_shareholders_equity_growth_per_share: f64,
317    pub three_y_shareholders_equity_growth_per_share: f64,
318    pub ten_y_dividend_per_share_growth_per_share: f64,
319    pub five_y_dividend_per_share_growth_per_share: f64,
320    pub three_y_dividend_per_share_growth_per_share: f64,
321    pub receivables_growth: f64,
322    pub inventory_growth: f64,
323    pub asset_growth: f64,
324    pub book_value_per_share_growth: f64,
325    pub debt_growth: f64,
326    pub rd_expense_growth: f64,
327    pub sg_a_expenses_growth: f64,
328}
329
330/// Financial statement as reported (XBRL data)
331#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
332#[serde(rename_all = "camelCase")]
333pub struct FinancialAsReported {
334    pub date: String,
335    pub symbol: String,
336    pub period: String,
337    pub cik: String,
338    pub filling_date: String,
339    pub accepted_date: String,
340    pub calendar_year: String,
341    // XBRL data is dynamic, so we use a generic value
342    #[serde(flatten)]
343    pub data: serde_json::Map<String, serde_json::Value>,
344}
345
346/// Revenue product segmentation
347#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
348#[serde(rename_all = "camelCase")]
349pub struct RevenueProductSegmentation {
350    pub date: String,
351    pub symbol: String,
352    #[serde(flatten)]
353    pub segments: serde_json::Map<String, serde_json::Value>,
354}
355
356/// Revenue geographic segmentation
357#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
358#[serde(rename_all = "camelCase")]
359pub struct RevenueGeographicSegmentation {
360    pub date: String,
361    pub symbol: String,
362    #[serde(flatten)]
363    pub segments: serde_json::Map<String, serde_json::Value>,
364}