Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
google-finance-ruby-client
Advanced tools
A Ruby client for the undocumented Google Finance web API. Supports stock quotes and historical prices. Attempts to make sense of, coerce and structure the data.
IANAL, but do note that if your application is for public consumption, using the Google Finance API seems to be against Google's terms of service.
Add to Gemfile.
gem 'google-finance-ruby-client'
Run bundle install
.
Fetches stock quotes via https://finance.google.com/finance.
quote = GoogleFinance::Quote.get('MSFT')
quote.last_trade_price # 84.26
quote.change # 0.09
quote.change_in_percent # 0.11
quote.change_in_percent_s # "+0.11%"
See quote.rb for returned fields.
If a symbol cannot be found a GoogleFinance::Errors::SymbolNotFound is raised.
Searches for a ticker or tickers, then fetches each quote.
quotes = GoogleFinance::Quotes.search('MSFT', 'AB')
quotes.size # 2
quotes[0] # GoogleFinance::Quote.get('MSFT')
quotes[1] # GoogleFinance::Quote.get('AB')
If one of the symbols cannot be found a GoogleFinance::Errors::SymbolsNotFound is raised.
Fetches price history for a ticker via https://finance.google.com/finance/historical.
prices = GoogleFinance::History.get('MSFT')
# prices for the last year of open markets
prices.count # 251
# prices appear in reverse chronological order
prices.first # #<GoogleFinance::Price close=85.54 date=#<Date: 2017-12-29> high=86.05 low=85.5 open=85.63 volume=18717406>
prices[1] # #<GoogleFinance::Price close=85.72 date=#<Date: 2017-12-28> high=85.93 low=85.55 open=85.9 volume=10594344>
If a symbol cannot be found a GoogleFinance::Errors::SymbolNotFound is raised.
The following options are supported.
start_date
: date to start retrieving fromend_date
: date to retrieve data up toRetrieve prices in the first trading week of 2016. No trading on the week-end or during holidays.
prices = GoogleFinance::History.get('MSFT', start_date: Date.parse('2016-01-03'), end_date: Date.parse('2016-01-10'))
prices.count # 5
prices.first # #<GoogleFinance::Price close=52.33 date=#<Date: 2016-01-08> high=53.28 low=52.15 open=52.37 volume=48753969>
Fetches price history, including at intraday intervals, for a ticker via https://finance.google.com/finance/getprices.
prices = GoogleFinance::Prices.get('MSFT')
prices.exchange # NASDAQ
# prices for the last month of open markets
prices.count # 21
# prices appear in reverse chronological order
prices.last #<GoogleFinance::Price close=85.71 date=2017-12-27 16:00:00 -0500 high=85.98 low=85.215 open=85.65 volume=14678025>
prices[-2] #<GoogleFinance::Price close=85.4 date=2017-12-26 16:00:00 -0500 high=85.5346 low=85.03 open=85.31 volume=9891237>
See price.rb for returned fields.
If a symbol cannot be found a GoogleFinance::Errors::SymbolNotFound is raised.
The following options are supported.
exchange
: stock exchange symbol on which stock is traded, eg. NASDAQ
interval
: interval size in secondsperiod
: period, a number followed by d
(days) or Y
(years)fields
: array of data to return
date
: timestampopen
: price at market openclose
: price at market closevolume
: volumelow
: low pricehigh
: high priceRetrieve intraday prices in 1 hour intervals.
prices = GoogleFinance::Prices.get('GOOG', interval: 60 * 60, period: '1d')
prices.count # 7
prices # array of GoogleFinance::Price, date=2017-12-29 10:00AM, 11:00AM, etc.
Retrieve only prices at market close.
prices = GoogleFinance::Prices.get('GOOG', fields: [:days, :close])
prices.first # #<GoogleFinance::Price close=1047.41 date=2017-11-28 16:00:00 -0500>
See CONTRIBUTING.
Copyright (c) 2017, Daniel Doubrovkine and Contributors.
This project is licensed under the MIT License.
FAQs
Unknown package
We found that google-finance-ruby-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.