knitr::opts_chunk$set( collapse = TRUE, comment = "#>", cache = TRUE ) library(iexcloudR) library(tidyquant)
The IEX Cloud API is a micropayment Api for financial and stock quote data. The Api is hosted by IEX Group Inc. The Investors Exchange. Using the Api requires registration. There is a free tier for use during initial api exploration and application development.
This is functional wrapper which returns data as tibbles, with a few exceptions. See the package documentation for call signitures, parameter descriptions, and the micropayment cost of each function call.
During resistration at icloud.io you were given security tokens required to access this API. This wrapper will read those tokens from the .env (or .Renviron) file. The .env file must include the following three key pairs;
IEXCLOUD_VERSION = "BETA" IEXCLOUD_PRIVATE_KEY = "pk_.........." IEXCLOUD_SECRET_KEY = "sk_.........."
AAPL<-historyFor("AAPL",timePeriod = "3m") # Candlestick Chart AAPL %>% ggplot(aes(x = date, y = close)) + geom_segment(aes(x=date, y = (min(low)+(max(high)-min(low))*(volume/max(volume))), xend = date, yend = min(low)),color="purple",size=0.2) + geom_candlestick(aes(open = open, high = high, low = low, close = close),color_up="black",color_down="black",fill_up="green",fill_down="red",size=0.4) + ggtitle("Apple 3 month chart") + ylab("price")
intraday <-historyFor("AAPL",date ="2019-05-22",chartIEXOnly = TRUE) # Candlestick Chart intraday %>% ggplot(aes(x = minute, y = close)) + geom_candlestick(aes(open = open, high = high, low = low, close = close),color_up="black",color_down="black",fill_up="green",fill_down="red",size=0.3) + ggtitle("Apple Intraday chart") + ylab("price") + scale_x_continuous(name = "time (America/New_York)",breaks = c(0,30,90,150,210,270,330,390), labels =c('9:30','10','11','12','1','2','3','4'));
"He who gives up [code] safety for [code] speed deserves neither." (via)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.