kendocode / iex-ruby-client

IEX Finance API Ruby Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IEX Finance API

Gem Version Build Status

A Ruby client for the IEX Finance API.

Installation

Add to Gemfile.

gem 'iex-ruby-client'

Run bundle install.

Usage

Get a Single Price

Fetches a single number, being the IEX real time price, the 15 minute delayed market price, or the previous close price.

IEX::Resources::Price.get('MSFT') # 93.78

See #price for detailed documentation.

Get a Quote

Fetches a single stock quote.

quote = IEX::Resources::Quote.get('MSFT')

quote.latest_price # 90.165
quote.change # 0.375
quote.change_percent # 0.00418
quote.change_percent_s # '+0.42%'

See #quote for detailed documentation or quote.rb for returned fields.

Get Company Information

Fetches company information for a symbol.

company = IEX::Resources::Company.get('MSFT')

company.ceo # 'Satya Nadella'
company.company_name # 'Microsoft Corporation'

See #company for detailed documentation or company.rb for returned fields.

Get Recent News

Fetches news for a symbol.

news = IEX::Resources::News.get('MSFT')

news.size # 10

latest = news.first
latest.headline # 'Smartsheet files for $100M IPO with growing losses'
latest.url # 'https://...'

Use market to get market-wide news.

news = IEX::Resources::News.get(:market)

Retrieve a range between 1 and 50.

news = IEX::Resources::News.get('MSFT', 5)

See #news for detailed documentation or news.rb for returned fields.

Get Chart

Fetches charts for a symbol.

chart = IEX::Resources::Chart.get('MSFT')

chart.size # 38510

first = chart.first
first.label # '9:30 AM'
first.high # 94.97

You can specify a chart range and additional options.

# 1d or 1m data depending on the day or week and time of day
IEX::Resources::Chart.get('MSFT', 'dynamic')

# a specific date
IEX::Resources::Chart.get('MSFT', Date.new(2018, 3, 26))

# every n-th data point
IEX::Resources::Chart.get('MSFT', '1d', chart_interval: 10)

See #chart for detailed documentation or chart/default and chart/one_day for returned fields.

Errors

SymbolNotFound

If a symbol cannot be found an IEX::Errors::SymbolNotFound exception is raised.

Contributing

See CONTRIBUTING.

Copyright and License

Copyright (c) 2018, Daniel Doubrovkine and Contributors.

This project is licensed under the MIT License.

Data provided for free by IEX, see terms.

About

IEX Finance API Ruby Client

License:MIT License


Languages

Language:Ruby 100.0%