Skip to contents

stocks_quote() lets the user download stocks live data.

stocks_hist() lets the user download stocks historical data.

Usage

stocks_quote(symbols, ...)

stocks_hist(
  symbols = c("VTI", "META"),
  from = Sys.Date() - 365,
  to = Sys.Date(),
  today = TRUE,
  tax = 15,
  parg = FALSE,
  cache = TRUE,
  quiet = FALSE,
  ...
)

# S3 method for class 'stocks_hist'
plot(x, type = 1, ...)

Arguments

symbols

Character Vector. List of symbols to download historical data.

...

Additional parameters.

from, to

Date. Dates for range. If not set, 1 year will be downloaded. Do use more than 4 days or will be over-written.

today

Boolean. Do you wish to add today's live quote? This will happen only if to value is the same as today's date

tax

Numeric. How much [0-99] of your dividends are gone with taxes?

parg

Boolean. Personal argument. Used to personalize stuff, in this case, taxes changed from A to B in given date (hard-coded)

cache

Boolean. Use daily cache if available?

quiet

Boolean. Keep quiet? If not, message will be shown.

x

stocks_hist object

type

Integer. Select type of plot.

Value

data.frame with Symbol, Type of stock, Quote time, current value, Daily Change, Market, and Symbol Name.

See also

Other Investment: etf_sector(), splot_summary(), stocks_file()

Other Scrapper: filesGD(), get_mp3(), gtrends_related(), holidays(), ip_data(), readGS(), splot_summary()

Examples

# \donttest{
# Multiple quotes at the same time
stocks_quote(c("VTI", "VOO", "TSLA"))
#> # A tibble: 3 × 9
#>   Symbol QuoteTime           Value DailyChange DailyChangeP  Open  High   Low
#>   <chr>  <dttm>              <dbl>       <dbl>        <dbl> <dbl> <dbl> <dbl>
#> 1 VTI    2024-10-22 16:00:00  288.      -0.330      -0.115   287.  288.  286.
#> 2 VOO    2024-10-22 16:00:00  536.      -0.370      -0.0690  534.  537.  533.
#> 3 TSLA   2024-10-22 16:00:01  218.      -0.880      -0.402   217.  218.  215.
#> # ℹ 1 more variable: Volume <int>
# }
if (FALSE) { # \dontrun{
df <- stocks_hist(symbols = c("VTI", "META", "FIW"), from = Sys.Date() - 180)
print(head(df))
plot(df)
} # }