Skip to contents

Base class for getting all data related to ticker from Yahoo Finance API.

Format

An R6 class object

Public fields

symbol

Symbol for which data is retrieved.

Active bindings

asset_profile

Information related to the company's location, operations, and officers.

calendar_events

Earnings and Revenue expectations for upcoming earnings date.

company_officers

Retrieves top executives for given symbol and their total pay package.

earnings_history

Data related to historical earnings (actual vs. estimate)

earnings

Historical earnings data.

earnings_trend

Historical trend data for earnings and revenue estimations

esg_scores

Data related to environmental, social, and governance metrics

financial_data

Financial key performance indicators

fund_bond_holdings

Retrieves aggregated maturity and duration information for a given symbol

fund_bond_ratings

Retrieves aggregated maturity and duration information

fund_equity_holdings

Fund equity holdings

fund_holding_info

Contains information for a funds top holdings, bond ratings, bond holdings, equity holdings, sector weightings, and category breakdown

fund_ownership

Top 10 owners of a given symbol

fund_performance

Historical return data for a given symbol and its specific category

fund_profile

Summary level information for a given symbol

fund_section_weightings

Retrieves aggregated sector weightings for a given symbol

fund_top_holdings

Retrieves Top 10 holdings for a given symbol

fund_holdings

Holding info for the given fund

grading_history

Data related to upgrades / downgrades by companies

index_trend

Trend data related to given symbol's index, specificially PE and PEG ratios

inside_holders

Data related to stock holdings of a given symbol(s) insiders

insider_transactions

Transactions by insiders for a given symbol(s)

institution_ownership

Top 10 owners of a given symbol

key_stats

KPIs for given symbol

major_holders

Data showing breakdown of owners of given symbol(s), insiders, institutions, etc.

page_views

Short, Mid, and Long-term trend data regarding a symbol's page views

price

Detailed pricing data for given symbol, exchange, quote type, currency, market cap, pre / post market data, etc.

quote_type

Stock exchange specific data for given symbol

recommendation_trend

Data related to historical recommendations (buy, hold, sell) for a given symbol

security_filings

Historical SEC filings

share_purchase_activity

High-level buy / sell data

summary_detail

Contains information available via the Summary tab in Yahoo Finance

summary_profile

Return business summary of given symbol

valuation_measures

Retrieves valuation measures for most recent four quarters

option_chain

Option chain data for all expiration dates for a given symbol

option_expiration_dates

Option expiration dates

option_strikes

Option strikes

quote

Get real-time quote information for given symbol

recommendations

Recommended symbols

technical_insights

Technical indicators for given symbol

Methods


Method new()

Create a new Ticker object.

Usage

Ticker$new(symbol = NA)

Arguments

symbol

Symbol.

Returns

A new `Ticker` object

Examples

aapl <- Ticker$new('aapl')


Method set_symbol()

Set a new symbol.

Usage

Ticker$set_symbol(symbol)

Arguments

symbol

New symbol

Examples

aapl <- Ticker$new('aapl')
aapl$set_symbol('msft')


Method get_balance_sheet()

Retrieves balance sheet data for most recent four quarters or most recent four years.

Usage

Ticker$get_balance_sheet(
  frequency = c("annual", "quarter"),
  clean_names = TRUE
)

Arguments

frequency

Annual or quarter.

clean_names

Logical; if TRUE, converts column names to snake case.

Returns

A tibble.

Examples

\donttest{
aapl <- Ticker$new('aapl')
aapl$get_balance_sheet('annual')
aapl$get_balance_sheet('quarter')
}


Method get_cash_flow()

Retrieves cash flow data for most recent four quarters or most recent four years.

Usage

Ticker$get_cash_flow(frequency = c("annual", "quarter"), clean_names = TRUE)

Arguments

frequency

Annual or quarter.

clean_names

Logical; if TRUE, converts column names to snake case.

Returns

A tibble.

Examples

\donttest{
aapl <- Ticker$new('aapl')
aapl$get_cash_flow('annual')
aapl$get_cash_flow('quarter')
}


Method get_income_statement()

Retrieves income statement data for most recent four quarters or most recent four years.

