I have an assigment and i need to use stocks and index, but i'm struggling with the script. I've tried alphavantage and Quandl, but i don't know how to set the period as well as getting it in a table. Thanks for the help
Accessing Quandl API is easy; consider the following code:
library(Quandl)
library(tidyverse)
frmData <- Quandl("BCHARTS/BITSTAMPUSD")
head(frmData)
Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price
1 2019-11-02 9250.70 9396.91 9201.19 9302.97 2400.145 22278130 9281.993
2 2019-11-01 9158.08 9303.53 9054.60 9250.45 6640.552 60832092 9160.697
3 2019-10-31 9169.55 9438.61 8961.53 9150.07 10113.159 92792854 9175.456
4 2019-10-30 9426.94 9437.06 8985.25 9159.94 8814.438 80752701 9161.412
5 2019-10-29 9216.39 9573.35 9051.48 9426.94 9059.612 85007062 9383.080
6 2019-10-28 9547.32 9950.00 9177.84 9216.44 14722.019 139923976 9504.402
ggplot(data = frmData, aes(x = Date, y = Close)) +
geom_line(color = "red")
In most use cases you don't really need to set the period ahead, and it is sufficient to dplyr::filter()
the records afterwards.
If you need to combine several downloaded datasets - e.g. API results for a stock, and for an index - consider one of the dplyr::*_join()
functions.
Thank you very much! I'm new to R, so i appreciate the reply!
Is there a free alternativ to Quandl? I need index SPY & DAX, as well as a few stocks. Stocks like Tesla is not free to use and i got error message
This will depend on your needs; Quandl API has limitations, but I found them pretty generous.
https://help.quandl.com/article/68-is-there-a-rate-limit-or-speed-limit-for-api-usage
50 calls per day for anonymous user is not much, but just by registering you can increase that to a more than reasonable amount.
I am not certain about individual tickers (both indexes should be covered).
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.