GithubHelp home page GithubHelp logo

iexcloudr's Introduction

iexcloudR

tested with testthat

An R language wrapper for the new iexcloud market data API from IEX Group Inc. All data is returned dataframes (actually tibbles).

This package is a companion to the NodeJS package iexcloud_api_wrapper

Usage

To install as a dependancy into your project at the R REPL command prompt

install.github("schardtbc/iexcloudR")

then in your .env or .Renviron file add the following keys

IEXCLOUD_API_VERSION = "stable"
IEXCLOUD_PUBLIC_KEY = "pk_..."
IEXCLOUD_SECRET_KEY = "sk_..."

# use the pk and sk obtained from your iexcloud account
# make sure the .env file is in your .gitignore file
# do not hard code the keys into your application code
# do not upload the keys to github.
# you can easily change the keys if they become compromised

Note: when IEXCLOUD_PUBLIC_KEY starts with a "T" ,as in "Tpk= ..." then the base url used will be the sandbox url instead of the production cloud url

To test that everything installed correctly and the .env file is properly setup you can use the following or similar code

library(iexcloudR)

historyFor("AAPL")

About iexcloud

iexcloud is a product of IEX Group Inc. which operates the Investors Exchange IEX, a stock exhange for US equities which trades > 9B notational value on a daily basis.

Using iexcloud requires registration to obtain a unique api key which is used for all data requests.

A majority of the endpoints are charged a usage free which varies by the source and type of data returned. All IEX Group sourced data is free.

Each endpoint is assigned a cost in terms of message units.

Plan Monthly Message Unit Allotment Monthy Fee
Free 500,000 Free
Launch 5,000,000 $9
Grow 100,000,000 $49
Scale 1,000,000,000 $ 499

see https://iexcloud.io/pricing/ for current plans, rates

Api reference documentation

https://iexcloud.io/docs/api/#introduction

Attribution to IEX

Attribution is required of all users of iexcloud. Put “Powered by IEX Cloud” somewhere on your site or app, and link that text to https://iexcloud.io. Alternately, the attribution link can be included in your terms of service.

Powered by IEX Cloud

Current Implementation Status

Below is a list of the iexcloud APIs that have ([x]) and have not ([ ]) been implemented by this package.

Account

Endpoint Message Units per
[X] MetaData 0 as in free
[X] Usage 0 as in free
[ ] Pay as you go 0 as in free

Stocks

Endpoint Message Units per
[X] Advanced Stats 3020 per symbol
[X] Balance Sheet 3000 per symbol per period
[X] Batch Requests varies with data types requested
[ ] Book 1 per symbol
[X] Cash Flow 1000 per symbol per period
[ ] Collections 1 per symbol in collection
[X] Company 1 per symbol
[X] Delayed Quote 1 per symbol
[X] Dividends 10 per symbol
[X] Earnings 1000 per symbol per period
[X] Earnings Today 1001 per symbol returned
[X] Effective Spread 0 as in free
[X] Estimates 10000 per symbol per period
[X] Financials 5000 per symbol per period
Historical Prices
[X] End of day 10 per symbol per day
[X] Insder Roster 5000 per symbol
[X] Insider Summary 5000 per symbol
[X] Insider Transactions 50 per transaction
[X] Intraday 1 per symbol per perios max 50 per call
[X] Income Statement 1000 per symbol per period
[ ] IPO Calendar upcoming-ipos 100 per IPO returned
[ ] IPO Calendar today-ipos 500 per iPO returned
[x] Key Stats 20 per symbol
[ ] Largest Trades 1 per trade returned
[X] List 1 per quote returned
[X] Logo 1 per logo
[X] Market Volume (U.S.) 1 per call
[X] News 10 per news item returned
[X] OHLC 2 per symbol
[X] marketOpenClose 500 all symbols
[X] Peers 500 per symbol
[X] Previous Day Prices 2 per symbol
[X] Price 1 per symbol per call
[X] Price Target 500 per symbol
[X] Quote 1 per quote
[X] Recomendation Trends 5000 per symbol
[X] Sector Performance 1 per sector
[X] Social Sentiment, daily 100 per date
[X] Social Sentiment, by minute 200 per date
[X] Splits 10 per symbol per record
[X] Upcoming Earnings 5 per symbol
[X] Volume by Venue 20 per call

Alternative Data