Usage

Ticker$get_income_statement(
  frequency = c("annual", "quarter"),
  clean_names = TRUE
)

Arguments

frequency

Annual or quarter.

clean_names

Logical; if TRUE, converts column names to snake case.

Returns

A tibble.

Examples

\donttest{
aapl <- Ticker$new('aapl')
aapl$get_income_statement('annual')
aapl$get_income_statement('quarter')
}


Method get_history()

Retrieves historical pricing data.

Usage

Ticker$get_history(period = "ytd", interval = "1d", start = NULL, end = NULL)

Arguments

period

Length of time. Defaults to 'ytd'. Valid values are:

  • '1d'

  • '5d'

  • '1mo'

  • '3mo'

  • '6mo'

  • '1y'

  • '2y'

  • '5y'

  • '10y'

  • 'ytd'

  • 'max'

interval

Time between data points. Defaults to '1d'. Valid values are:

  • '1m'

  • '2m'

  • '5m'

  • '15m'

  • '30m'

  • '60m'

  • '90m'

  • '1h'

  • '1d'

  • '5d'

  • '1wk'

  • '1mo'

  • '3mo'

start

Specific starting date. String or date object in yyyy-mm-dd format.

end

Specific ending date. String or date object in yyyy-mm-dd format.

Returns

A data.frame.

Examples

\donttest{
aapl <- Ticker$new('aapl')
aapl$get_history(start = '2022-07-01', interval = '1d')
aapl$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d')
aapl$get_history(period = '1mo', interval = '1d')
}


Method clone()

The objects of this class are cloneable with this method.

Usage

Ticker$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `Ticker$new`
## ------------------------------------------------

aapl <- Ticker$new('aapl')

## ------------------------------------------------
## Method `Ticker$set_symbol`
## ------------------------------------------------

aapl <- Ticker$new('aapl')
aapl$set_symbol('msft')

## ------------------------------------------------
## Method `Ticker$get_balance_sheet`
## ------------------------------------------------

# \donttest{
aapl <- Ticker$new('aapl')
aapl$get_balance_sheet('annual')
#> # A tibble: 4 x 24
#>   end_date          cash short~1 net_r~2 inven~3 other~4 total~5 long_~6 prope~7
#>   <date>           <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1 2021-09-25 34940000000 2.77e10 5.15e10  6.58e9 1.41e10 1.35e11 1.28e11 4.95e10
#> 2 2020-09-26 38016000000 5.29e10 3.74e10  4.06e9 1.13e10 1.44e11 1.01e11 4.53e10
#> 3 2019-09-28 48844000000 5.17e10 4.58e10  4.11e9 1.24e10 1.63e11 1.05e11 3.74e10
#> 4 2018-09-29 25913000000 4.04e10 4.90e10  3.96e9 1.21e10 1.31e11 1.71e11 4.13e10
#> # ... with 15 more variables: other_assets <dbl>, total_assets <dbl>,
#> #   accounts_payable <dbl>, short_long_term_debt <dbl>,
#> #   other_current_liab <dbl>, long_term_debt <dbl>, other_liab <dbl>,
#> #   total_current_liabilities <dbl>, total_liab <dbl>, common_stock <dbl>,
#> #   retained_earnings <dbl>, treasury_stock <dbl>,
#> #   other_stockholder_equity <dbl>, total_stockholder_equity <dbl>,
#> #   net_tangible_assets <dbl>, and abbreviated variable names ...
aapl$get_balance_sheet('quarter')
#> # A tibble: 4 x 24
#>   end_date          cash short~1 net_r~2 inven~3 other~4 total~5 long_~6 prope~7
#>   <date>           <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1 2022-06-25 27502000000 2.07e10 4.22e10  5.43e9 1.64e10 1.12e11 1.31e11 4.03e10
#> 2 2022-03-26 28098000000 2.34e10 4.54e10  5.46e9 1.58e10 1.18e11 1.41e11 3.93e10
#> 3 2021-12-25 37119000000 2.68e10 6.53e10  5.88e9 1.81e10 1.53e11 1.39e11 3.92e10
#> 4 2021-09-25 34940000000 2.77e10 5.15e10  6.58e9 1.41e10 1.35e11 1.28e11 4.95e10
#> # ... with 15 more variables: other_assets <dbl>, total_assets <dbl>,
#> #   accounts_payable <dbl>, short_long_term_debt <dbl>,
#> #   other_current_liab <dbl>, long_term_debt <dbl>, other_liab <dbl>,
#> #   total_current_liabilities <dbl>, total_liab <dbl>, common_stock <dbl>,
#> #   retained_earnings <dbl>, treasury_stock <dbl>,
#> #   other_stockholder_equity <dbl>, total_stockholder_equity <dbl>,
#> #   net_tangible_assets <dbl>, and abbreviated variable names ...
# }

