Skip to content

Commit

Permalink
Add stock_market_list
Browse files Browse the repository at this point in the history
  • Loading branch information
bguban committed Mar 5, 2020
1 parent d998cab commit 8a20c54
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 1.1.2 (Next)

* Your contribution here.
* [#65](https://github.com/dblock/iex-ruby-client/pull/65): Add stock_market_list - [@bguban](https://github.com/bguban).
* [#64](https://github.com/dblock/iex-ruby-client/pull/64): Add ref_data_isin - [@bguban](https://github.com/bguban).

### 1.1.1 (2020/03/02)
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ A Ruby client for the [The IEX Cloud API](https://iexcloud.io/docs/api/).
- [Get Largest Trades](#get-largest-trades)
- [Get a Quote for Crypto Currencies](#get-a-quote-for-crypto-currencies)
- [ISIN Mapping](#isin-mapping)
- [Get List](#get-list)
- [Other Requests](#other-requests)
- [Configuration](#configuration)
- [Errors](#errors)
Expand Down Expand Up @@ -394,6 +395,16 @@ client.ref_data_isin(['US0378331005', 'US5949181045'], mapped: true) # {'US03783

See [#ISIN Mapping](https://iexcloud.io/docs/api/#isin-mapping) for detailed documentation or [isin_mapping.rb](lib/iex/resources/isin_mapping.rb) for returned fields.

### Get List

Returns an array of quotes for the top 10 symbols in a specified list.

```ruby
client.stock_market_list(:mostactive) # [{symbol: 'AAPL', ...}, {...}]
```

See [#list](https://iexcloud.io/docs/api/#list) for detailed documentation or [quote.rb](lib/iex/resources/quote.rb) for returned fields.

### Other Requests

Public endpoints that aren't yet supported by the client can be called using `client.get`, `client.post`, `client.put`
Expand Down
1 change: 1 addition & 0 deletions lib/iex/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require_relative 'endpoints/sectors'
require_relative 'endpoints/crypto'
require_relative 'endpoints/ref_data'
require_relative 'endpoints/list'

require_relative 'api/config'
require_relative 'api/client'
1 change: 1 addition & 0 deletions lib/iex/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Client
include Endpoints::Quote
include Endpoints::Sectors
include Endpoints::RefData
include Endpoints::List

include Cloud::Connection
include Cloud::Request
Expand Down
11 changes: 11 additions & 0 deletions lib/iex/endpoints/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module IEX
module Endpoints
module List
def stock_market_list(list_type, options = {})
get("stock/market/list/#{list_type}", { token: publishable_token }.merge(options)).map do |data|
IEX::Resources::Quote.new(data)
end
end
end
end
end
76 changes: 76 additions & 0 deletions spec/fixtures/iex/list/mostactive.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions spec/iex/endpoints/list_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'spec_helper'

describe IEX::Endpoints::List do
include_context 'client'

describe '#list', vcr: { cassette_name: 'list/mostactive' } do
subject { client.stock_market_list(:mostactive) }

it 'retrieves a list of quotes' do
expect(subject).to all(be_a(IEX::Resources::Quote))
expect(subject.map(&:symbol)).to match_array(%w[AAPL AMD BAC F GE INO INTC MSFT T XOM])
end
end
end

0 comments on commit 8a20c54

Please sign in to comment.