Skip to contents

alpacar is an R package wrapper for the Alpaca API.

API documentation can be found here.

The functionality for this package is covered in a series of blog posts:

Installation

Install from GitHub.

remotes::install_github("datawookie/alpacar")

Load

Once installed you can load the package. I also like to increase the number of significant figures in tibble output (completely optional).

  library(alpacar)
  
  # Expand decimal places.
  options(pillar.sigfig = 8)

Authenticate

I store my credentials in environment variables. Specifically I use a .env file in my project directory.

library(dotenv)

load_dot_env()

authenticate(
  key = Sys.getenv("ALPACA_KEY"),
  secret = Sys.getenv("ALPACA_SECRET_KEY")
)

Endpoints