Endpoint Message Units per
[X] News
[ ] Crypto

Data Points

Endpoint Message Units per
[X] List Keys 0
[X] Value for Key varies symbol

Time Series

Endpoint Message Units per
[X] List time-series ids 0
[X] Value for time-series id varies record

Reference Data

Endpoint Message Units per
[X] Symbols 100 per call
[X] IEX Symbols 0 as in free
[ ] U.S. Exchanges 1 per call
[ ] U.S. Holidays and Trading Days 1 per call
[ ] Stock Tags
[ ] Stock Collections
[X] Mutual Fund Symbols 100 per call
[X] OTC Symbols 100 per call
[ ] Forex / Currency Symbols
[ ] Options Symbols
[ ] Commodities Symbols
[ ] Bonds Symbols
[ ] Crypto Symbols

Investors Exchange Data [Free]

Endpoint
[X] TOPS
[X] TOPS Last
[ ] DEEP
[ ] DEEP Auction
[ ] DEEP Book
[ ] DEEP Operational Halt Status
[ ] DEEP Official Price
[ ] DEEP Security Event
[ ] DEEP Short Sale Price Tst Status
[ ] DEEP System Event
[X] DEEP Trades
[ ] DEEP Trade Break
[ ] DEEP Trading Status
[ ] Listed Regulation SHO Threshold Securities List
[ ] Listed Short Interest List
[ ] Stats Historical Daily
[ ] Stats Historical Summary
[ ] Stats Intraday
[ ] Stats Recent
[ ] Stats Records

API System Metadata

Endpoint Message Units per
[ ] Status 0

In Development at IEX Group

  • FOREX CURRANCIES
  • OPTIONS
  • COMMODITIES
  • BONDS
  • REALTME, SCALABLE NOTIFICATIONS
  • EVENT DRIVEN AUTOMATED RULES FOR SERVERLESS DATA ANALYSIS

iexcloudr's People

Contributors

no-dice-io avatar schardtbc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

iexcloudr's Issues

Questions on initial set up

Hi there:

I'm working on getting the API set up for the first time. I followed the instructions you lay out but encounter the following problem. Code below:

install_github("schardtbc/iexcloudR")
library("iexcloudR")

IEXCLOUD_API_VERSION = "https://cloud.iexapis.com/stable/"
IEXCLOUD_PUBLIC_KEY = "pk_..."
IEXCLOUD_SECRET_KEY = "sk_..."

But I get the following error:

historyFor("AAPL")
Error in addToken(endpoint) : missing IEXCLOUD_PRIVATE_KEY value

I don't see any reference to a "Private Key" in the docs or in your instructions. Any advice?

Error: Column name `symbol` must not be duplicated

Sample code:

library(iexcloudR)
historyFor("AAPL")

returns an error:

Error: Column name `symbol` must not be duplicated.
Run `rlang::last_error()` to see where the error occurred.

Are there any docs on how to use the package?

listSymbols() throws error - Error: All nested columns must have the same number of elements.

Describe the bug
Call to listSymbols() returns error Error: All nested columns must have the same number of elements.

Expected behavior
A tibble with the list of symbols is returned

Error details

> rlang::last_error()
<error/rlang_error>
All nested columns must have the same number of elements.
Backtrace:
  1. iexcloudR::listSymbols()
  2. tibble::as_tibble(do.call(rbind, res$content))
 10. tidyr::unnest_legacy(.)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/rlang_error>
All nested columns must have the same number of elements.
Backtrace:
     █
  1. └─iexcloudR::listSymbols()
  2.   └─tibble::as_tibble(do.call(rbind, res$content)) %>% tidyr::unnest_legacy()
  3.     ├─base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
  4.     └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
  5.       └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
  6.         └─iexcloudR:::`_fseq`(`_lhs`)
  7.           └─magrittr::freduce(value, `_function_list`)
  8.             ├─base::withVisible(function_list[[k]](value))
  9.             └─function_list[[k]](value)
 10.               ├─tidyr::unnest_legacy(.)
 11.               └─tidyr:::unnest_legacy.data.frame(.)

Desktop (please complete the following information):

  • OS: Ubuntu 20.10

All functions throw errors - cannot connect to IEX API

The iexcloudR package loads with no problems. My API keys are saved in .env and Sys.getenv verifies these variables are saved. My problem is any function I've tried so far returns the same error:

