https://github.com/jmettraux/avantage
A Ruby client to the Alpha Vantage API
https://github.com/jmettraux/avantage
alphavantage ruby
Last synced: about 1 year ago
JSON representation
A Ruby client to the Alpha Vantage API
- Host: GitHub
- URL: https://github.com/jmettraux/avantage
- Owner: jmettraux
- License: mit
- Created: 2019-06-14T05:13:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-25T14:54:36.000Z (over 5 years ago)
- Last Synced: 2025-03-25T15:21:28.076Z (over 1 year ago)
- Topics: alphavantage, ruby
- Language: Ruby
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# avantage
[](http://badge.fury.io/rb/avantage)
A Ruby library to query the [Alpha Vantage API](https://www.alphavantage.co/documentation/).
## usage
The first step is to instantiate a client:
```ruby
require 'avantage'
client = Avantage::Client.new('6SAMPLEWO0KLUG55')
# or more something like
client = Avantage::Client.new(File.read('.api.key').strip)
```
Functions may be called directly:
```ruby
require 'pp'
pp client.get(:global_quote, symbol: 'GOOG')
#
# ==>
#
# {"Global Quote"=>
# {"01. symbol"=>"GOOG",
# "02. open"=>"1109.6900",
# "03. high"=>"1116.3900",
# "04. low"=>"1098.9995",
# "05. price"=>"1103.6000",
# "06. volume"=>"1386684",
# "07. latest trading day"=>"2019-06-18",
# "08. previous close"=>"1092.5000",
# "09. change"=>"11.1000",
# "10. change percent"=>"1.0160%"}}
```
GLOBAL_QUOTE, SYMBOL_SEARCH, CURRENCY_EXCHANGE_RATE, and SECTOR can be called directly:
```ruby
client.global_quote('GOOG')
client.global_quote(symbol: 'GOOG')
client.global_quote(symbol: 'GOOG', datatype: 'csv')
client.quote('GOOG')
# ...
client.symbol_search(keywords: 'IBM')
client.symbol_search('IBM')
client.search(keywords: 'IBM')
client.search('IBM')
client.search(keywords: 'IBM', datatype: 'csv')
# ...
client.currency_exchange_rate('USD', 'JPY')
client.exchange_rate('USD', 'JPY')
client.exchange_rate(from: 'USD', to: 'JPY')
client.exchange_rate(from_currency: 'USD', to_currency: 'JPY')
client.forex(from: 'USD', to: 'JPY')
client.forex('USD', 'JPY')
client.forex(from: 'USD', to: 'JPY', datatype: 'csv')
# ...
client.sectors
client.sector
client.sectors(datatype: 'csv')
# ...
```
## license
MIT, see [LICENSE.txt](LICENSE.txt)