## ------------------------------------------------
## Method `Ticker$get_cash_flow`
## ------------------------------------------------

# \donttest{
aapl <- Ticker$new('aapl')
aapl$get_cash_flow('annual')
#> # A tibble: 4 x 20
#>   end_date   net_i~1 depre~2 change~3 change~4 change~5 chang~6 change~7 total~8
#>   <date>       <dbl>   <dbl>    <dbl>    <dbl>    <dbl>   <dbl>    <dbl>   <dbl>
#> 1 2021-09-25 9.47e10 1.13e10  2.98e 9 -1.01e10  1.40e10 -2.64e9 -6.15e 9 1.04e11
#> 2 2020-09-26 5.74e10 1.11e10  6.52e 9  6.92e 9 -1.98e 9 -1.27e8  8.81e 8 8.07e10
#> 3 2019-09-28 5.53e10 1.25e10  5.08e 9  2.45e 8 -2.55e 9 -2.89e8 -8.96e 8 6.94e10
#> 4 2018-09-29 5.95e10 1.09e10 -2.77e10 -5.32e 9  9.17e 9  8.28e8  3.00e10 7.74e10
#> # ... with 11 more variables: capital_expenditures <dbl>, investments <dbl>,
#> #   other_cashflows_from_investing_activities <int>,
#> #   total_cashflows_from_investing_activities <dbl>, dividends_paid <dbl>,
#> #   net_borrowings <dbl>, other_cashflows_from_financing_activities <int>,
#> #   total_cash_from_financing_activities <dbl>, change_in_cash <dbl>,
#> #   repurchase_of_stock <dbl>, issuance_of_stock <int>, and abbreviated
#> #   variable names 1: net_income, 2: depreciation, 3: change_to_netincome, ...
aapl$get_cash_flow('quarter')
#> # A tibble: 4 x 20
#>   end_date   net_inc~1 depre~2 chang~3 chang~4 change~5 chang~6 change~7 total~8
#>   <date>         <dbl>   <dbl>   <dbl>   <dbl>    <dbl>   <int>    <dbl>   <dbl>
#> 1 2022-06-25   1.94e10  2.80e9  3.87e9 -9.81e8 -4.72e 9 -1.6 e7  2.50e 9 2.29e10
#> 2 2022-03-26   2.50e10  2.74e9  2.47e9  9.48e9 -2.14e10  3.84e8  9.49e 9 2.82e10
#> 3 2021-12-25   3.46e10  2.70e9  3.11e9 -3.93e9  2.03e10  6.81e8 -1.05e10 4.70e10
#> 4 2021-09-25   2.06e10  2.99e9 -1.55e9 -8.81e9  1.40e10 -1.43e9 -5.60e 9 2.02e10
#> # ... with 11 more variables: capital_expenditures <dbl>, investments <dbl>,
#> #   other_cashflows_from_investing_activities <int>,
#> #   total_cashflows_from_investing_activities <dbl>, dividends_paid <dbl>,
#> #   net_borrowings <dbl>, other_cashflows_from_financing_activities <int>,
#> #   total_cash_from_financing_activities <dbl>, change_in_cash <dbl>,
#> #   repurchase_of_stock <dbl>, issuance_of_stock <int>, and abbreviated
#> #   variable names 1: net_income, 2: depreciation, 3: change_to_netincome, ...
# }