Error in curl::curl_fetch_memory(url, handle = handle) : 
  Could not resolve host: NA

The traceback is usually the same except the first (1) function:

8: .Call(R_curl_fetch_memory, enc2utf8(url), handle, nonblocking)
7: curl::curl_fetch_memory(url, handle = handle)
6: request_fetch.write_memory(req$output, req$url, handle)
5: request_fetch(req$output, req$url, handle)
4: request_perform(req, hu$handle$handle)
3: httr::GET(url)
2: iex(endpoint)
1: historyFor("AAPL")

This is the code for curl::curl_fetch_memory:

function (url, handle = new_handle()) 
{
  nonblocking <- isTRUE(getOption("curl_interrupt", TRUE))
  output <- .Call(R_curl_fetch_memory, enc2utf8(url), handle, 
    nonblocking)
  res <- handle_data(handle)
  res$content <- output
  res
}

Eventually the error traces back to the line output <- .Call(R_curl_fetch_memory, enc2utf8(url), handle, nonblocking) in the block above, at which point we've reached C++ and I can't dig any deeper.

historyFor error - "Column name `symbol` must not be duplicated."

Describe the bug
Running the example in the README: historyFor("AAPL") returns an error (actually any symbol I use is returning the same error.

Error: Column name `symbol` must not be duplicated.

To Reproduce
Steps to reproduce the behavior:

library(iexcloudR)
historyFor("AAPL")

Expected behavior
a tibble is returned with the history for AAPL stock

Error details

> rlang::last_error()
█
├─<error/tibble_error_column_names_must_be_unique>
│ Column name `symbol` must not be duplicated.
└─<error/vctrs_error_names_must_be_unique>
  Names must be unique.
Backtrace:
  1. iexcloudR::historyFor("AAPL")
  2. tibble::as_tibble(do.call(rbind, data))
  9. tibble::add_column(., symbol = symbol, .before = 1)
 10. tibble:::set_repaired_names(out, .name_repair)
 12. tibble:::repaired_names(...)
 15. vctrs::vec_as_names(...)
 17. vctrs:::validate_unique(names = names, arg = arg)
 18. vctrs:::stop_names_must_be_unique(names, arg)
 19. vctrs:::stop_names(...)
 20. vctrs:::stop_vctrs(class = c(class, "vctrs_error_names"), ...)
> rlang::last_trace()
█
├─<error/tibble_error_column_names_must_be_unique>
│ Column name `symbol` must not be duplicated.
└─<error/vctrs_error_names_must_be_unique>
  Names must be unique.
Backtrace:
     █
  1. └─iexcloudR::historyFor("AAPL")
  2.   └─`%>%`(...)
  3.     ├─base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
  4.     └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
  5.       └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
  6.         └─iexcloudR:::`_fseq`(`_lhs`)
  7.           └─magrittr::freduce(value, `_function_list`)
  8.             └─function_list[[i]](value)
  9.               └─tibble::add_column(., symbol = symbol, .before = 1)
 10.                 └─tibble:::set_repaired_names(out, .name_repair)
 11.                   ├─rlang::set_names(...)
 12.                   └─tibble:::repaired_names(...)
 13.                     ├─tibble:::subclass_name_repair_errors(...)
 14.                     │ └─base::withCallingHandlers(...)
 15.                     └─vctrs::vec_as_names(...)
 16.                       └─(function () ...
 17.                         └─vctrs:::validate_unique(names = names, arg = arg)
 18.                           └─vctrs:::stop_names_must_be_unique(names, arg)
 19.                             └─vctrs:::stop_names(...)
 20.                               └─vctrs:::stop_vctrs(class = c(class, "vctrs_error_names"), ...)

`historyFor` emits warning message referring to `cols` paramenter

What happens
The iex API appears to now require a columns definition, manifested as a warning in use of functions that call it.

How to reproduce
After setting environment to define API keys, run following:

require(iexcloudR)
historyFor("AAPL")

Expected behavior
Printing of data frame containing stock price history for AAPL.

Actual behavior
Printing of stock history is followed by warning:

Warning message:
`cols` is now required.
Please use `cols = c(date, open, close, high, low, volume, uOpen, uClose, uHigh, 
    uLow, uVolume, change, changePercent, label, changeOverTime)` 

The parameter cols does not seem to be applicable to the historyFor function, however.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.