# Load libraries
library(tidyquant)
library(tidyverse)
# Get the list of `get` options
tq_get_options()
# Get stock prices for a stock from Yahoo
aapl_stock_prices <- tq_get("AAPL")
# Get stock prices for multiple stocks
mult_stocks <- tq_get(c("FB", "AMZN"),
get = "stock.prices",
from = "2016-01-01",
to = "2017-01-01")
if (FALSE) {
# --- Quandl ---
quandl_api_key('')
# Energy data from EIA
tq_get("EIA/PET_MTTIMUS1_M", get = "quandl", from = "2010-01-01")
# --- Tiingo ---
tiingo_api_key('')
# Tiingo Prices (Free alternative to Yahoo Finance!)
tq_get(c("AAPL", "GOOG"), get = "tiingo", from = "2010-01-01")
# Sub-daily prices from IEX ----
tq_get(c("AAPL", "GOOG"),
get = "tiingo.iex",
from = "2020-01-01",
to = "2020-01-15",
resample_frequency = "5min")
# Tiingo Bitcoin Prices ----
tq_get(c("btcusd", "btceur"),
get = "tiingo.crypto",
from = "2020-01-01",
to = "2020-01-15",
resample_frequency = "5min")
# --- Alpha Vantage ---
av_api_key('')
# Daily Time Series
tq_get("AAPL",
get = "alphavantager",
av_fun = "TIME_SERIES_DAILY_ADJUSTED",
outputsize = "full")
# Intraday 15 Min Interval
tq_get("AAPL",
get = "alphavantage",
av_fun = "TIME_SERIES_INTRADAY",
interval = "15min",
outputsize = "full")
# FX DAILY
tq_get("USD/EUR", get = "alphavantage", av_fun = "FX_DAILY", outputsize = "full")
# FX REAL-TIME QUOTE
tq_get("USD/EUR", get = "alphavantage", av_fun = "CURRENCY_EXCHANGE_RATE")
}
Run the code above in your browser using DataLab