yafa 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +33 -25
- data/lib/yafa/stock_chart.rb +6 -6
- data/lib/yafa/stock_quotes.rb +6 -6
- data/lib/yafa/version.rb +1 -1
- data/yafa.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ecc1c4be19bdfea084ad10a25841b2a9e63a4b1
|
4
|
+
data.tar.gz: b57af1fe5ef71e6464d505595a96a122a70a1c8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2419a7e974d3bae2920c3cff3b4b867dac971ac08ec6f98d20d698a6aea0045a0fca42d6767cda0a3954bad39a8e70c0ef312f1d17c80155151f927173f8f54
|
7
|
+
data.tar.gz: af40620f83b3264368881200e65fada01a728365f6f658c6e3907a43ab0e497592f5bd4c614f0677ec33242f686593431bb1b9a33df3f8dd982e270a4c07d309
|
data/README.md
CHANGED
@@ -1,41 +1,49 @@
|
|
1
|
-
#
|
1
|
+
# Yafa
|
2
2
|
|
3
|
-
|
3
|
+
**Ya**hoo **F**inance **A**PI wrapper, fetch stock quotes and stock
|
4
|
+
chart data
|
4
5
|
|
5
|
-
|
6
|
+
### Setup
|
6
7
|
|
7
|
-
|
8
|
+
Just install yafa or add it to your gemfile `gem 'yafa'`
|
8
9
|
|
9
|
-
|
10
|
+
### Usage
|
11
|
+
#### Quotes data
|
12
|
+
|
13
|
+
Fetches the current/most recent stock quote:
|
10
14
|
|
11
15
|
```ruby
|
12
|
-
|
16
|
+
tickers = ['GOOG']
|
17
|
+
fetcher = StockQuotes.new(tickers)
|
18
|
+
quotes = fetcher.fetch
|
13
19
|
```
|
14
20
|
|
15
|
-
|
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
|
-
|
23
|
+
#### Chart data
|
26
24
|
|
27
|
-
|
25
|
+
Fetches per-minute quotes for the last day, good for making charts of
|
26
|
+
recent stock prices
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
```ruby
|
29
|
+
ticker = 'GOOG'
|
30
|
+
fetcher = StockChart.new(ticker)
|
31
|
+
chart_data = fetcher.fetch
|
32
|
+
```
|
34
33
|
|
35
|
-
|
34
|
+
Fetches for a single ticker per request
|
36
35
|
|
36
|
+
#### Historical Data
|
37
37
|
|
38
|
-
|
38
|
+
Coming soon...
|
39
39
|
|
40
|
-
|
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
|
data/lib/yafa/stock_chart.rb
CHANGED
@@ -8,17 +8,17 @@ module Yafa
|
|
8
8
|
READ_TIMEOUT = 5
|
9
9
|
DATA_SOURCE = 'yahoo_chart_api'.freeze
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def initialize(ticker)
|
12
|
+
@ticker = ticker
|
13
13
|
end
|
14
14
|
|
15
|
-
|
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
|
data/lib/yafa/stock_quotes.rb
CHANGED
@@ -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
|
17
|
-
|
16
|
+
def initialize(tickers)
|
17
|
+
@tickers = tickers
|
18
18
|
end
|
19
19
|
|
20
|
-
|
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
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:
|
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: {}
|