Skip to content
No description, website, or topics provided.
Ruby Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


This is a high-level Ruby wrapper for Alpaca trading API. This implementation only supports the Web API v2 API, there is no plan to support Web API v1.


Add this line to your application's Gemfile:

gem 'alpaca-trade-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install alpaca-trade-api



By default, the library is configured to use the Paper Trading host - - as the endpoint it connects to, and loads both the key id and secret key from the following environment variables: ALPACA_API_KEY_ID and ALPACA_API_SECRET_KEY. To configure the library differently:

Alpaca::Trade::Api.configure do |config|
  config.endpoint = ''
  config.key_id = 'A_KEY_ID'
  config.key_secret = 'A_S3CRET'

Supported endpoints

Here's a table with all currently supported endpoints in this library:

Object Action Method
Account [GET] Get the account Client#account
Orders [GET] Get a list of orders Client#order
[POST] Request a new order Client#new_order
[GET] Get an order Client#order(id:)
[GET] Get an order by client order id Client#order(id:)
[PATCH] Replace an order Client#replace_order
[DELETE] Cancel all orders Client#cancel_orders
[DELETE] Cancel an order Client#cancel_order(id:)
Positions [GET] Get open positions Client#positions
[GET] Get an open position Client#position(symbol:)
[DELETE] Close all positions Client#close_positions
[DELETE] Close a position Client#close_position(symbol:)
Assets [GET] Get assets Client#assets
[GET] Get assets/:id Client#asset(symbol:)
[GET] Get an asset Client#asset(symbol:)
Calendar [GET] Get the calendar Client#calendar(start_date:, end_date:)
Clock [GET] Get the clock Client#clock
Bars [GET] Get a list of bars Client#bars(timeframe, symbols, limit:)


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at


The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.