## ------------------------------------------------
## Method `Ticker$get_income_statement`
## ------------------------------------------------

# \donttest{
aapl <- Ticker$new('aapl')
aapl$get_income_statement('annual')
#> # A tibble: 4 x 16
#>   end_date   total_rev~1 cost_~2 gross~3 resea~4 selli~5 total~6 opera~7 total~8
#>   <date>           <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <int>
#> 1 2021-09-25     3.66e11 2.13e11 1.53e11 2.19e10 2.20e10 2.57e11 1.09e11  2.58e8
#> 2 2020-09-26     2.75e11 1.70e11 1.05e11 1.88e10 1.99e10 2.08e11 6.63e10  8.03e8
#> 3 2019-09-28     2.60e11 1.62e11 9.84e10 1.62e10 1.82e10 1.96e11 6.39e10  1.81e9
#> 4 2018-09-29     2.66e11 1.64e11 1.02e11 1.42e10 1.67e10 1.95e11 7.09e10  2.00e9
#> # ... with 7 more variables: ebit <dbl>, interest_expense <dbl>,
#> #   income_before_tax <dbl>, income_tax_expense <dbl>,
#> #   net_income_from_continuing_ops <dbl>, net_income <dbl>,
#> #   net_income_applicable_to_common_shares <dbl>, and abbreviated variable
#> #   names 1: total_revenue, 2: cost_of_revenue, 3: gross_profit,
#> #   4: research_development, 5: selling_general_administrative,
#> #   6: total_operating_expenses, 7: operating_income, ...
aapl$get_income_statement('quarter')
#> # A tibble: 4 x 16
#>   end_date   total_rev~1 cost_~2 gross~3 resea~4 selli~5 total~6 opera~7 total~8
#>   <date>           <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <int>
#> 1 2022-06-25     8.30e10 4.71e10 3.59e10  6.80e9  6.01e9 5.99e10 2.31e10 -1   e7
#> 2 2022-03-26     9.73e10 5.47e10 4.26e10  6.39e9  6.19e9 6.73e10 3.00e10  1.6 e8
#> 3 2021-12-25     1.24e11 6.97e10 5.42e10  6.31e9  6.45e9 8.25e10 4.15e10 -2.47e8
#> 4 2021-09-25     8.34e10 4.82e10 3.52e10  5.77e9  5.62e9 5.96e10 2.38e10 -5.38e8
#> # ... with 7 more variables: ebit <dbl>, interest_expense <int>,
#> #   income_before_tax <dbl>, income_tax_expense <dbl>,
#> #   net_income_from_continuing_ops <dbl>, net_income <dbl>,
#> #   net_income_applicable_to_common_shares <dbl>, and abbreviated variable
#> #   names 1: total_revenue, 2: cost_of_revenue, 3: gross_profit,
#> #   4: research_development, 5: selling_general_administrative,
#> #   6: total_operating_expenses, 7: operating_income, ...
# }

## ------------------------------------------------
## Method `Ticker$get_history`
## ------------------------------------------------

