yafa 0.1.0 → 1.0.0

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: 2faaa4583f9ed8fb64fab2398144100d48095b99
4
- data.tar.gz: bd026569282943484bca5e4f11978d3ffd47de28
3
+ metadata.gz: 7ecc1c4be19bdfea084ad10a25841b2a9e63a4b1
4
+ data.tar.gz: b57af1fe5ef71e6464d505595a96a122a70a1c8b
5
5
  SHA512:
6
- metadata.gz: c16dbb6c15af16d38f506f2244f7a922c7572568c70d251fd2c190b916f5a5fe8f603eb8e2a6968e3948467e0b085270ea7648f3e71909bd7196f72cafb9e298
7
- data.tar.gz: e303aed5f6b3bfa30b93eb19d1219514182da62340047106264c21c4384ea118e17398e9ab637adbea4282547337b5b6638ac8f6af6e8bb0385d385313c3640b
6
+ metadata.gz: d2419a7e974d3bae2920c3cff3b4b867dac971ac08ec6f98d20d698a6aea0045a0fca42d6767cda0a3954bad39a8e70c0ef312f1d17c80155151f927173f8f54
7
+ data.tar.gz: af40620f83b3264368881200e65fada01a728365f6f658c6e3907a43ab0e497592f5bd4c614f0677ec33242f686593431bb1b9a33df3f8dd982e270a4c07d309
data/README.md CHANGED
@@ -1,41 +1,49 @@
1
- # YFAPI
1
+ # Yafa
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/YFAPI`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ **Ya**hoo **F**inance **A**PI wrapper, fetch stock quotes and stock
4
+ chart data
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ ### Setup
6
7
 
7
- ## Installation
8
+ Just install yafa or add it to your gemfile `gem 'yafa'`
8
9
 
9
- Add this line to your application's Gemfile:
10
+ ### Usage
11
+ #### Quotes data
12
+
13
+ Fetches the current/most recent stock quote:
10
14
 
11
15
  ```ruby
12
- gem 'YFAPI'
16
+ tickers = ['GOOG']
17
+ fetcher = StockQuotes.new(tickers)
18
+ quotes = fetcher.fetch
13
19
  ```
14
20
 
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install YFAPI
22
-
23
- ## Usage
21
+ Tickers array takes up to 400 tickers at once
24
22
 
25
- TODO: Write usage instructions here
23
+ #### Chart data
26
24
 
27
- ## Development
25
+ Fetches per-minute quotes for the last day, good for making charts of
26
+ recent stock prices
28
27
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
28
+ ```ruby
29
+ ticker = 'GOOG'
30
+ fetcher = StockChart.new(ticker)
31
+ chart_data = fetcher.fetch
32
+ ```
34
33
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/YFAPI. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+ Fetches for a single ticker per request
36
35
 
36
+ #### Historical Data
37
37
 
38
- ## License
38
+ Coming soon...
39
39
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+ ### Worth knowing
41
+ * Yahoo Finance API sometimes goes down, so handle failed requests
42
+ * Stay under your Yahoo API request limit, something like 20k/day
43
+ (based on IP address making the request)
41
44
 
45
+ ### Improvements
46
+ * Historical data api
47
+ * Config for fetcher (i.e. timeouts, query params)
48
+ * Option to replace Yahoo time and key formatting with a consistent
49
+ format
@@ -8,17 +8,17 @@ module Yafa
8
8
  READ_TIMEOUT = 5
9
9
  DATA_SOURCE = 'yahoo_chart_api'.freeze
10
10
 
11
- def call(ticker)
12
- get_bars_data(ticker)
11
+ def initialize(ticker)
12
+ @ticker = ticker
13
13
  end
14
14
 
15
- private
16
-
17
- def get_bars_data(ticker)
18
- quote_data = call_api ticker
15
+ def fetch
16
+ quote_data = call_api @ticker
19
17
  parse_quote quote_data
20
18
  end
21
19
 
20
+ private
21
+
22
22
  def call_api(ticker)
23
23
  url = format_api_url ticker
24
24
  response = perform_api_request url
@@ -13,19 +13,19 @@ module Yafa
13
13
  YAHOO_API_END = '&format=json&diagnostics=true&env=store%3A%2F%2Fdatata'\
14
14
  'bles.org%2Falltableswithkeys&callback='.freeze
15
15
 
16
- def call(tickers)
17
- fetch_quotes_from_api tickers
16
+ def initialize(tickers)
17
+ @tickers = tickers
18
18
  end
19
19
 
20
- private
21
-
22
- def fetch_quotes_from_api(tickers)
23
- formatted_tickers = format_tickers tickers
20
+ def fetch
21
+ formatted_tickers = format_tickers @tickers
24
22
  quote_data = call_api(formatted_tickers)
25
23
 
26
24
  format_quote_data(quote_data)
27
25
  end
28
26
 
27
+ private
28
+
29
29
  def call_api(yahoo_tickers)
30
30
  url = format_api_url yahoo_tickers
31
31
  response = open(
data/lib/yafa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yafa
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
data/yafa.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = 'yahoo finance api'
13
13
  spec.description = 'wrapper for yahoo finance stock quotes and chart data'
14
- spec.homepage = ''
14
+ spec.homepage = 'https://github.com/KlotzAndrew/yafa'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yafa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Klotz
@@ -90,7 +90,7 @@ files:
90
90
  - lib/yafa/stock_quotes.rb
91
91
  - lib/yafa/version.rb
92
92
  - yafa.gemspec
93
- homepage: ''
93
+ homepage: https://github.com/KlotzAndrew/yafa
94
94
  licenses:
95
95
  - MIT
96
96
  metadata: {}