twelvedata_ruby 0.1.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -2
- data/Gemfile.lock +17 -17
- data/README.md +33 -2
- data/doc/TwelvedataRuby.html +2 -2
- data/doc/TwelvedataRuby/BadRequestResponseError.html +1 -1
- data/doc/TwelvedataRuby/Client.html +1 -1
- data/doc/TwelvedataRuby/Endpoint.html +1 -1
- data/doc/TwelvedataRuby/EndpointError.html +1 -1
- data/doc/TwelvedataRuby/EndpointNameError.html +1 -1
- data/doc/TwelvedataRuby/EndpointParametersKeysError.html +1 -1
- data/doc/TwelvedataRuby/EndpointRequiredParametersError.html +1 -1
- data/doc/TwelvedataRuby/Error.html +1 -1
- data/doc/TwelvedataRuby/ForbiddenResponseError.html +1 -1
- data/doc/TwelvedataRuby/InternalServerResponseErro.html +1 -1
- data/doc/TwelvedataRuby/NotFoundResponseError.html +1 -1
- data/doc/TwelvedataRuby/PageNotFoundResponseError.html +1 -1
- data/doc/TwelvedataRuby/ParameterTooLongResponseError.html +1 -1
- data/doc/TwelvedataRuby/Request.html +1 -1
- data/doc/TwelvedataRuby/Response.html +1 -1
- data/doc/TwelvedataRuby/ResponseError.html +1 -1
- data/doc/TwelvedataRuby/TooManyRequestsResponseError.html +1 -1
- data/doc/TwelvedataRuby/UnauthorizedResponseError.html +1 -1
- data/doc/TwelvedataRuby/Utils.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +32 -3
- data/doc/index.html +32 -3
- data/doc/top-level-namespace.html +1 -1
- data/lib/twelvedata_ruby.rb +2 -2
- data/lib/twelvedata_ruby/endpoint.rb +18 -4
- data/lib/twelvedata_ruby/error.rb +2 -2
- data/lib/twelvedata_ruby/response.rb +41 -17
- data/twelvedata_ruby.gemspec +5 -5
- metadata +25 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7d5d01f41fde75fae4a61796b121816c87d6d95afc4ea3126e3044b46648eb3
|
4
|
+
data.tar.gz: 04cdeaf1de8e47c3728bcefdade8b18544869dbc8b4b6af8b01354ffd3e50f73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6353eaab3d7e93d532d25990c32014c3c324ae02bff155500e05135a07f96f592cfdaf2927566b088c95d5ef7aba31ef4b87c6d5dfe1f8fa1a808d37a3c40d95
|
7
|
+
data.tar.gz: 8566bd2833987cbff4f792a0b28403e7a1a3b1d963a723de6ab2b76370548f4ee6441e943d4acb299bfe1d28c3004de52e60b4ccaa032bc6f2f66f3f980dabb0
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
twelvedata_ruby (0.
|
5
|
-
httpx (~> 0.14.5)
|
4
|
+
twelvedata_ruby (0.3.0)
|
5
|
+
httpx (~> 0.14, >= 0.14.5)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.
|
10
|
+
addressable (2.8.0)
|
11
11
|
public_suffix (>= 2.0.2, < 5.0)
|
12
12
|
ast (2.4.2)
|
13
13
|
crack (0.4.5)
|
@@ -15,16 +15,16 @@ GEM
|
|
15
15
|
diff-lcs (1.4.4)
|
16
16
|
docile (1.4.0)
|
17
17
|
hashdiff (1.0.1)
|
18
|
-
http-2-next (0.
|
19
|
-
httpx (0.
|
18
|
+
http-2-next (0.5.0)
|
19
|
+
httpx (0.16.1)
|
20
20
|
http-2-next (>= 0.4.1)
|
21
21
|
timers
|
22
22
|
parallel (1.20.1)
|
23
|
-
parser (3.0.
|
23
|
+
parser (3.0.2.0)
|
24
24
|
ast (~> 2.4.1)
|
25
25
|
public_suffix (4.0.6)
|
26
26
|
rainbow (3.0.0)
|
27
|
-
rake (13.0.
|
27
|
+
rake (13.0.6)
|
28
28
|
regexp_parser (2.1.1)
|
29
29
|
rexml (3.2.5)
|
30
30
|
rspec (3.10.0)
|
@@ -40,16 +40,16 @@ GEM
|
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
41
|
rspec-support (~> 3.10.0)
|
42
42
|
rspec-support (3.10.2)
|
43
|
-
rubocop (1.
|
43
|
+
rubocop (1.18.4)
|
44
44
|
parallel (~> 1.10)
|
45
45
|
parser (>= 3.0.0.0)
|
46
46
|
rainbow (>= 2.2.2, < 4.0)
|
47
47
|
regexp_parser (>= 1.8, < 3.0)
|
48
48
|
rexml
|
49
|
-
rubocop-ast (>= 1.
|
49
|
+
rubocop-ast (>= 1.8.0, < 2.0)
|
50
50
|
ruby-progressbar (~> 1.7)
|
51
51
|
unicode-display_width (>= 1.4.0, < 3.0)
|
52
|
-
rubocop-ast (1.
|
52
|
+
rubocop-ast (1.9.0)
|
53
53
|
parser (>= 3.0.1.1)
|
54
54
|
ruby-progressbar (1.11.0)
|
55
55
|
simplecov (0.21.2)
|
@@ -60,21 +60,21 @@ GEM
|
|
60
60
|
simplecov_json_formatter (0.1.3)
|
61
61
|
timers (4.3.3)
|
62
62
|
unicode-display_width (2.0.0)
|
63
|
-
webmock (3.
|
64
|
-
addressable (>= 2.
|
63
|
+
webmock (3.14.0)
|
64
|
+
addressable (>= 2.8.0)
|
65
65
|
crack (>= 0.3.2)
|
66
66
|
hashdiff (>= 0.4.0, < 2.0.0)
|
67
67
|
|
68
68
|
PLATFORMS
|
69
|
-
x86_64-darwin-
|
69
|
+
x86_64-darwin-20
|
70
70
|
|
71
71
|
DEPENDENCIES
|
72
|
-
rake (~> 13.0, >= 13.0.
|
73
|
-
rspec (~> 3.10.0)
|
74
|
-
rubocop (~> 1.17.0)
|
72
|
+
rake (~> 13.0, >= 13.0.0)
|
73
|
+
rspec (~> 3.10, >= 3.10.0)
|
74
|
+
rubocop (~> 1.17, >= 1.17.0)
|
75
75
|
simplecov (~> 0.21, >= 0.21.2)
|
76
76
|
twelvedata_ruby!
|
77
77
|
webmock (~> 3.13, >= 3.13.0)
|
78
78
|
|
79
79
|
BUNDLED WITH
|
80
|
-
2.2.
|
80
|
+
2.2.25
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# TwelvedataRuby
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/twelvedata_ruby.svg)](https://badge.fury.io/rb/twelvedata_ruby)
|
4
|
+
|
5
|
+
TwelvedataRuby is a Ruby library that exposes some convenient ways to access Twelve Data API to get information on stock, forex, crypto, and other financial market data. In order to do so, a free API key is required which can be easily requested [here](https://twelvedata.com/pricing). Visit their [API's full documentation](https://twelvedata.com/docs)
|
3
6
|
|
4
|
-
TwelvedataRuby is a Ruby library that exposes some convenient ways to access Twelve Data API to get information on stock, forex, crypto, and other financial market data. In order to do so, a free API key is required which can be easily requested [here](https://twelvedata.com/pricing). Visit their [API's full documentation](https://twelvedata.com/doc)
|
5
7
|
|
6
8
|
## Installation
|
7
9
|
|
@@ -105,8 +107,37 @@ resp_objects_array = TwelvedataRuby::Client.request(quote_req, timeseries_req, e
|
|
105
107
|
Be caution that the above example, depending on the number request objects sent and how large the responses, hitting the daily limit is likely possible. But then again if you have several api keys you might be able to supply each request object with its own apikey. :)
|
106
108
|
|
107
109
|
|
108
|
-
|
110
|
+
The data from a successful API request can be access from `Response#parsed_body`. If request format is `:json` then it will be a `Hash` instance
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
TwelvedataRuby.client.quote(symbol: "GOOG").parsed_body
|
114
|
+
=>
|
115
|
+
{:symbol=>"GOOG",
|
116
|
+
:name=>"Alphabet Inc",
|
117
|
+
:exchange=>"NASDAQ",
|
118
|
+
:currency=>"USD",
|
119
|
+
:datetime=>"2021-07-15",
|
120
|
+
:open=>"2650.00000",
|
121
|
+
:high=>"2651.89990",
|
122
|
+
:low=>"2611.95996",
|
123
|
+
:close=>"2625.33008",
|
124
|
+
:volume=>"828300",
|
125
|
+
:previous_close=>"2641.64990",
|
126
|
+
:change=>"-16.31982",
|
127
|
+
:percent_change=>"-0.61779",
|
128
|
+
:average_volume=>"850344",
|
129
|
+
:fifty_two_week=>{:low=>"1406.55005", :high=>"2659.91992", :low_change=>"1218.78003", :high_change=>"-34.58984", :low_change_percent=>"86.65031", :high_change_percent=>"-1.30041", :range=>"1406.550049 - 2659.919922"}}
|
130
|
+
```
|
131
|
+
|
132
|
+
Likewise, if the API request format is `:csv` then `Response#parsed_body` will be `CSV#Table` instance
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
TwelvedataRuby.client.quote(symbol: "GOOG", format: :csv).parsed_body
|
136
|
+
=> #<CSV::Table mode:col_or_row row_count:2>
|
137
|
+
```
|
109
138
|
|
139
|
+
## Documentation
|
140
|
+
You can browse the source code [documentation](https://kanroyalhigh.github.io/twelvedata_ruby/doc/)
|
110
141
|
## Contributing
|
111
142
|
|
112
143
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/twelvedata_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/twelvedata_ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/doc/TwelvedataRuby.html
CHANGED
@@ -149,7 +149,7 @@
|
|
149
149
|
|
150
150
|
</div>
|
151
151
|
</dt>
|
152
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.1.
|
152
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.1.1</span><span class='tstring_end'>"</span></span></pre></dd>
|
153
153
|
|
154
154
|
</dl>
|
155
155
|
|
@@ -343,7 +343,7 @@
|
|
343
343
|
</div>
|
344
344
|
|
345
345
|
<div id="footer">
|
346
|
-
Generated on
|
346
|
+
Generated on Fri Jul 16 20:51:23 2021 by
|
347
347
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
348
348
|
0.9.26 (ruby-3.0.1).
|
349
349
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -1433,7 +1433,7 @@
|
|
1433
1433
|
</div>
|
1434
1434
|
|
1435
1435
|
<div id="footer">
|
1436
|
-
Generated on
|
1436
|
+
Generated on Fri Jul 16 20:51:25 2021 by
|
1437
1437
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1438
1438
|
0.9.26 (ruby-3.0.1).
|
1439
1439
|
</div>
|
@@ -1468,7 +1468,7 @@
|
|
1468
1468
|
</div>
|
1469
1469
|
|
1470
1470
|
<div id="footer">
|
1471
|
-
Generated on
|
1471
|
+
Generated on Fri Jul 16 20:51:25 2021 by
|
1472
1472
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1473
1473
|
0.9.26 (ruby-3.0.1).
|
1474
1474
|
</div>
|
@@ -237,7 +237,7 @@
|
|
237
237
|
</div>
|
238
238
|
|
239
239
|
<div id="footer">
|
240
|
-
Generated on
|
240
|
+
Generated on Fri Jul 16 20:51:23 2021 by
|
241
241
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
242
242
|
0.9.26 (ruby-3.0.1).
|
243
243
|
</div>
|
@@ -157,7 +157,7 @@
|
|
157
157
|
</div>
|
158
158
|
|
159
159
|
<div id="footer">
|
160
|
-
Generated on
|
160
|
+
Generated on Fri Jul 16 20:51:23 2021 by
|
161
161
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
162
162
|
0.9.26 (ruby-3.0.1).
|
163
163
|
</div>
|
@@ -157,7 +157,7 @@
|
|
157
157
|
</div>
|
158
158
|
|
159
159
|
<div id="footer">
|
160
|
-
Generated on
|
160
|
+
Generated on Fri Jul 16 20:51:23 2021 by
|
161
161
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
162
162
|
0.9.26 (ruby-3.0.1).
|
163
163
|
</div>
|
@@ -157,7 +157,7 @@
|
|
157
157
|
</div>
|
158
158
|
|
159
159
|
<div id="footer">
|
160
|
-
Generated on
|
160
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
161
161
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
162
162
|
0.9.26 (ruby-3.0.1).
|
163
163
|
</div>
|
@@ -308,7 +308,7 @@
|
|
308
308
|
</div>
|
309
309
|
|
310
310
|
<div id="footer">
|
311
|
-
Generated on
|
311
|
+
Generated on Fri Jul 16 20:51:23 2021 by
|
312
312
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
313
313
|
0.9.26 (ruby-3.0.1).
|
314
314
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -673,7 +673,7 @@
|
|
673
673
|
</div>
|
674
674
|
|
675
675
|
<div id="footer">
|
676
|
-
Generated on
|
676
|
+
Generated on Fri Jul 16 20:51:25 2021 by
|
677
677
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
678
678
|
0.9.26 (ruby-3.0.1).
|
679
679
|
</div>
|
@@ -1612,7 +1612,7 @@
|
|
1612
1612
|
</div>
|
1613
1613
|
|
1614
1614
|
<div id="footer">
|
1615
|
-
Generated on
|
1615
|
+
Generated on Fri Jul 16 20:51:26 2021 by
|
1616
1616
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1617
1617
|
0.9.26 (ruby-3.0.1).
|
1618
1618
|
</div>
|
@@ -555,7 +555,7 @@
|
|
555
555
|
</div>
|
556
556
|
|
557
557
|
<div id="footer">
|
558
|
-
Generated on
|
558
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
559
559
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
560
560
|
0.9.26 (ruby-3.0.1).
|
561
561
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Fri Jul 16 20:51:24 2021 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.9.26 (ruby-3.0.1).
|
174
174
|
</div>
|
@@ -493,7 +493,7 @@
|
|
493
493
|
</div>
|
494
494
|
|
495
495
|
<div id="footer">
|
496
|
-
Generated on
|
496
|
+
Generated on Fri Jul 16 20:51:23 2021 by
|
497
497
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
498
498
|
0.9.26 (ruby-3.0.1).
|
499
499
|
</div>
|
data/doc/_index.html
CHANGED
@@ -305,7 +305,7 @@
|
|
305
305
|
</div>
|
306
306
|
|
307
307
|
<div id="footer">
|
308
|
-
Generated on
|
308
|
+
Generated on Fri Jul 16 20:51:22 2021 by
|
309
309
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
310
310
|
0.9.26 (ruby-3.0.1).
|
311
311
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -164,9 +164,38 @@ resp_objects_array = TwelvedataRuby::Client.request(quote_req, timeseries_req, e
|
|
164
164
|
|
165
165
|
<p>Be caution that the above example, depending on the number request objects sent and how large the responses, hitting the daily limit is likely possible. But then again if you have several api keys you might be able to supply each request object with its own apikey. :)</p>
|
166
166
|
|
167
|
-
<p>
|
167
|
+
<p>The data from a successful API request can be access from <code>Response#parsed_body</code>. If request format is <code>:json</code> then it will be a <code>Hash</code> instance</p>
|
168
168
|
|
169
|
-
<
|
169
|
+
<p><code>ruby
|
170
|
+
TwelvedataRuby.client.quote(symbol: "GOOG").parsed_body
|
171
|
+
=>
|
172
|
+
{:symbol=>"GOOG",
|
173
|
+
:name=>"Alphabet Inc",
|
174
|
+
:exchange=>"NASDAQ",
|
175
|
+
:currency=>"USD",
|
176
|
+
:datetime=>"2021-07-15",
|
177
|
+
:open=>"2650.00000",
|
178
|
+
:high=>"2651.89990",
|
179
|
+
:low=>"2611.95996",
|
180
|
+
:close=>"2625.33008",
|
181
|
+
:volume=>"828300",
|
182
|
+
:previous_close=>"2641.64990",
|
183
|
+
:change=>"-16.31982",
|
184
|
+
:percent_change=>"-0.61779",
|
185
|
+
:average_volume=>"850344",
|
186
|
+
:fifty_two_week=>{:low=>"1406.55005", :high=>"2659.91992", :low_change=>"1218.78003", :high_change=>"-34.58984", :low_change_percent=>"86.65031", :high_change_percent=>"-1.30041", :range=>"1406.550049 - 2659.919922"}}
|
187
|
+
</code></p>
|
188
|
+
|
189
|
+
<p>Likewise, if the API request format is <code>:csv</code> then <code>Response#parsed_body</code> will be <code>CSV#Table</code> instance</p>
|
190
|
+
|
191
|
+
<p><code>ruby
|
192
|
+
TwelvedataRuby.client.quote(symbol: "GOOG", format: :csv).parsed_body
|
193
|
+
=> #<CSV::Table mode:col_or_row row_count:2>
|
194
|
+
</code></p>
|
195
|
+
|
196
|
+
<h2 id="documentation">Documentation</h2>
|
197
|
+
<p>You can browse the source code <a href="https://kanroyalhigh.github.io/twelvedata_ruby/doc/">documentation</a>
|
198
|
+
## Contributing</p>
|
170
199
|
|
171
200
|
<p>Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/twelvedata_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the <a href="https://github.com/[USERNAME]/twelvedata_ruby/blob/master/CODE_OF_CONDUCT.md">code of conduct</a>.</p>
|
172
201
|
|
@@ -184,7 +213,7 @@ resp_objects_array = TwelvedataRuby::Client.request(quote_req, timeseries_req, e
|
|
184
213
|
</div></div>
|
185
214
|
|
186
215
|
<div id="footer">
|
187
|
-
Generated on
|
216
|
+
Generated on Fri Jul 16 20:51:22 2021 by
|
188
217
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
189
218
|
0.9.26 (ruby-3.0.1).
|
190
219
|
</div>
|
data/doc/index.html
CHANGED
@@ -164,9 +164,38 @@ resp_objects_array = TwelvedataRuby::Client.request(quote_req, timeseries_req, e
|
|
164
164
|
|
165
165
|
<p>Be caution that the above example, depending on the number request objects sent and how large the responses, hitting the daily limit is likely possible. But then again if you have several api keys you might be able to supply each request object with its own apikey. :)</p>
|
166
166
|
|
167
|
-
<p>
|
167
|
+
<p>The data from a successful API request can be access from <code>Response#parsed_body</code>. If request format is <code>:json</code> then it will be a <code>Hash</code> instance</p>
|
168
168
|
|
169
|
-
<
|
169
|
+
<p><code>ruby
|
170
|
+
TwelvedataRuby.client.quote(symbol: "GOOG").parsed_body
|
171
|
+
=>
|
172
|
+
{:symbol=>"GOOG",
|
173
|
+
:name=>"Alphabet Inc",
|
174
|
+
:exchange=>"NASDAQ",
|
175
|
+
:currency=>"USD",
|
176
|
+
:datetime=>"2021-07-15",
|
177
|
+
:open=>"2650.00000",
|
178
|
+
:high=>"2651.89990",
|
179
|
+
:low=>"2611.95996",
|
180
|
+
:close=>"2625.33008",
|
181
|
+
:volume=>"828300",
|
182
|
+
:previous_close=>"2641.64990",
|
183
|
+
:change=>"-16.31982",
|
184
|
+
:percent_change=>"-0.61779",
|
185
|
+
:average_volume=>"850344",
|
186
|
+
:fifty_two_week=>{:low=>"1406.55005", :high=>"2659.91992", :low_change=>"1218.78003", :high_change=>"-34.58984", :low_change_percent=>"86.65031", :high_change_percent=>"-1.30041", :range=>"1406.550049 - 2659.919922"}}
|
187
|
+
</code></p>
|
188
|
+
|
189
|
+
<p>Likewise, if the API request format is <code>:csv</code> then <code>Response#parsed_body</code> will be <code>CSV#Table</code> instance</p>
|
190
|
+
|
191
|
+
<p><code>ruby
|
192
|
+
TwelvedataRuby.client.quote(symbol: "GOOG", format: :csv).parsed_body
|
193
|
+
=> #<CSV::Table mode:col_or_row row_count:2>
|
194
|
+
</code></p>
|
195
|
+
|
196
|
+
<h2 id="documentation">Documentation</h2>
|
197
|
+
<p>You can browse the source code <a href="https://kanroyalhigh.github.io/twelvedata_ruby/doc/">documentation</a>
|
198
|
+
## Contributing</p>
|
170
199
|
|
171
200
|
<p>Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/twelvedata_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the <a href="https://github.com/[USERNAME]/twelvedata_ruby/blob/master/CODE_OF_CONDUCT.md">code of conduct</a>.</p>
|
172
201
|
|
@@ -184,7 +213,7 @@ resp_objects_array = TwelvedataRuby::Client.request(quote_req, timeseries_req, e
|
|
184
213
|
</div></div>
|
185
214
|
|
186
215
|
<div id="footer">
|
187
|
-
Generated on
|
216
|
+
Generated on Fri Jul 16 20:51:22 2021 by
|
188
217
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
189
218
|
0.9.26 (ruby-3.0.1).
|
190
219
|
</div>
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Fri Jul 16 20:51:23 2021 by
|
104
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.26 (ruby-3.0.1).
|
106
106
|
</div>
|
data/lib/twelvedata_ruby.rb
CHANGED
@@ -12,11 +12,11 @@ require_relative "twelvedata_ruby/client"
|
|
12
12
|
module TwelvedataRuby
|
13
13
|
# Holds the current version
|
14
14
|
# @return [String] version number
|
15
|
-
VERSION = "0.
|
15
|
+
VERSION = "0.3.0"
|
16
16
|
|
17
17
|
# A convenient and clearer way of getting and overriding default attribute values of the singleton `Client.instance`
|
18
18
|
#
|
19
|
-
# @param [Hash] options the optional Hash object that may contain values to override the
|
19
|
+
# @param [Hash] options the optional Hash object that may contain values to override the cd Docdefaults
|
20
20
|
# @option options [Symbol, String] :apikey the private key from Twelvedata API key
|
21
21
|
# @option options [Integer, String] :connect_timeout milliseconds
|
22
22
|
#
|
@@ -57,7 +57,21 @@ module TwelvedataRuby
|
|
57
57
|
},
|
58
58
|
time_series: {
|
59
59
|
parameters: {
|
60
|
-
keys: %i[
|
60
|
+
keys: %i[
|
61
|
+
symbol
|
62
|
+
interval
|
63
|
+
exchange
|
64
|
+
country
|
65
|
+
type
|
66
|
+
outputsize
|
67
|
+
format
|
68
|
+
dp
|
69
|
+
order
|
70
|
+
timezone
|
71
|
+
start_date
|
72
|
+
end_date
|
73
|
+
previous_close
|
74
|
+
],
|
61
75
|
required: %i[symbol interval]
|
62
76
|
},
|
63
77
|
response: {
|
@@ -96,15 +110,15 @@ module TwelvedataRuby
|
|
96
110
|
response: {keys: %i[price]}
|
97
111
|
},
|
98
112
|
eod: {
|
99
|
-
parameters: {keys: %i[symbol exchange country type], required: %i[symbol]},
|
113
|
+
parameters: {keys: %i[symbol exchange country type prepost dp], required: %i[symbol]},
|
100
114
|
response: {keys: %i[symbol exchange currency datetime close]}
|
101
115
|
},
|
102
116
|
exchange_rate: {
|
103
|
-
parameters: {keys: %i[symbol format], required: %i[symbol]},
|
117
|
+
parameters: {keys: %i[symbol format precision timezone], required: %i[symbol]},
|
104
118
|
response: {keys: %i[symbol rate timestamp]}
|
105
119
|
},
|
106
120
|
currency_conversion: {
|
107
|
-
parameters: {keys: %i[symbol amount format], required: %i[symbol amount]},
|
121
|
+
parameters: {keys: %i[symbol amount format precision timezone], required: %i[symbol amount]},
|
108
122
|
response: {keys: %i[symbol rate amount timestamp]}
|
109
123
|
},
|
110
124
|
complex_data: {
|
@@ -6,9 +6,9 @@ module TwelvedataRuby
|
|
6
6
|
"EndpointError" => "Endpoint is not valid. %{invalid}",
|
7
7
|
"EndpointNameError" => "`%{invalid}` is not a correct endpoint. Valid values are: `%{valid_names}`",
|
8
8
|
"EndpointParametersKeysError" => "Invalid parameters found: `%{invalid}`. Valid parameters for `%{name}` "\
|
9
|
-
|
9
|
+
"endpoint are: `%{parameters}`. Please see: `Twelvedata::Endpoint#parameters` for more details",
|
10
10
|
"EndpointRequiredParametersError" => "Missing values for required parameters: `%{invalid}`. "\
|
11
|
-
|
11
|
+
"`%{name}` endpoint required parameters are: `%{required}`.",
|
12
12
|
"ResponseError" => "Encountered an error from the response"
|
13
13
|
}.freeze
|
14
14
|
|
@@ -4,6 +4,7 @@ require "csv"
|
|
4
4
|
module TwelvedataRuby
|
5
5
|
class Response
|
6
6
|
CSV_COL_SEP = ";"
|
7
|
+
BODY_MAX_BYTESIZE = 16_000
|
7
8
|
HTTP_STATUSES = {http_error: (400..600), success: (200..299)}.freeze
|
8
9
|
CONTENT_TYPE_HANDLERS = {
|
9
10
|
json: {parser: :json_parser, dumper: :json_dumper},
|
@@ -34,12 +35,10 @@ module TwelvedataRuby
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
attr_reader :http_response, :headers, :body, :request
|
38
|
+
attr_reader :http_response, :headers, :body, :body_bytesize, :request
|
38
39
|
|
39
40
|
def initialize(http_response:, request:, headers: nil, body: nil)
|
40
41
|
self.http_response = http_response
|
41
|
-
self.headers = headers || http_response.headers
|
42
|
-
self.body = body || http_response.body
|
43
42
|
end
|
44
43
|
|
45
44
|
def attachment_filename
|
@@ -56,17 +55,12 @@ module TwelvedataRuby
|
|
56
55
|
@content_type ||= headers["content-type"].match(%r{^.+/([a-z]+).*$})&.send(:[], 1)&.to_sym
|
57
56
|
end
|
58
57
|
|
59
|
-
def csv_parser
|
60
|
-
|
61
|
-
opts = {col_sep: CSV_COL_SEP}
|
62
|
-
body.each do |chk|
|
63
|
-
chunk_parsed = chunk_parsed&.send(:push, CSV.parse(chk, **opts)) || CSV.parse(chk, **opts.merge(headers: true))
|
64
|
-
end
|
65
|
-
chunk_parsed
|
58
|
+
def csv_parser(io)
|
59
|
+
CSV.parse(io, headers: true, col_sep: CSV_COL_SEP)
|
66
60
|
end
|
67
61
|
|
68
62
|
def csv_dumper
|
69
|
-
parsed_body.is_a?(CSV::Table) ? parsed_body.to_csv : nil
|
63
|
+
parsed_body.is_a?(CSV::Table) ? parsed_body.to_csv(col_sep: CSV_COL_SEP) : nil
|
70
64
|
end
|
71
65
|
|
72
66
|
def dumped_parsed_body
|
@@ -89,20 +83,39 @@ module TwelvedataRuby
|
|
89
83
|
parsed_body.is_a?(Hash) ? JSON.dump(parsed_body) : nil
|
90
84
|
end
|
91
85
|
|
92
|
-
def json_parser
|
93
|
-
JSON.parse(
|
86
|
+
def json_parser(io)
|
87
|
+
JSON.parse(io, symbolize_names: true)
|
94
88
|
end
|
95
89
|
|
96
90
|
def parsed_body
|
97
|
-
@parsed_body
|
91
|
+
return @parsed_body if @parsed_body || http_response&.body.nil? || http_response&.body.closed?
|
92
|
+
|
93
|
+
begin
|
94
|
+
tmp_file = nil
|
95
|
+
if body_bytesize < BODY_MAX_BYTESIZE
|
96
|
+
@parsed_body = send(body_parser, http_response.body.to_s)
|
97
|
+
else
|
98
|
+
tmp_file = Tempfile.new
|
99
|
+
http_response.body.copy_to(tmp_file)
|
100
|
+
@parsed_body = send(body_parser, IO.read(tmp_file.path))
|
101
|
+
end
|
102
|
+
ensure
|
103
|
+
http_response.body.close
|
104
|
+
tmp_file&.close
|
105
|
+
tmp_file&.unlink
|
106
|
+
end
|
107
|
+
|
108
|
+
@parsed_body
|
98
109
|
end
|
110
|
+
alias body parsed_body
|
111
|
+
alias parse_http_response_body parsed_body
|
99
112
|
|
100
113
|
def parsed_body_dumper
|
101
114
|
CONTENT_TYPE_HANDLERS[content_type][:dumper]
|
102
115
|
end
|
103
116
|
|
104
|
-
def plain_parser
|
105
|
-
body.to_s
|
117
|
+
def plain_parser(io=nil)
|
118
|
+
io.to_s || http_response.body.to_s
|
106
119
|
end
|
107
120
|
|
108
121
|
def status_code
|
@@ -127,6 +140,17 @@ module TwelvedataRuby
|
|
127
140
|
|
128
141
|
private
|
129
142
|
|
130
|
-
attr_writer :
|
143
|
+
attr_writer :request
|
144
|
+
|
145
|
+
def http_response=(http_resp)
|
146
|
+
@http_response = http_resp
|
147
|
+
@body_bytesize = http_resp.body.bytesize
|
148
|
+
self.headers = http_response.headers
|
149
|
+
parse_http_response_body
|
150
|
+
end
|
151
|
+
|
152
|
+
def headers=(http_resp_headers)
|
153
|
+
@headers = http_response&.headers
|
154
|
+
end
|
131
155
|
end
|
132
156
|
end
|
data/twelvedata_ruby.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.summary = "A Ruby client library that provides helping hands in accessing Twelve Data API's stock, \
|
11
11
|
forex, crypto, and other financial data"
|
12
12
|
spec.description = "A Ruby gem for accessing Twelve Data's API."
|
13
|
-
spec.homepage = "https://github.
|
13
|
+
spec.homepage = "https://kanroyalhigh.github.io/twelvedata_ruby"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
16
|
|
@@ -28,10 +28,10 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.bindir = "exe"
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) {|f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
|
-
spec.add_dependency "httpx", "~> 0.14.5"
|
32
|
-
spec.add_development_dependency "rake", "~> 13.0", ">= 13.0.
|
33
|
-
spec.add_development_dependency "rspec", "~> 3.10.0"
|
34
|
-
spec.add_development_dependency "rubocop", "~> 1.17.0"
|
31
|
+
spec.add_dependency "httpx", "~> 0.14", ">= 0.14.5"
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0", ">= 13.0.0"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.10", ">= 3.10.0"
|
34
|
+
spec.add_development_dependency "rubocop", "~> 1.17", ">= 1.17.0"
|
35
35
|
spec.add_development_dependency "simplecov", "~> 0.21", ">= 0.21.2"
|
36
36
|
spec.add_development_dependency "webmock", "~> 3.13", ">= 3.13.0"
|
37
37
|
end
|
metadata
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twelvedata_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kendo Camajalan, KCD
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpx
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.14'
|
20
|
+
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 0.14.5
|
20
23
|
type: :runtime
|
@@ -22,6 +25,9 @@ dependencies:
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.14'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 0.14.5
|
27
33
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +39,7 @@ dependencies:
|
|
33
39
|
version: '13.0'
|
34
40
|
- - ">="
|
35
41
|
- !ruby/object:Gem::Version
|
36
|
-
version: 13.0.
|
42
|
+
version: 13.0.0
|
37
43
|
type: :development
|
38
44
|
prerelease: false
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,12 +49,15 @@ dependencies:
|
|
43
49
|
version: '13.0'
|
44
50
|
- - ">="
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version: 13.0.
|
52
|
+
version: 13.0.0
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: rspec
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
50
56
|
requirements:
|
51
57
|
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.10'
|
60
|
+
- - ">="
|
52
61
|
- !ruby/object:Gem::Version
|
53
62
|
version: 3.10.0
|
54
63
|
type: :development
|
@@ -56,6 +65,9 @@ dependencies:
|
|
56
65
|
version_requirements: !ruby/object:Gem::Requirement
|
57
66
|
requirements:
|
58
67
|
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.10'
|
70
|
+
- - ">="
|
59
71
|
- !ruby/object:Gem::Version
|
60
72
|
version: 3.10.0
|
61
73
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +75,9 @@ dependencies:
|
|
63
75
|
requirement: !ruby/object:Gem::Requirement
|
64
76
|
requirements:
|
65
77
|
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '1.17'
|
80
|
+
- - ">="
|
66
81
|
- !ruby/object:Gem::Version
|
67
82
|
version: 1.17.0
|
68
83
|
type: :development
|
@@ -70,6 +85,9 @@ dependencies:
|
|
70
85
|
version_requirements: !ruby/object:Gem::Requirement
|
71
86
|
requirements:
|
72
87
|
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.17'
|
90
|
+
- - ">="
|
73
91
|
- !ruby/object:Gem::Version
|
74
92
|
version: 1.17.0
|
75
93
|
- !ruby/object:Gem::Dependency
|
@@ -171,11 +189,11 @@ files:
|
|
171
189
|
- lib/twelvedata_ruby/response.rb
|
172
190
|
- lib/twelvedata_ruby/utils.rb
|
173
191
|
- twelvedata_ruby.gemspec
|
174
|
-
homepage: https://github.
|
192
|
+
homepage: https://kanroyalhigh.github.io/twelvedata_ruby
|
175
193
|
licenses:
|
176
194
|
- MIT
|
177
195
|
metadata:
|
178
|
-
homepage_uri: https://github.
|
196
|
+
homepage_uri: https://kanroyalhigh.github.io/twelvedata_ruby
|
179
197
|
source_code_uri: https://github.com/kanroyalhigh/twelvedata_ruby
|
180
198
|
changelog_uri: https://github.com/kanroyalhigh/twelvedata_ruby/CHANGELOG.md
|
181
199
|
post_install_message:
|
@@ -193,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
211
|
- !ruby/object:Gem::Version
|
194
212
|
version: '0'
|
195
213
|
requirements: []
|
196
|
-
rubygems_version: 3.2.
|
214
|
+
rubygems_version: 3.2.22
|
197
215
|
signing_key:
|
198
216
|
specification_version: 4
|
199
217
|
summary: A Ruby client library that provides helping hands in accessing Twelve Data
|