yahoo_finanza 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca919f9cbbad25047bd58b4b3cdccdc66a5a0c14
4
- data.tar.gz: 6a6822ff52a03843162af5ce09945827b0e3cd67
3
+ metadata.gz: e9534658e039738eabf39f87c79c65f0d1127121
4
+ data.tar.gz: fd0890f4ec5e42e23922cd8313659621c57244b5
5
5
  SHA512:
6
- metadata.gz: aa9c38395cae970a0bbdb1a3eac53ac69ed81c8f3eeff2486787df13c0185c05d52e5ec58c704640e467f0bc9ba8cb0a67884c28d89e5a39821d945f43c0b151
7
- data.tar.gz: 4a08070fa5ecb450ef7f6766a31203c0c5d7983b39048d701b673cf4f914e731ccf09b4dbeedbc8dee05eb370f75879a355ce18027b04aa9211e95dd0a0d57cf
6
+ metadata.gz: dddc1b376348ac563bb403d5d3212b156510d850f601340f3c6d8ee4e538827984f6cf7e8cfb0bd5aff88f618f92d8aa0063e126286671527aef06972ec9d160
7
+ data.tar.gz: ccaf43d61c76420fdfb0519d2673070f22df9a51073cc3f957be2c50df8be9d602b5b2dc93728917e35d607492605d31d50ac8f2ef63884ef49819b564692fd9
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /lib/.DS_Store
16
+ *.swp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.ruby_version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ script:
5
+ bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # GemFile
2
+ source 'https://rubygems.org'
3
+ # Specify your gem's dependencies in yahoo_finanza.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,356 @@
1
+ # YahooFinanza
2
+ [![Build Status](https://travis-ci.org/cometaworks/yahoo_finanza.svg?branch=master)](https://travis-ci.org/cometaworks/yahoo_finanza)
3
+
4
+ This is a simple Yahoo Finance client. The client is capable of getting current data for several symbols in bulk as well as individually. It also has an historical data method which fetches historical data about a symbol. Additional features include getting stock symbols filtered by country and stock market.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'yahoo_finanza'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install yahoo_finanza
21
+
22
+ ## General Usage
23
+
24
+ All that is needed to use the gem is to require yahoo_finanza:
25
+
26
+ ```ruby
27
+ require 'yahoo_finanza'
28
+ ```
29
+
30
+ ## Client
31
+
32
+ To use the client class create an instance of it:
33
+
34
+ ```ruby
35
+ yahoo_finanza_client = YahooFinanza::Client.new
36
+ ```
37
+
38
+ To get the quotes of a list of symbols simply do:
39
+
40
+ ```ruby
41
+ quotes = yahoo_finanza_client.quotes(['JPM', 'YHOO', 'AAPL', 'GOOG', 'MSFT'])
42
+ ```
43
+
44
+ To access the quotes of a symbol, for example yahoo, do:
45
+
46
+ ```ruby
47
+ quote = quotes.select { |stock_quote| stock_quote == 'YHOO'}.first
48
+
49
+ # => returns an OpenStruct with the quotes for each symbol
50
+
51
+ quote.symbol
52
+
53
+ # => returns the symbol, in this case JPM
54
+ ```
55
+
56
+ To get the quote of a single of symbol do:
57
+
58
+ ```ruby
59
+ quote = yahoo_finanza_client.quote('JPM')
60
+
61
+ # => returns an OpenStruct with data
62
+
63
+ quote.symbol
64
+
65
+ # => returns the symbol, in this case JPM
66
+ ```
67
+
68
+ Use quote to access all the data available.
69
+
70
+ To get the historical quotes for a symbol, for example apple from 2009-03-10 to 2010-03-10, do:
71
+
72
+ ```ruby
73
+ historical_quotes = yahoo_finanza_client.quotes_history(
74
+ 'AAPL', '2009-03-10', '2010-03-10')
75
+
76
+ # => returns an array of OpenStructs with data about the symbol
77
+ ```
78
+
79
+ To access the first data entry of the historical quotes do:
80
+
81
+ ```ruby
82
+ historical_quotes.first
83
+
84
+ # => returns an OpenStruct with the data for the first entry
85
+
86
+ historical_quotes.first.symbol
87
+
88
+ # => returns the symbol. In this case APPL
89
+ ```
90
+ To search for symbols call the search_symbols method
91
+
92
+ ```ruby
93
+ yahoo_finanza_client.search_symbols('apple') => ["AAPL", "APLE", "AGPL", "GAPJ", "APRU", "APC.DE", "AGPLX", "APPLX", "APPIX", "ALE.V"]
94
+ ```
95
+
96
+ To get most active stocks quotes call popular_stock_quotes method
97
+
98
+ ```ruby
99
+ yahoo_finanza_client.popular_stock_quotes
100
+
101
+ # => returns an array of quotes (OpenStructs) of the 100 most active stocks
102
+ ```
103
+
104
+ This method returns an array of quotes (OpenStructs) of the 100 most active stocks in the market
105
+
106
+ ## Workers
107
+
108
+ You can access multiple workers to use as you like so:
109
+
110
+ ```ruby
111
+ YahooFinanza::WorkerName
112
+ ```
113
+ Where WorkerName could be any of the following:
114
+
115
+ - ActiveStockWorker
116
+ - SingleQuoteWorker
117
+ - MultiQuoteWorker
118
+ - HistoricQuoteWorker
119
+ - SymbolSearchWorker
120
+
121
+ ### Active Stock Worker
122
+
123
+ To use the active stock worker, create a new instance of the worker
124
+
125
+ ```ruby
126
+ worker = YahooFinanza::ActiveStockWorker.new()
127
+ ```
128
+
129
+ Then whenever it needs to fetch the most active stocks do:
130
+
131
+ ```ruby
132
+ worker.run
133
+ #=> returns an array of quotes(OpenStructs)
134
+ ```
135
+
136
+ ### Single Stock Worker
137
+
138
+ To use the single stock worker, create a new instance of the worker
139
+
140
+ ```ruby
141
+ worker = YahooFinanza::SingleQuoteWorker.new(symbol)
142
+ # symbol is any symbol from any stock you want
143
+
144
+ # Example:
145
+ worker = YahooFinanza::SingleQuoteWorker.new('AAPL')
146
+ ```
147
+ Then whenever it needs to fetch the quote for that symbol do:
148
+
149
+ ```ruby
150
+ worker.run
151
+ #=> returns a quote(OpenStruct) for the initialized symbol
152
+ ```
153
+
154
+ #### Multi Stock Worker
155
+
156
+ To use the single stock worker, create a new instance of the worker
157
+
158
+ ```ruby
159
+ worker = YahooFinanza::MultiQuoteWorker.new(symbols)
160
+ # symbols is a list of any symbols from any stocks you want
161
+
162
+ # Example:
163
+ worker = YahooFinanza::SingleQuoteWorker.new(['AAPL', 'FB', 'NFLX'])
164
+ ```
165
+ Then whenever it needs to fetch the quote for that symbol do:
166
+
167
+ ```ruby
168
+ worker.run
169
+ #=> returns an array of quotes(OpenStructs) for the initialized symbol list
170
+ ```
171
+
172
+ #### Historic Stock Worker
173
+
174
+ To use the single stock worker, create a new instance of the worker
175
+
176
+ ```ruby
177
+ worker = YahooFinanza::HistoricQuoteWorker.new(symbol, options)
178
+ # symbol is any symbol from any stock you want
179
+ # options is a hash like so: { start_date: 'YYYY-mm-dd', end_date: 'YYYY-mm-dd' }
180
+
181
+ # Example:
182
+ worker = YahooFinanza::HistoricQuoteWorker.new('AAPL', { start_date: '2009-01-10', end_date: '2009-01-15' })
183
+ ```
184
+ Then whenever it needs to fetch the quote for that symbol do:
185
+
186
+ ```ruby
187
+ worker.run
188
+ #=> returns an array of historic data (OpenStruct) for the initialized symbol and dates
189
+ ```
190
+
191
+ ### Symbol Search Worker
192
+
193
+ To use the active stock worker, create a new instance of the worker
194
+
195
+ ```ruby
196
+ worker = YahooFinanza::SymbolSearchWorker.new(key)
197
+ # Where key is the key you want to search for
198
+
199
+ # Example:
200
+ worker = YahooFinanza::SymbolSearchWorker.new('apple')
201
+ ```
202
+
203
+ Then whenever it needs to fetch the most active stocks do:
204
+
205
+ ```ruby
206
+ worker.run
207
+ #=> returns an array of symbols
208
+ ```
209
+
210
+ ## Constants
211
+
212
+ Constants can be used to get lists of symbols. The list of symbols include:
213
+
214
+ - NYSE Market Symbols
215
+ - NASDAQ Market Symbols
216
+ - AMEX Market Symbols
217
+ - S&P 500 Symbols
218
+
219
+ ### NYSE Market Symbol List:
220
+
221
+ To get the list of the NYSE Market use:
222
+
223
+ ```ruby
224
+ YahooFinanza::Constants.nyse
225
+ # => returns a list of nyse market symbols
226
+ ```
227
+
228
+ ### NASDAQ Market Symbol List:
229
+
230
+ To get the list of the NYSE Market use:
231
+
232
+ ```ruby
233
+ YahooFinanza::Constants.nasdaq
234
+ # => returns a list of nasdaq market symbols
235
+ ```
236
+
237
+ ### AMEX Market Symbol List:
238
+
239
+ To get the list of the AMEX Market use:
240
+
241
+ ```ruby
242
+ YahooFinanza::Constants.amex
243
+ # => returns a list of amex market symbols
244
+ ```
245
+
246
+ ### S&P 500 Symbol List:
247
+
248
+ To get the list of the S&P 500 Symbols use:
249
+
250
+ ```ruby
251
+ YahooFinanza::Constants.sp_500
252
+ # => returns a list of s&p 500 symbols
253
+ ```
254
+
255
+ All of these lists can be sent to the client method quotes or be used in the Multi Quote Worker
256
+
257
+ ## Available Properties for OpenStructs
258
+
259
+ - :symbol
260
+ - :ask
261
+ - :average_daily_volume
262
+ - :bid
263
+ - :ask_realtime
264
+ - :bid_realtime
265
+ - :book_value
266
+ - :change_percent_change
267
+ - :change
268
+ - :commission
269
+ - :currency
270
+ - :change_realtime
271
+ - :after_hours_change_realtime
272
+ - :dividend_share
273
+ - :last_trade_date
274
+ - :trade_date
275
+ - :earnings_share
276
+ - :error_indicationreturnedforsymbolchangedinvalid
277
+ - :eps_estimate_current_year
278
+ - :eps_estimate_next_year
279
+ - :eps_estimate_next_quarter
280
+ - :days_low
281
+ - :days_high
282
+ - :year_low
283
+ - :year_high
284
+ - :holdings_gain_percent
285
+ - :annualized_gain
286
+ - :holdings_gain
287
+ - :holdings_gain_percent_realtime
288
+ - :holdings_gain_realtime
289
+ - :more_info
290
+ - :order_book_realtime
291
+ - :market_capitalization
292
+ - :market_cap_realtime
293
+ - :ebitda
294
+ - :change_from_year_low
295
+ - :percent_change_from_year_low
296
+ - :last_trade_realtime_with_time
297
+ - :change_percent_realtime
298
+ - :change_from_year_high
299
+ - :percebt_change_from_year_high
300
+ - :last_trade_with_time
301
+ - :last_trade_price_only
302
+ - :high_limit
303
+ - :low_limit
304
+ - :days_range
305
+ - :days_range_realtime
306
+ - :fiftyday_moving_average
307
+ - :two_hundredday_moving_average
308
+ - :change_from_two_hundredday_moving_average
309
+ - :percent_change_from_two_hundredday_moving_average
310
+ - :change_from_fiftyday_moving_average
311
+ - :percent_change_from_fiftyday_moving_average
312
+ - :name
313
+ - :notes
314
+ - :open
315
+ - :previous_close
316
+ - :price_paid
317
+ - :changein_percent
318
+ - :price_sales
319
+ - :price_book
320
+ - :ex_dividend_date
321
+ - :pe_ratio
322
+ - :dividend_pay_date
323
+ - :pe_ratio_realtime
324
+ - :peg_ratio
325
+ - :price_eps_estimate_current_year
326
+ - :price_eps_estimate_next_year
327
+ - :shares_owned
328
+ - :short_ratio
329
+ - :last_trade_time
330
+ - :ticker_trend
331
+ - :oneyr_target_price
332
+ - :volume
333
+ - :holdings_value
334
+ - :holdings_value_realtime
335
+ - :year_range
336
+ - :days_value_change
337
+ - :days_value_change_realtime
338
+ - :stock_exchange
339
+ - :dividend_yield
340
+ - :percent_change
341
+
342
+
343
+ ## Contributing
344
+
345
+ 1. Fork it ( https://github.com/[my-github-username]/yahoo_finanza/fork )
346
+ 2. Create your feature branch (`git checkout -b feature/my_new_feature`)
347
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
348
+ 4. Push to the branch (`git push origin my-new-feature`)
349
+ 5. Create a new Pull Request
350
+
351
+ ## Special Thanks To:
352
+
353
+ 1. Jonah Ruiz (jonahoffline)
354
+ 2. Robert Grayson (ybur-yug)
355
+ 3. Herval Freire (Who inspired me to implement this gem)
356
+ 4. Nasir Jamal (Thanks for the YQL gem)
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'bundler/gem_tasks'
4
+
5
+ # Default directory to look in is `/specs`
6
+ # Run with `rake spec`
7
+ RSpec::Core::RakeTask.new(:spec) do |task|
8
+ task.rspec_opts = ['--color', '--format', 'nested']
9
+ end
10
+
11
+ task default: :spec