alphavantagerb 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AlphavantageRB.gemspec +1 -1
- data/README.md +13 -6
- data/lib/Crypto.rb +2 -2
- data/lib/Crypto_Timeseries.rb +9 -9
- data/spec/lib/1.0.0/crypto_timeseries.rb +12 -6
- 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: 45b9bfaa0883fbcebabc5b26972fd66f736df2c4
|
4
|
+
data.tar.gz: 9407ed9a0c3761d8ba70bf79a19678bc7b614ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d07776377781826d1778768bad668cf5125f3e8856b52828c27b0d3a45bfe18907023739cd0d4884af890ce9727f528c4775e02f502fac9970980e48dcdb0bf3
|
7
|
+
data.tar.gz: 60945c1de9ffc3d0c08dff5b65b87cf3cba61615f32d61107e17f3ffcf9db5afa8570f6abb978cc61069bcc31385ff4e46cc354418728ea0a455f768b31bda9f
|
data/AlphavantageRB.gemspec
CHANGED
data/README.md
CHANGED
@@ -665,8 +665,8 @@ To create a new Crypto_Timeseries class you can use a Crypto class or you can cr
|
|
665
665
|
These two creation commands are equivalent:
|
666
666
|
|
667
667
|
``` ruby
|
668
|
-
crypto_timeseries = crypto.timeseries
|
669
|
-
crypto_timeseries = Alphavantage::Crypto_Timeseries.new symbol: "BTC", market: "DKK", key: "YOURKEY"
|
668
|
+
crypto_timeseries = crypto.timeseries type: "daily"
|
669
|
+
crypto_timeseries = Alphavantage::Crypto_Timeseries.new type: "daily", symbol: "BTC", market: "DKK", key: "YOURKEY"
|
670
670
|
```
|
671
671
|
|
672
672
|
Note that the initialization owns different entries:
|
@@ -674,6 +674,7 @@ Note that the initialization owns different entries:
|
|
674
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
|
675
675
|
* key: authentication key. This value cannot be setup if you are initializing a timeseries from a crypto class
|
676
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
|
677
|
+
* type: it can be "intraday", "daily", "weekly", "monthly" (default "daily")
|
677
678
|
* datatype: it can be "json" or "csv" (default "json")
|
678
679
|
* file: path where a csv file should be saved (default "nil")
|
679
680
|
|
@@ -700,17 +701,23 @@ These methods will return an array of couples where the first entry is a timesta
|
|
700
701
|
These timeseries return always the corrispective timeseries in relation of the USD market.
|
701
702
|
|
702
703
|
``` ruby
|
703
|
-
crypto_timeseries.
|
704
|
-
crypto_timeseries.
|
704
|
+
crypto_timeseries.open
|
705
|
+
crypto_timeseries.close
|
706
|
+
crypto_timeseries.high
|
707
|
+
crypto_timeseries.low
|
705
708
|
crypto_timeseries.volume
|
709
|
+
crypto_timeseries.open_usd
|
710
|
+
crypto_timeseries.close_usd
|
711
|
+
crypto_timeseries.high_usd
|
712
|
+
crypto_timeseries.low_usd
|
706
713
|
crypto_timeseries.market_cap_usd
|
707
714
|
```
|
708
715
|
|
709
716
|
You can order the data in ascending or descending order.
|
710
717
|
|
711
718
|
``` ruby
|
712
|
-
crypto_timeseries.
|
713
|
-
crypto_timeseries.
|
719
|
+
crypto_timeseries.open("desc") # Default
|
720
|
+
crypto_timeseries.open("asc")
|
714
721
|
```
|
715
722
|
<a name="Exchange"></a>
|
716
723
|
## Alphavantage::Exchange
|
data/lib/Crypto.rb
CHANGED
@@ -18,8 +18,8 @@ module Alphavantage
|
|
18
18
|
@datatype = datatype
|
19
19
|
end
|
20
20
|
|
21
|
-
def timeseries market: @market, file: nil, datatype: @datatype
|
22
|
-
Alphavantage::Crypto_Timeseries.new market: market,
|
21
|
+
def timeseries type: "intraday", market: @market, file: nil, datatype: @datatype
|
22
|
+
Alphavantage::Crypto_Timeseries.new type: type, 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 market:, symbol:, datatype: "json", file: nil,
|
5
|
+
def initialize type: "intraday", 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
|
-
|
17
|
-
url = "function
|
16
|
+
@selected_time_series = which_series(type)
|
17
|
+
url = "function=#{@selected_time_series}&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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
@@ -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", type: "daily"
|
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(type: "monthly")
|
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(type: "monthly")
|
17
17
|
bool = []
|
18
18
|
bool << timeseries.information.is_a?(String)
|
19
19
|
bool << (timeseries.digital_currency_code == "BTC")
|
@@ -23,9 +23,15 @@ 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)
|
26
30
|
bool << timeseries.volume("asc").is_a?(Array)
|
27
|
-
bool << timeseries.
|
28
|
-
bool << timeseries.
|
31
|
+
bool << timeseries.open_usd.is_a?(Array)
|
32
|
+
bool << timeseries.high_usd.is_a?(Array)
|
33
|
+
bool << timeseries.low_usd.is_a?(Array)
|
34
|
+
bool << timeseries.close_usd.is_a?(Array)
|
29
35
|
bool << timeseries.market_cap_usd.is_a?(Array)
|
30
36
|
expect(bool.all?{|e| e}).to eq true
|
31
37
|
end
|
@@ -43,7 +49,7 @@ describe Alphavantage::Crypto_Timeseries do
|
|
43
49
|
it "cannot retrieve with wrong symbol" do
|
44
50
|
error = false
|
45
51
|
begin
|
46
|
-
sleep(1); stock = Alphavantage::Crypto_Timeseries.new symbol: "wrong_symbol", key: @config["key"], market: "DKK"
|
52
|
+
sleep(1); stock = Alphavantage::Crypto_Timeseries.new symbol: "wrong_symbol", key: @config["key"], market: "DKK", type: "daily"
|
47
53
|
rescue Alphavantage::Error => e
|
48
54
|
error = true
|
49
55
|
end
|
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.2.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: 2018-
|
11
|
+
date: 2018-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|