yfinance 1.0.11 → 1.0.12
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/lib/yfinance.rb +19 -0
- data/test/yfinance_test.rb +18 -1
- data/yfinance.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: 7ac37be4f80052239b7f94fbec8d7fd92448c17a
|
|
4
|
+
data.tar.gz: 4fcb0a16a81cef7025271542655c75419a10b63a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5071c8726d577c7f78778069527f3926fc0322b6a4e0b2b73aecc49807c8a2e4b9840a0db9f336add9ff625d0610285c1313a2ed99a81825552f648564e87e76
|
|
7
|
+
data.tar.gz: cd44fbb500ee5455487f33885ff934e9d9b1c53d05223089279b344ba8f5dad667159e5c1e2b8d5d286b980eaa930ef758a8d4987808b9adfd7754e26e9e1906
|
data/lib/yfinance.rb
CHANGED
|
@@ -135,6 +135,25 @@ class Yfinance
|
|
|
135
135
|
end
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
+
# returns daily historical data in one hash
|
|
139
|
+
def daily_historical_data(symbols_array, start_date, end_date)
|
|
140
|
+
result = {}
|
|
141
|
+
callb = Proc.new do |resp|
|
|
142
|
+
result.merge!(resp)
|
|
143
|
+
if result.length == symbols_array.length
|
|
144
|
+
return result
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
add_historical_data_query(symbols_array, start_date, end_date, {period: :daily}, &callb)
|
|
148
|
+
run
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# for each symbol, the callback is executed
|
|
152
|
+
def daily_historical_data_callback(symbols_array, start_date, end_date, &callback)
|
|
153
|
+
add_historical_data_query(symbols_array, start_date, end_date, {period: :daily}, &callback)
|
|
154
|
+
run
|
|
155
|
+
end
|
|
156
|
+
|
|
138
157
|
def read_symbols(query, &callback)
|
|
139
158
|
url = "http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=#{query}&callback=YAHOO.Finance.SymbolSuggest.ssCallback"
|
|
140
159
|
request = Typhoeus::Request.new(url, method: :get)
|
data/test/yfinance_test.rb
CHANGED
|
@@ -47,11 +47,28 @@ class YfinanceTest < Minitest::Test
|
|
|
47
47
|
assert_nil res["BCXZA"]
|
|
48
48
|
end
|
|
49
49
|
#
|
|
50
|
-
def
|
|
50
|
+
def test_historical_data_works_for_one_symbol
|
|
51
51
|
yf = Yfinance.new
|
|
52
52
|
res = Proc.new { |resp| assert resp["MSFT"].kind_of?(Array)}
|
|
53
53
|
yf.add_historical_data_query(['MSFT'], '2013-01-01', Date.today, {period: :daily}, &res)
|
|
54
54
|
yf.run
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
def test_daily_historical_data_is_returned_as_one_hash_for_multiple_symbols
|
|
58
|
+
yf = Yfinance.new
|
|
59
|
+
symbols = ["MSFT", "TEP.L", "TWTR"]
|
|
60
|
+
result = yf.daily_historical_data(symbols, Date.today - 7, Date.today)
|
|
61
|
+
assert_equal symbols.length, result.length
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_daily_historical_data_is_returned_via_callbacks_for_multiple_valid_symbols
|
|
65
|
+
yf = Yfinance.new
|
|
66
|
+
symbols = ["MSFT", "TEP.L", "TWTR"]
|
|
67
|
+
h = Hash.new
|
|
68
|
+
res = Proc.new do |resp|
|
|
69
|
+
assert true
|
|
70
|
+
end
|
|
71
|
+
yf.daily_historical_data_callback(symbols, Date.today - 7, Date.today, &res)
|
|
72
|
+
end
|
|
73
|
+
|
|
57
74
|
end
|
data/yfinance.gemspec
CHANGED
|
@@ -5,7 +5,7 @@ require 'yfinance'
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "yfinance"
|
|
8
|
-
spec.version = "1.0.
|
|
8
|
+
spec.version = "1.0.12"
|
|
9
9
|
spec.authors = ["Alexander Potrykus"]
|
|
10
10
|
spec.email = ["alexander@risklog.io"]
|
|
11
11
|
spec.summary = %q{Fetches Yahoo! Finance data using parallel HTTP requests.}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yfinance
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Potrykus
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-10-
|
|
11
|
+
date: 2014-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|