tiingo data with riingo
## Download financial data with riingo
## Perform various data manipulations with dplyr
## plot data with ggplot
## Athanassios Stavrakoudis
## 29 Oct 2021
library(riingo)
library(tidyverse)
# Apple Inc daily prices
riingo_prices("AAPL",
start_date = "2021-01-01",
resample_frequency = "daily")
riingo_iex_prices("AAPL",
start_date = "2021-01-01",
resample_frequency = "daily")
# Apple Inc minute prices
riingo_iex_prices("AAPL",
start_date = Sys.Date() - 1,
resample_frequency = "1min")
# crypto currencies
riingo_crypto_prices("btcusd")
BTC <- riingo_crypto_prices("btcusd", start_date = "2011-01-01")
# plot bitcoin price
BTC %>%
ggplot(aes(x = date, y = close)) +
geom_line() +
theme_linedraw(base_size = 15, base_family = "NimbusSan")
# bitcoin price by mitute since yesterday
BTC <- riingo_crypto_prices("btcusd",
start_date = Sys.Date() - 1,
resample_frequency = "1min")
BTC %>%
ggplot(aes(x = date, y = close)) +
geom_line(color = "blue", size = 1) +
theme_linedraw(base_size = 15, base_family = "NimbusSan")
# Foreign exchange rates
riingo_fx_prices("eurusd",
start_date = Sys.Date() - 1,
resample_frequency = "1min")
EURUSD <- riingo_fx_prices("eurusd",
start_date = Sys.Date() - 365,
resample_frequency = "1day")
EURUSD %>%
ggplot(aes(x = date, y = close)) +
geom_line(color = "blue", size = 1) +
labs(y = "EUR/USD") +
theme_linedraw(base_size = 15, base_family = "NimbusSan")
# multiple tickers
FX <- riingo_fx_prices(c("eurusd", "eurchf"),
start_date = Sys.Date() - 365,
resample_frequency = "1day")
# plot multiple lines
FX %>%
ggplot(aes(x = date, y = close, colour = ticker)) +
geom_line() +
labs(y = "Exchange rate") +
theme_linedraw(base_size = 15, base_family = "NimbusSan")
# facet plot
FX %>%
ggplot(aes(x = date, y = close)) +
geom_line() +
labs(y = "Exchange rate") +
theme_linedraw(base_size = 15, base_family = "NimbusSan") +
facet_wrap(~ticker)
# commodities
OIL <- riingo_prices("OIL",
start_date = "2010-01-01",
end_date = Sys.Date(),
resample_frequency = "daily")
OIL %>%
ggplot(aes(x = date, y = close)) +
geom_line() +
labs(y = "Oil price") +
theme_linedraw(base_size = 15, base_family = "NimbusSan")
Συνδεθείτε για περισσότερες δυνατότητες αλληλεπίδρασης,
σχολιασμοί, εξωτερικοί σύνδεσμοι, βοήθεια, ψηφοφορίες, αρχεία, κτλ.
σχολιασμοί, εξωτερικοί σύνδεσμοι, βοήθεια, ψηφοφορίες, αρχεία, κτλ.
Εκπαιδευτικό υλικό από τον
Αθανάσιο Σταυρακούδη
σας παρέχετε κάτω από την άδεια
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.
Σας παρακαλώ να ενημερωθείτε για κάποιους επιπλέον περιορισμούς
http://stavrakoudis.econ.uoi.gr/stavrakoudis/?iid=401.