# \donttest{
aapl <- Ticker$new('aapl')
aapl$get_history(start = '2022-07-01', interval = '1d')
#>                   date    volume   high    low   open  close adj_close
#> 1  2022-07-01 13:30:00  71051600 139.04 135.66 136.04 138.93  138.7373
#> 2  2022-07-05 13:30:00  73353800 141.61 136.93 137.77 141.56  141.3636
#> 3  2022-07-06 13:30:00  74064300 144.12 141.08 141.35 142.92  142.7218
#> 4  2022-07-07 13:30:00  66253700 146.55 143.28 143.29 146.35  146.1470
#> 5  2022-07-08 13:30:00  64547800 147.55 145.00 145.26 147.04  146.8360
#> 6  2022-07-11 13:30:00  63141600 146.64 143.78 145.67 144.87  144.6690
#> 7  2022-07-12 13:30:00  77588800 148.45 145.05 145.76 145.86  145.6577
#> 8  2022-07-13 13:30:00  71185600 146.45 142.12 142.99 145.49  145.2882
#> 9  2022-07-14 13:30:00  78140700 148.95 143.25 144.08 148.47  148.2641
#> 10 2022-07-15 13:30:00  76259900 150.86 148.20 149.78 150.17  149.9617
#> 11 2022-07-18 13:30:00  81420900 151.57 146.70 150.74 147.07  146.8660
#> 12 2022-07-19 13:30:00  82982400 151.23 146.91 147.92 151.00  150.7905
#> 13 2022-07-20 13:30:00  64823400 153.72 150.37 151.12 153.04  152.8277
#> 14 2022-07-21 13:30:00  65086600 155.57 151.94 154.50 155.35  155.1345
#> 15 2022-07-22 13:30:00  66675400 156.28 153.41 155.39 154.09  153.8763
#> 16 2022-07-25 13:30:00  53623900 155.04 152.28 154.01 152.95  152.7378
#> 17 2022-07-26 13:30:00  55138700 153.09 150.80 152.26 151.60  151.3897
#> 18 2022-07-27 13:30:00  78620700 157.33 152.16 152.58 156.79  156.5725
#> 19 2022-07-28 13:30:00  81378700 157.64 154.41 156.98 157.35  157.1317
#> 20 2022-07-29 13:30:00 101786900 163.63 159.50 161.24 162.51  162.2846
#> 21 2022-08-01 13:30:00  67829400 163.59 160.89 161.01 161.51  161.2860
#> 22 2022-08-02 13:30:00  59907000 162.41 159.63 160.10 160.01  159.7880
#> 23 2022-08-03 13:30:00  82507500 166.59 160.75 160.84 166.13  165.8996
#> 24 2022-08-04 13:30:00  55474100 167.19 164.43 166.01 165.81  165.5800
#> 25 2022-08-05 13:30:00  56697000 165.85 163.00 163.21 165.35  165.3500
#> 26 2022-08-08 13:30:00  60276900 167.81 164.20 166.37 164.87  164.8700
#> 27 2022-08-09 13:30:00  63135500 165.82 163.25 164.02 164.92  164.9200
#> 28 2022-08-10 13:30:00  70170500 169.34 166.90 167.68 169.24  169.2400
#> 29 2022-08-11 13:30:00  57149200 170.99 168.19 170.06 168.49  168.4900
#> 30 2022-08-12 13:30:00  68039400 172.17 169.40 169.82 172.10  172.1000
#> 31 2022-08-15 13:30:00  54091700 173.39 171.35 171.52 173.19  173.1900
#> 32 2022-08-16 13:30:00  56377100 173.71 171.66 172.78 173.03  173.0300
#> 33 2022-08-17 13:30:00  79542000 176.15 172.57 172.77 174.55  174.5500
#> 34 2022-08-18 13:30:00  62290100 174.90 173.12 173.75 174.15  174.1500
#> 35 2022-08-19 13:30:00  70346300 173.74 171.31 173.03 171.52  171.5200
#> 36 2022-08-22 13:30:00  69026800 169.86 167.14 169.69 167.57  167.5700
#> 37 2022-08-23 13:30:00  54147100 168.71 166.65 167.08 167.23  167.2300
#> 38 2022-08-24 13:30:00  53841500 168.11 166.25 167.32 167.53  167.5300
#> 39 2022-08-25 13:30:00  51218200 170.14 168.35 168.78 170.03  170.0300
#> 40 2022-08-26 13:30:00  78961000 171.05 163.56 170.57 163.62  163.6200
#> 41 2022-08-29 13:30:00  73314000 162.90 159.82 161.15 161.38  161.3800
#> 42 2022-08-30 13:30:00  77906200 162.56 157.72 162.13 158.91  158.9100
#> 43 2022-08-31 13:30:00  87991100 160.58 157.14 160.31 157.22  157.2200
#> 44 2022-09-01 13:30:00  74229900 158.42 154.67 156.64 157.96  157.9600
#> 45 2022-09-02 13:30:00  76905200 160.36 154.97 159.75 155.81  155.8100
#> 46 2022-09-06 13:30:00  73714800 157.09 153.69 156.47 154.53  154.5300
#> 47 2022-09-07 13:30:00  87449600 156.67 153.61 154.82 155.96  155.9600
#> 48 2022-09-08 13:30:00  84923800 156.36 152.68 154.64 154.46  154.4600
#> 49 2022-09-09 13:30:00  68028800 157.82 154.75 155.47 157.37  157.3700
#> 50 2022-09-12 13:30:00 104956000 164.26 159.30 159.59 163.43  163.4300
#> 51 2022-09-13 13:30:00 122656600 160.54 153.37 159.90 153.84  153.8400
#> 52 2022-09-14 13:30:00  87965400 157.10 153.61 154.79 155.31  155.3100
#> 53 2022-09-15 13:30:00  90481100 155.24 151.38 154.65 152.37  152.3700
#> 54 2022-09-16 13:30:00 162157000 151.35 148.37 151.21 150.70  150.7000
#> 55 2022-09-19 13:30:00  81328800 154.56 149.10 149.31 154.48  154.4800
aapl$get_history(start = '2022-07-01', end = '2022-07-14', interval = '1d')
#>                  date   volume   high    low   open  close adj_close
#> 1 2022-07-01 13:30:00 71051600 139.04 135.66 136.04 138.93  138.7373
#> 2 2022-07-05 13:30:00 73353800 141.61 136.93 137.77 141.56  141.3636
#> 3 2022-07-06 13:30:00 74064300 144.12 141.08 141.35 142.92  142.7218
#> 4 2022-07-07 13:30:00 66253700 146.55 143.28 143.29 146.35  146.1470
#> 5 2022-07-08 13:30:00 64547800 147.55 145.00 145.26 147.04  146.8360
#> 6 2022-07-11 13:30:00 63141600 146.64 143.78 145.67 144.87  144.6690
#> 7 2022-07-12 13:30:00 77588800 148.45 145.05 145.76 145.86  145.6577
#> 8 2022-07-13 13:30:00 71185600 146.45 142.12 142.99 145.49  145.2882
aapl$get_history(period = '1mo', interval = '1d')
#>                   date    volume   high    low   open  close adj_close
#> 1  2022-08-22 13:30:00  69026800 169.86 167.14 169.69 167.57    167.57
#> 2  2022-08-23 13:30:00  54147100 168.71 166.65 167.08 167.23    167.23
#> 3  2022-08-24 13:30:00  53841500 168.11 166.25 167.32 167.53    167.53
#> 4  2022-08-25 13:30:00  51218200 170.14 168.35 168.78 170.03    170.03
#> 5  2022-08-26 13:30:00  78961000 171.05 163.56 170.57 163.62    163.62
#> 6  2022-08-29 13:30:00  73314000 162.90 159.82 161.15 161.38    161.38
#> 7  2022-08-30 13:30:00  77906200 162.56 157.72 162.13 158.91    158.91
#> 8  2022-08-31 13:30:00  87991100 160.58 157.14 160.31 157.22    157.22
#> 9  2022-09-01 13:30:00  74229900 158.42 154.67 156.64 157.96    157.96
#> 10 2022-09-02 13:30:00  76905200 160.36 154.97 159.75 155.81    155.81
#> 11 2022-09-06 13:30:00  73714800 157.09 153.69 156.47 154.53    154.53
#> 12 2022-09-07 13:30:00  87449600 156.67 153.61 154.82 155.96    155.96
#> 13 2022-09-08 13:30:00  84923800 156.36 152.68 154.64 154.46    154.46
#> 14 2022-09-09 13:30:00  68028800 157.82 154.75 155.47 157.37    157.37
#> 15 2022-09-12 13:30:00 104956000 164.26 159.30 159.59 163.43    163.43
#> 16 2022-09-13 13:30:00 122656600 160.54 153.37 159.90 153.84    153.84
#> 17 2022-09-14 13:30:00  87965400 157.10 153.61 154.79 155.31    155.31
#> 18 2022-09-15 13:30:00  90481100 155.24 151.38 154.65 152.37    152.37
#> 19 2022-09-16 13:30:00 162157000 151.35 148.37 151.21 150.70    150.70
#> 20 2022-09-19 13:30:00  81328800 154.56 149.10 149.31 154.48    154.48
# }