Retrieves all three main financial statements (income statement, balance sheet, and cash flow statement) from Yahoo Finance for a specified ticker symbol in a single call. This is a convenience function that calls the individual statement functions and returns the results as a list.
Usage
get_financials(
ticker,
freq = "annual",
start = NULL,
end = NULL,
cashflow_keys = NULL,
balance_keys = NULL,
income_keys = NULL,
pretty = TRUE,
wide = TRUE,
proxy = NULL,
output = c("tibble", "response", "request")
)Arguments
- ticker
A ticker object created with
get_tickers()or a ticker symbol string- freq
Frequency of data: "annual" or "quarterly" (default "annual")
- start
Start timestamp as date, datetime, or string (default EOY 2016)
- end
End timestamp as date, datetime, or string (default current timestamp)
- cashflow_keys
Vector of specific cash flow statement keys to include (default all) See
valid_cashflow_keysfor available options.- balance_keys
Vector of specific balance sheet keys to include (default all) See
valid_balance_keysfor available options.- income_keys
Vector of specific income statement keys to include (default all) See
valid_income_keysfor available options.- pretty
Format column names to be more readable (default TRUE)
- wide
Return data in wide format with dates as columns (default TRUE). If FALSE, returns data in long format with a date column.
- proxy
Optional proxy settings for the request
- output
Object to return. Can be "tibble", "response", or "request" (default "tibble")
Value
A list containing three elements:
income_statement: Income statement databalance_sheet: Balance sheet datacashflow: Cash flow statement data
If output is "request" or "response", returns a list of httr2 request or response objects instead.
Details
Note that this function makes multiple API calls to Yahoo Finance. Be aware of potential rate limiting issues when making frequent requests. If you encounter HTTP 429 (Too Many Requests) errors, consider implementing a delay between requests or using a proxy.
Examples
if (FALSE) { # \dontrun{
apple <- get_tickers("AAPL")
# Get all annual financial statements
financials <- get_financials(apple)
# Access individual statements from the results
income <- financials$income_statement
balance <- financials$balance_sheet
cashflow <- financials$cashflow
# Get all quarterly financial statements
quarterly_financials <- get_financials(apple, freq = "quarterly")
# Get financial statements for a specific time period
financials_2020_2022 <- get_financials(apple,
start = "2020-01-01",
end = "2022-12-31"
)
} # }
