market_data 0.1.0 → 0.1.2
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/CHANGELOG.md +10 -0
- data/lib/market_data/errors.rb +3 -0
- data/lib/market_data/quotes.rb +9 -7
- data/lib/market_data/version.rb +1 -1
- data/lib/market_data.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02bae11e4d0ffd6cbc6c1e9211188bf980c54f59c61cb36d9d32628975ace153
|
4
|
+
data.tar.gz: 661a761e828644036057ec05d6711ddeb1462e9885de3baf8319b4e483ea8333
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48056be17c0be8068325457f25e64d4a38e38d9b3573cf707960348d5ebc53597ea6beb96edf5a7f96da593d8480539cae01d4852a2b1ee658cb6f29665562ab
|
7
|
+
data.tar.gz: e7277b27c830b40a5e3de5fbbd83d53b69ab02e463b42e00ba2a72eb82265b1e972a42656a264e448e18387442cd81989f0cb047cdf093f11322281722bacd27
|
data/CHANGELOG.md
CHANGED
@@ -3,3 +3,13 @@
|
|
3
3
|
## [0.1.0] - 2024-09-11
|
4
4
|
|
5
5
|
- Initial release
|
6
|
+
|
7
|
+
## [0.1.1] - 2024-09-12
|
8
|
+
|
9
|
+
- Fix handling of snapshot parameter in bulk quotes method
|
10
|
+
- Rename fetch method to quote on Quote submodule. Quotes methods are no longer wrapped in parent module.
|
11
|
+
|
12
|
+
## [0.1.2] - 2024-09-24
|
13
|
+
|
14
|
+
- Change validations for bulk_quotes method
|
15
|
+
- Add `token` method to `Client` class
|
data/lib/market_data/errors.rb
CHANGED
@@ -2,6 +2,7 @@ module MarketData
|
|
2
2
|
|
3
3
|
class ClientError < StandardError;end
|
4
4
|
class UnauthorizedError < ClientError; end
|
5
|
+
class RateLimitedError < ClientError; end
|
5
6
|
class BadParameterError < ClientError; end
|
6
7
|
|
7
8
|
module Errors
|
@@ -10,6 +11,8 @@ module MarketData
|
|
10
11
|
case er.status[0]
|
11
12
|
when "401"
|
12
13
|
raise UnauthorizedError
|
14
|
+
when "429"
|
15
|
+
raise RateLimitedError
|
13
16
|
else
|
14
17
|
raise e
|
15
18
|
end
|
data/lib/market_data/quotes.rb
CHANGED
@@ -20,7 +20,7 @@ module MarketData
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def quote(symbol, w52 = false)
|
24
24
|
path_hash = { host: MarketData.base_host, path: @@single + symbol }
|
25
25
|
if w52
|
26
26
|
path_hash[:query] = URI.encode_www_form({"52week" => true })
|
@@ -30,15 +30,18 @@ module MarketData
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def bulk_quotes(symbols, snapshot = false)
|
33
|
-
unless symbols.is_a?(Array) && symbols.size > 1
|
34
|
-
raise BadParameterError.new("symbols must be a non-empty list")
|
35
|
-
end
|
36
|
-
|
37
33
|
path_hash = { host: MarketData.base_host, path: @@bulk }
|
38
|
-
query_hash = {
|
34
|
+
query_hash = {}
|
35
|
+
|
39
36
|
if snapshot
|
40
37
|
query_hash[:snapshot] = true
|
38
|
+
else
|
39
|
+
if not symbols.is_a?(Array) || symbols.size < 1
|
40
|
+
raise BadParameterError.new("symbols must be a non-empty list")
|
41
|
+
end
|
42
|
+
query_hash = { symbols: symbols.join(",") }
|
41
43
|
end
|
44
|
+
|
42
45
|
path_hash[:query] = URI.encode_www_form(query_hash)
|
43
46
|
|
44
47
|
res = do_connect(get_uri path_hash)
|
@@ -48,7 +51,6 @@ module MarketData
|
|
48
51
|
def self.map_quotes(quotes)
|
49
52
|
h = Hash.new
|
50
53
|
size = quotes[SYMBOL_RESPONSE_KEY].size
|
51
|
-
p size
|
52
54
|
for i in 0..(size - 1) do
|
53
55
|
qquote = Quote.new(*quotes.except(STATUS_RESPONSE_KEY).values.map { |ar| ar[i] })
|
54
56
|
h[quotes[SYMBOL_RESPONSE_KEY][i]] = !qquote.blank? ? qquote : nil
|
data/lib/market_data/version.rb
CHANGED
data/lib/market_data.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: market_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastián González
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby client for the MarketData API.
|
14
14
|
email:
|