alphavantagerb 1.0.0 → 1.1.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/AlphavantageRB.gemspec +1 -1
- data/README.md +67 -32
- data/lib/Batch.rb +52 -0
- data/lib/Client.rb +4 -0
- data/lib/Crypto.rb +2 -2
- data/lib/Crypto_Timeseries.rb +9 -9
- data/lib/alphavantagerb.rb +1 -0
- data/spec/lib/1.0.0/crypto_timeseries.rb +15 -21
- data/spec/lib/1.0.0/exchange.rb +9 -9
- data/spec/lib/1.0.0/sector.rb +9 -9
- data/spec/lib/1.0.0/timeseries.rb +9 -9
- data/spec/lib/1.1.0/batch.rb +45 -0
- data/spec/test_all.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2846dc690fd548267b1fd3657beae0c5be91451c
|
4
|
+
data.tar.gz: 5b6cdcb1492ba342f1cf8e02a5284fd89dd0290b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e62c435f993111a6c95e2b2522eea583f80c9dfb5b6b3efb9e74bddf5a7d45ca2d47c98b9ad7daf8d11003a84f6a9fbdf1447b6d297c228fc6dc3dcf759c08d
|
7
|
+
data.tar.gz: e0141b848e4b8512ebf1f2f7d618d109adbcec3a62217752d6a8ec6ac964ec0c50704161d074525514104e9407ac42aa05b2b6b1624f977df9824fbcf618a6b6
|
data/AlphavantageRB.gemspec
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
AlphavantageRB
|
1
|
+
AlphavantageRB [](https://badge.fury.io/rb/alphavantagerb)
|
2
2
|
=========================================================
|
3
3
|
|
4
4
|
[Alpha Vantage](https://www.alphavantage.co/) is a great API for retrieving Stock
|
5
5
|
market data in JSON or CSV format.
|
6
|
-
AlphavantageRB is a Gem to use Alpha Vantage with Ruby.
|
6
|
+
AlphavantageRB is a Gem to use Alpha Vantage with Ruby. AlphavantageRB is based
|
7
7
|
on the [HTTP API of Alpha Vantage](https://www.alphavantage.co/documentation/).
|
8
8
|
|
9
|
+
To install AlphavantageRB: `gem install alphavantagerb`
|
10
|
+
|
11
|
+
To use it in your application: `require "alphavantagerb"`
|
12
|
+
|
9
13
|
## Classes
|
10
14
|
|
11
15
|
AlphavantateRB has the following classes:
|
@@ -14,6 +18,7 @@ AlphavantateRB has the following classes:
|
|
14
18
|
Vantage
|
15
19
|
* [Alphavantage::Stock](#Stock): to create a stock class
|
16
20
|
* [Alphavantage::Timeseries](#Timeseries): to retrieve historical data of a stock
|
21
|
+
* [Alphavantage::Batch](#Batch): to retrieve multiple stock data at once
|
17
22
|
* [Alphavantage::Indicator](#Indicator): to use some technical indicator of a stock
|
18
23
|
* [Alphavantage::Crypto](#Crypto): to create a crypto currency class
|
19
24
|
* [Alphavantage::Crypto_Timeseries](#Crypto_Timeseries): to retrieve historical
|
@@ -126,6 +131,44 @@ You can order the data in ascending or descending order.
|
|
126
131
|
timeseries.open("asc")
|
127
132
|
```
|
128
133
|
|
134
|
+
<a name="Batch"></a>
|
135
|
+
## Alphavantage::Batch
|
136
|
+
|
137
|
+
Alphavantage::Batch is used to retrieve the last updated values of multiple stocks.
|
138
|
+
To create a new Batch class you can use a Client class or you can create it directly.
|
139
|
+
These two creation commands are equivalent:
|
140
|
+
|
141
|
+
``` ruby
|
142
|
+
batch = client.batch symbols: ["MSFT", "FB", "AAPL"]
|
143
|
+
batch = Alphavantage::Batch.new symbols: ["MSFT", "FB", "AAPL"], key: "YOURKEY"
|
144
|
+
```
|
145
|
+
|
146
|
+
Note that the initialization owns different entries:
|
147
|
+
* symbols: it is an array of string that denote the stocks you want to retrieve.
|
148
|
+
* key: authentication key. This value cannot be setup if you are initializing a batch from a client
|
149
|
+
* verbose: used to see the request to Alpha Vantage (default false). This value cannot be setup if you are initializing a batch from a client
|
150
|
+
* datatype: it can be "json" or "csv" (default "json")
|
151
|
+
* file: path where a csv file should be saved (default "nil")
|
152
|
+
|
153
|
+
You can retrieve all the output from Alpha Vantage by doing.
|
154
|
+
``` ruby
|
155
|
+
batch.hash
|
156
|
+
```
|
157
|
+
|
158
|
+
The array of the stocks is found by using:
|
159
|
+
``` ruby
|
160
|
+
batch.stock_quotes
|
161
|
+
```
|
162
|
+
|
163
|
+
Specific information about the batch can be retrieved using the following methods:
|
164
|
+
|
165
|
+
``` ruby
|
166
|
+
batch.information # Retrieve information about the batch
|
167
|
+
batch.symbols # Symbols used by the batch
|
168
|
+
batch.notes # Generic notes of the batch
|
169
|
+
batch.time_zone # Time zone of the batch
|
170
|
+
```
|
171
|
+
|
129
172
|
<a name="Indicator"></a>
|
130
173
|
## Alphavantage::Indicator
|
131
174
|
|
@@ -597,8 +640,8 @@ To create a new Crypto class you can use a client or you can create it directly.
|
|
597
640
|
These two creation commands are equivalent:
|
598
641
|
|
599
642
|
``` ruby
|
600
|
-
|
601
|
-
|
643
|
+
crypto = client.crypto symbol: "BTC", market: "DKK"
|
644
|
+
crypto = Alphavantage::Crypto.new symbol: "BTC", market: "DKK", key: "YOURKEY"
|
602
645
|
```
|
603
646
|
|
604
647
|
Note that the initialization owns different entry:
|
@@ -611,7 +654,7 @@ Note that the initialization owns different entry:
|
|
611
654
|
You can setup the datatype of future retrieving by doing:
|
612
655
|
|
613
656
|
``` ruby
|
614
|
-
|
657
|
+
crypto.datatype = "csv"
|
615
658
|
```
|
616
659
|
|
617
660
|
<a name="Crypto_Timeseries"></a>
|
@@ -622,8 +665,8 @@ To create a new Crypto_Timeseries class you can use a Crypto class or you can cr
|
|
622
665
|
These two creation commands are equivalent:
|
623
666
|
|
624
667
|
``` ruby
|
625
|
-
crypto_timeseries = crypto.timeseries
|
626
|
-
crypto_timeseries = Alphavantage::Crypto_Timeseries.new
|
668
|
+
crypto_timeseries = crypto.timeseries
|
669
|
+
crypto_timeseries = Alphavantage::Crypto_Timeseries.new symbol: "BTC", market: "DKK", key: "YOURKEY"
|
627
670
|
```
|
628
671
|
|
629
672
|
Note that the initialization owns different entries:
|
@@ -631,7 +674,6 @@ Note that the initialization owns different entries:
|
|
631
674
|
* market: it is a string that denote the market you want to analyze. This value cannot be setup if you are initializing a timeseries from a stock
|
632
675
|
* key: authentication key. This value cannot be setup if you are initializing a timeseries from a crypto class
|
633
676
|
* verbose: used to see the request to Alpha Vantage (default false). This value cannot be setup if you are initializing a timeseries from a stock
|
634
|
-
* type: it can be "intraday", "daily", "weekly", "monthly" (default "daily")
|
635
677
|
* datatype: it can be "json" or "csv" (default "json")
|
636
678
|
* file: path where a csv file should be saved (default "nil")
|
637
679
|
|
@@ -658,23 +700,17 @@ These methods will return an array of couples where the first entry is a timesta
|
|
658
700
|
These timeseries return always the corrispective timeseries in relation of the USD market.
|
659
701
|
|
660
702
|
``` ruby
|
661
|
-
crypto_timeseries.
|
662
|
-
crypto_timeseries.
|
663
|
-
crypto_timeseries.high
|
664
|
-
crypto_timeseries.low
|
703
|
+
crypto_timeseries.price
|
704
|
+
crypto_timeseries.price_usd
|
665
705
|
crypto_timeseries.volume
|
666
|
-
crypto_timeseries.open_usd
|
667
|
-
crypto_timeseries.close_usd
|
668
|
-
crypto_timeseries.high_usd
|
669
|
-
crypto_timeseries.low_usd
|
670
706
|
crypto_timeseries.market_cap_usd
|
671
707
|
```
|
672
708
|
|
673
709
|
You can order the data in ascending or descending order.
|
674
710
|
|
675
711
|
``` ruby
|
676
|
-
|
677
|
-
|
712
|
+
crypto_timeseries.price("desc") # Default
|
713
|
+
crypto_timeseries.price("asc")
|
678
714
|
```
|
679
715
|
<a name="Exchange"></a>
|
680
716
|
## Alphavantage::Exchange
|
@@ -734,24 +770,23 @@ Note that the initialization owns different entries:
|
|
734
770
|
|
735
771
|
You can retrieve all the output from Alpha Vantage by doing.
|
736
772
|
``` ruby
|
737
|
-
|
773
|
+
sector.hash
|
738
774
|
```
|
739
775
|
|
740
776
|
Specific information about the timeseries can be retrieved using the following methods:
|
741
777
|
``` ruby
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
exchange.ten_year_performance
|
778
|
+
sector.information
|
779
|
+
sector.last_refreshed
|
780
|
+
sector.real_time_performance
|
781
|
+
sector.one_day_performance
|
782
|
+
sector.five_day_performance
|
783
|
+
sector.one_month_performance
|
784
|
+
sector.three_month_performance
|
785
|
+
sector.year_to_date_performance
|
786
|
+
sector.one_year_performance
|
787
|
+
sector.three_year_performance
|
788
|
+
sector.five_year_performance
|
789
|
+
sector.ten_year_performance
|
755
790
|
```
|
756
791
|
|
757
792
|
<a name="Error"></a>
|
data/lib/Batch.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Alphavantage
|
2
|
+
class Batch
|
3
|
+
include HelperFunctions
|
4
|
+
|
5
|
+
def initialize symbols:, datatype: "json", key:, verbose: false, file: nil
|
6
|
+
check_argument([true, false], verbose, "verbose")
|
7
|
+
symbols = [symbols] unless symbols.is_a?(Array)
|
8
|
+
@client = return_client(key, verbose)
|
9
|
+
@symbols = symbols
|
10
|
+
@datatype = datatype
|
11
|
+
@verbose = verbose
|
12
|
+
@file = file
|
13
|
+
check_argument(["json", "csv"], datatype, "datatype")
|
14
|
+
if datatype == "csv" && file.nil?
|
15
|
+
raise Alphavantage::Error.new message: "No file specified where to save the CSV ata"
|
16
|
+
elsif datatype != "csv" && !file.nil?
|
17
|
+
raise Alphavantage::Error.new message: "Hash error: No file necessary"
|
18
|
+
end
|
19
|
+
name_symbols = symbols.join(",")
|
20
|
+
name_symbols.upcase!
|
21
|
+
url = "function=BATCH_STOCK_QUOTES&symbols=#{name_symbols}"
|
22
|
+
return @client.download(url, file) if datatype == "csv"
|
23
|
+
@hash = @client.request(url)
|
24
|
+
metadata = @hash.dig("Meta Data") || {}
|
25
|
+
metadata.each do |key, val|
|
26
|
+
key_sym = recreate_metadata_key(key)
|
27
|
+
define_singleton_method(key_sym) do
|
28
|
+
return val
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
stock_quote = @hash.find{|key, val| key.include?("Stock Quotes")}[1]
|
34
|
+
rescue Exception => e
|
35
|
+
raise Alphavantage::Error.new message: "No Stock Quotes found: #{e.message}",
|
36
|
+
data: @hash
|
37
|
+
end
|
38
|
+
|
39
|
+
@stock_quote = []
|
40
|
+
stock_quote.each do |sq|
|
41
|
+
sval = {}
|
42
|
+
sq.each do |key, val|
|
43
|
+
key_sym = key.downcase.gsub(/[0-9.]/, "").lstrip.gsub(" ", "_")
|
44
|
+
sval[key_sym] = val
|
45
|
+
end
|
46
|
+
@stock_quote << sval
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
attr_reader :datatype, :stock_quote, :hash, :symbols
|
51
|
+
end
|
52
|
+
end
|
data/lib/Client.rb
CHANGED
@@ -51,6 +51,10 @@ module Alphavantage
|
|
51
51
|
return "CSV saved in #{file}"
|
52
52
|
end
|
53
53
|
|
54
|
+
def batch(symbols:, datatype: "json", file: nil)
|
55
|
+
Alphavantage::Batch.new symbols: symbols, key: self, datatype: datatype, file: file
|
56
|
+
end
|
57
|
+
|
54
58
|
def stock(symbol:, datatype: "json")
|
55
59
|
Alphavantage::Stock.new symbol: symbol, key: self, datatype: datatype
|
56
60
|
end
|
data/lib/Crypto.rb
CHANGED
@@ -18,8 +18,8 @@ module Alphavantage
|
|
18
18
|
@datatype = datatype
|
19
19
|
end
|
20
20
|
|
21
|
-
def timeseries
|
22
|
-
Alphavantage::Crypto_Timeseries.new
|
21
|
+
def timeseries market: @market, file: nil, datatype: @datatype
|
22
|
+
Alphavantage::Crypto_Timeseries.new market: market,
|
23
23
|
symbol: @symbol, datatype: datatype, file: file, key: @client
|
24
24
|
end
|
25
25
|
end
|
data/lib/Crypto_Timeseries.rb
CHANGED
@@ -2,7 +2,7 @@ module Alphavantage
|
|
2
2
|
class Crypto_Timeseries
|
3
3
|
include HelperFunctions
|
4
4
|
|
5
|
-
def initialize
|
5
|
+
def initialize market:, symbol:, datatype: "json", file: nil,
|
6
6
|
key:, verbose: false
|
7
7
|
check_argument([true, false], verbose, "verbose")
|
8
8
|
@client = return_client(key, verbose)
|
@@ -13,8 +13,8 @@ module Alphavantage
|
|
13
13
|
raise Alphavantage::Error.new message: "Hash error: No file necessary"
|
14
14
|
end
|
15
15
|
|
16
|
-
@selected_time_series = which_series(type)
|
17
|
-
url = "function
|
16
|
+
# @selected_time_series = which_series(type)
|
17
|
+
url = "function=DIGITAL_CURRENCY_INTRADAY&symbol=#{symbol}&market=#{market}"
|
18
18
|
return @client.download(url, file) if datatype == "csv"
|
19
19
|
@hash = @client.request(url)
|
20
20
|
metadata = @hash.dig("Meta Data") || {}
|
@@ -57,11 +57,11 @@ module Alphavantage
|
|
57
57
|
|
58
58
|
attr_reader :hash
|
59
59
|
|
60
|
-
def which_series(type)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
60
|
+
# def which_series(type)
|
61
|
+
# check_argument(["intraday", "daily", "weekly", "monthly"], type, "type")
|
62
|
+
# series = "DIGITAL_CURRENCY_"
|
63
|
+
# series += type.upcase
|
64
|
+
# return series
|
65
|
+
# end
|
66
66
|
end
|
67
67
|
end
|
data/lib/alphavantagerb.rb
CHANGED
@@ -3,17 +3,17 @@ require_relative './../../spec_helper'
|
|
3
3
|
describe Alphavantage::Crypto_Timeseries do
|
4
4
|
context "#new" do
|
5
5
|
it "create a new timeseries without stock" do
|
6
|
-
sleep(1); stock = Alphavantage::Crypto_Timeseries.new symbol: "BTC", key: @config["key"], verbose: false, market: "DKK"
|
6
|
+
sleep(1); stock = Alphavantage::Crypto_Timeseries.new symbol: "BTC", key: @config["key"], verbose: false, market: "DKK"
|
7
7
|
expect(stock.class).to eq Alphavantage::Crypto_Timeseries
|
8
8
|
end
|
9
9
|
|
10
10
|
it "create a new stock from stock" do
|
11
|
-
sleep(1); timeseries = @client.crypto(symbol: "BTC", market: "DKK").timeseries
|
11
|
+
sleep(1); timeseries = @client.crypto(symbol: "BTC", market: "DKK").timeseries
|
12
12
|
expect(timeseries.class).to eq Alphavantage::Crypto_Timeseries
|
13
13
|
end
|
14
14
|
|
15
15
|
it "own multiple data" do
|
16
|
-
sleep(1); timeseries = @client.crypto(symbol: "BTC", market: "DKK").timeseries
|
16
|
+
sleep(1); timeseries = @client.crypto(symbol: "BTC", market: "DKK").timeseries
|
17
17
|
bool = []
|
18
18
|
bool << timeseries.information.is_a?(String)
|
19
19
|
bool << (timeseries.digital_currency_code == "BTC")
|
@@ -23,33 +23,27 @@ describe Alphavantage::Crypto_Timeseries do
|
|
23
23
|
bool << timeseries.last_refreshed.is_a?(String)
|
24
24
|
bool << timeseries.time_zone.is_a?(String)
|
25
25
|
bool << timeseries.hash.is_a?(Hash)
|
26
|
-
bool << timeseries.open.is_a?(Array)
|
27
|
-
bool << timeseries.high.is_a?(Array)
|
28
|
-
bool << timeseries.low.is_a?(Array)
|
29
|
-
bool << timeseries.close.is_a?(Array)
|
30
26
|
bool << timeseries.volume("asc").is_a?(Array)
|
31
|
-
bool << timeseries.
|
32
|
-
bool << timeseries.
|
33
|
-
bool << timeseries.low_usd.is_a?(Array)
|
34
|
-
bool << timeseries.close_usd.is_a?(Array)
|
27
|
+
bool << timeseries.price.is_a?(Array)
|
28
|
+
bool << timeseries.price_usd.is_a?(Array)
|
35
29
|
bool << timeseries.market_cap_usd.is_a?(Array)
|
36
30
|
expect(bool.all?{|e| e}).to eq true
|
37
31
|
end
|
38
32
|
|
39
|
-
it "cannot retrieve with wrong key" do
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
33
|
+
# it "cannot retrieve with wrong key" do
|
34
|
+
# error = false
|
35
|
+
# begin
|
36
|
+
# sleep(1); stock = Alphavantage::Crypto_Timeseries.new symbol: "BTC", key: "wrong_key", market: "DKK"
|
37
|
+
# rescue Alphavantage::Error => e
|
38
|
+
# error = true
|
39
|
+
# end
|
40
|
+
# expect(error).to eq true
|
41
|
+
# end
|
48
42
|
|
49
43
|
it "cannot retrieve with wrong symbol" do
|
50
44
|
error = false
|
51
45
|
begin
|
52
|
-
sleep(1); stock = Alphavantage::Crypto_Timeseries.new symbol: "wrong_symbol", key: @config["key"], market: "DKK"
|
46
|
+
sleep(1); stock = Alphavantage::Crypto_Timeseries.new symbol: "wrong_symbol", key: @config["key"], market: "DKK"
|
53
47
|
rescue Alphavantage::Error => e
|
54
48
|
error = true
|
55
49
|
end
|
data/spec/lib/1.0.0/exchange.rb
CHANGED
@@ -26,15 +26,15 @@ describe Alphavantage::Exchange do
|
|
26
26
|
expect(bool.all?{|e| e}).to eq true
|
27
27
|
end
|
28
28
|
|
29
|
-
it "cannot retrieve with wrong key" do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
29
|
+
# it "cannot retrieve with wrong key" do
|
30
|
+
# error = false
|
31
|
+
# begin
|
32
|
+
# sleep(1); stock = Alphavantage::Exchange.new from: "USD", to: "DKK", key:"wrong_key"
|
33
|
+
# rescue Alphavantage::Error => e
|
34
|
+
# error = true
|
35
|
+
# end
|
36
|
+
# expect(error).to eq true
|
37
|
+
# end
|
38
38
|
|
39
39
|
it "cannot retrieve with wrong symbol" do
|
40
40
|
error = false
|
data/spec/lib/1.0.0/sector.rb
CHANGED
@@ -31,14 +31,14 @@ describe Alphavantage::Sector do
|
|
31
31
|
expect(bool.all?{|e| e}).to eq true
|
32
32
|
end
|
33
33
|
|
34
|
-
it "cannot retrieve with wrong key" do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
34
|
+
# it "cannot retrieve with wrong key" do
|
35
|
+
# error = false
|
36
|
+
# begin
|
37
|
+
# sleep(1); stock = Alphavantage::Sector.new key:"wrong_key"
|
38
|
+
# rescue Alphavantage::Error => e
|
39
|
+
# error = true
|
40
|
+
# end
|
41
|
+
# expect(error).to eq true
|
42
|
+
# end
|
43
43
|
end
|
44
44
|
end
|
@@ -78,15 +78,15 @@ describe Alphavantage::Stock do
|
|
78
78
|
expect(bool).to eq [false, true]
|
79
79
|
end
|
80
80
|
|
81
|
-
it "cannot retrieve with wrong key" do
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
81
|
+
# it "cannot retrieve with wrong key" do
|
82
|
+
# error = false
|
83
|
+
# begin
|
84
|
+
# sleep(1); stock = Alphavantage::Timeseries.new symbol: "MSFT", key:"wrong key"
|
85
|
+
# rescue Alphavantage::Error => e
|
86
|
+
# error = true
|
87
|
+
# end
|
88
|
+
# expect(error).to eq true
|
89
|
+
# end
|
90
90
|
|
91
91
|
it "cannot retrieve with wrong symbol" do
|
92
92
|
error = false
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative './../../spec_helper'
|
2
|
+
|
3
|
+
describe Alphavantage::Batch do
|
4
|
+
context "#new" do
|
5
|
+
it "create a new batch without client" do
|
6
|
+
stock = Alphavantage::Batch.new symbols: ["MSFT", "FB", "AAPL"], key: @config["key"]
|
7
|
+
expect(stock.class).to eq Alphavantage::Batch
|
8
|
+
end
|
9
|
+
|
10
|
+
it "create a new batch from client" do
|
11
|
+
stock = @client.batch symbols: ["MSFT", "FB", "AAPL"]
|
12
|
+
expect(stock.class).to eq Alphavantage::Batch
|
13
|
+
end
|
14
|
+
|
15
|
+
it "own multiple data" do
|
16
|
+
sleep(1); timeseries = @client.batch symbols: ["MSFT", "FB", "AAPL"]
|
17
|
+
bool = []
|
18
|
+
bool << timeseries.information.is_a?(String)
|
19
|
+
bool << timeseries.notes.is_a?(String)
|
20
|
+
bool << timeseries.time_zone.is_a?(String)
|
21
|
+
bool << timeseries.stock_quote.is_a?(Array)
|
22
|
+
expect(bool.all?{|e| e}).to eq true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can retrieve csv files" do
|
26
|
+
bool = []
|
27
|
+
directory = "#{__dir__}/test.csv"
|
28
|
+
bool << File.exists?(directory)
|
29
|
+
sleep(1); @client.batch(symbols: ["MSFT", "FB", "AAPL"], datatype: "csv", file: directory)
|
30
|
+
bool << File.exists?(directory)
|
31
|
+
File.delete(directory)
|
32
|
+
expect(bool).to eq [false, true]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "cannot retrieve with wrong symbol" do
|
36
|
+
error = false
|
37
|
+
begin
|
38
|
+
sleep(1); stock = Alphavantage::Batch.new symbols: ["MSAFT", "FDB", "AAAPL"], key: @config["key"]
|
39
|
+
rescue Alphavantage::Error => e
|
40
|
+
error = true
|
41
|
+
end
|
42
|
+
expect(stock.stock_quote.empty?).to eq true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/test_all.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alphavantagerb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- Gemfile
|
50
50
|
- LICENSE.md
|
51
51
|
- README.md
|
52
|
+
- lib/Batch.rb
|
52
53
|
- lib/Client.rb
|
53
54
|
- lib/Crypto.rb
|
54
55
|
- lib/Crypto_Timeseries.rb
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- spec/lib/1.0.0/sector.rb
|
70
71
|
- spec/lib/1.0.0/stock.rb
|
71
72
|
- spec/lib/1.0.0/timeseries.rb
|
73
|
+
- spec/lib/1.1.0/batch.rb
|
72
74
|
- spec/spec_helper.rb
|
73
75
|
- spec/test_all.rb
|
74
76
|
homepage: https://github.com/StefanoMartin/AlphaVantageRB
|