finnhubrb 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/FinnhubRB.gemspec +1 -1
- data/README.md +56 -9
- data/lib/Client.rb +7 -0
- data/lib/Crypto.rb +1 -1
- data/lib/Stock.rb +94 -6
- data/lib/Tick.rb +40 -0
- data/lib/Timeseries.rb +3 -2
- data/lib/Transcript.rb +15 -0
- data/lib/{finnhubrb.rb → finnhub.rb} +2 -0
- data/spec/1.0.0/stock.rb +2 -2
- data/spec/1.1.0/stock.rb +90 -0
- data/spec/all.rb +1 -0
- data/spec/config.yml +1 -1
- data/spec/spec_helper.rb +2 -4
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24f55e759933953990eb11d0047d58d31ba29fe6937d5c216001021c4f708589
|
4
|
+
data.tar.gz: b3c5b08e7cb5a0b2383450eced49455176adbd5ac55ce99c45426baacd69611a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8821e04829a448e35da18a8d3c0d6cf5281c82aeaa40a40306e9d504c691554109009cf3ef304c9418e90e5f0768b98bc6e7394c2dfaa05a6baa8365d74eaa10
|
7
|
+
data.tar.gz: 2c78cd652e399426d40065367dbe367c0ae5f7cfb132c1db5d2b8e152bb1d5d779933021d731f9681c46bafc1625ee96bd6857c898ff80242604f7087f832bd5
|
data/FinnhubRB.gemspec
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FinnhubRB
|
1
|
+
FinnhubRB [![Gem Version](https://badge.fury.io/rb/finnhubrb.svg)](https://badge.fury.io/rb/finnhubrb)
|
2
2
|
=========================================================
|
3
3
|
|
4
4
|
[Finnhub](https://finnhub.io/) is an API for retrieving Stock
|
@@ -22,7 +22,7 @@ Then run "rspec spec/test_all.rb".
|
|
22
22
|
|
23
23
|
## Support
|
24
24
|
|
25
|
-
* Without a premium account, testing is hard and I could have missed something. Any bug, suggestions and improvements are more than welcome. Please do not be shy to create issues or pull requests.
|
25
|
+
* Without a premium account, testing is hard and I could have missed something. Any bug, suggestions and improvements are more than welcome. Please do not be shy to create issues or pull requests. Premium features are implemented but untested.
|
26
26
|
* This is a personal project, any stars for giving your support will make a man happy.
|
27
27
|
|
28
28
|
## Client
|
@@ -44,24 +44,49 @@ setup verbose equal to true.
|
|
44
44
|
|
45
45
|
## Stock
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
To analyse a stock you can start by choosing which stock exchange you want to analyse.
|
48
|
+
|
49
|
+
``` ruby
|
50
|
+
client.stock_exchanges # Retrieve the available stock exchanges on Finnhub (Finnhub::Stock_Exchange instances)
|
51
|
+
client.stock_exchanges(plain: true) # As above, but it returns simply the output of the request
|
52
|
+
stock_exchange = client.stock_exchanges(name: "NAME_CRYPTO_EXCHANGE") # Create a single instance of Finnhub::Stock_Exchange
|
53
|
+
```
|
54
|
+
|
55
|
+
After that you can choose in that crypto exchange which symbol you want to check.
|
56
|
+
|
57
|
+
``` ruby
|
58
|
+
stock_exchange.symbols # Retrieve the available stock symbols on the chosen stock exchange (Finnhub::Stock instances)
|
59
|
+
stock_exchange.symbols(plain: true) # As above, but it returns simply the output of the request
|
60
|
+
```
|
61
|
+
|
62
|
+
In alternative you can create a stock instance directly:.
|
49
63
|
|
50
64
|
``` ruby
|
51
65
|
stock = client.stock symbol: "AAPL"
|
52
66
|
```
|
53
67
|
|
68
|
+
Finnhub::Stock is used to manage a stock class.
|
54
69
|
Several methods are available under this class:
|
55
70
|
|
56
71
|
``` ruby
|
57
72
|
stock.symbol # Return the symbol
|
58
73
|
stock.profile # Retrieve profile of the stock
|
74
|
+
stock.profile(isin: "US5949181045") # Retrieve profile of the stock by its isin
|
75
|
+
stock.profile(cusip: "023135106") # Retrieve profile of the stock by its cusip
|
76
|
+
stock.profile # Retrieve profile of the stock
|
59
77
|
stock.ceo_compensation # Retrieve compensation of the stock's CEO
|
78
|
+
stock.executive # Retrieve list of company's executives
|
60
79
|
stock.recommendation # Retrieve recommendation about this stock
|
61
80
|
stock.price_target # Retrieve price target about this stock
|
81
|
+
stock.upgrade_downgrade # Retrieve latest stock upgrade and downgrade
|
62
82
|
stock.option_chain # Retrieve option chain about this stock
|
63
83
|
stock.earnings # Retrieve earnings about this stock
|
84
|
+
stock.metrics # Retrieve key metrics
|
85
|
+
stock.investors # Retrieve full list of investors
|
86
|
+
stock.funds # Retrieve list of fund investors
|
87
|
+
stock.financials # (PREMIUM) Retrieve standardized balances sheet
|
64
88
|
stock.news # Retrieve news about this stock (only US)
|
89
|
+
stock.major_development # Retrieve major development
|
65
90
|
stock.sentiment # Retrieve social sentiment about this stock (only US)
|
66
91
|
stock.peers(plain: true) # Retrieve peers company similar to the one chosen
|
67
92
|
stock.peers # Like the previous one, but the results are Finnhub::Stock instances
|
@@ -77,6 +102,7 @@ To create a timeseries you can use:
|
|
77
102
|
stock.timeseries(resolution: "D") # Resolution is daily "D", alternative are 1, 5, 15, 30, 60, D, W, M) where the numeric one are for minutes (default resolution is "D")
|
78
103
|
stock.timeseries(from: Time.now-24*30*3600, to: Time.now) # Fetch from a date to another date (default from: nil, to: nil)
|
79
104
|
stock.timeseries(format: "json") # Return the output in json or in csv (default format: "json")
|
105
|
+
stock.timeseries(adjusted: true) # Return adjusted data (default false)
|
80
106
|
```
|
81
107
|
|
82
108
|
Remember count and from/to are exclusive. If you use one, you cannot use the other two.
|
@@ -85,7 +111,7 @@ The methods "open", "high", "low", "close", "volume" and "status" will not work
|
|
85
111
|
``` ruby
|
86
112
|
timeseries = stock.timeseries(from: Time.now-24*30*3600, to: Time.now, resolution: 60)
|
87
113
|
timeseries.output # Return output obtained from the request
|
88
|
-
|
114
|
+
timeseries.timestamps # Return timestamps obtained from the request
|
89
115
|
timeseries.open # Return open obtained from the request
|
90
116
|
timeseries.low # Return low obtained from the request
|
91
117
|
timeseries.close # Return close obtained from the request
|
@@ -93,14 +119,35 @@ The methods "open", "high", "low", "close", "volume" and "status" will not work
|
|
93
119
|
timeseries.status # Return status obtained from the request
|
94
120
|
```
|
95
121
|
|
122
|
+
|
123
|
+
(PREMIUM) To manage tick data use:
|
124
|
+
|
125
|
+
``` ruby
|
126
|
+
tick = stock.tick(from: Time.now-24*30*3600, to: Time.now) # Create stick data
|
127
|
+
tick.output # Return output obtained from the request
|
128
|
+
tick.timestamps # Return timestamps obtained from the request
|
129
|
+
tick.price # Return price obtained from the request
|
130
|
+
tick.volume # Return volume obtained from the request
|
131
|
+
tick.status # Return status obtained from the request
|
132
|
+
```
|
133
|
+
|
134
|
+
|
135
|
+
(PREMIUM) To retrieve transcripts you can use:
|
136
|
+
|
137
|
+
``` ruby
|
138
|
+
stock.stock_exchanges # Retrieve the available stock exchanges on Finnhub (Finnhub::Stock_Exchange instances)
|
139
|
+
client.stock_exchanges(plain: true) # As above, but it returns simply the output of the request
|
140
|
+
stock_exchange = client.stock_exchanges(name: "NAME_CRYPTO_EXCHANGE") # Create a single instance of Finnhub::Stock_Exchange
|
141
|
+
```
|
142
|
+
|
96
143
|
## Crypto
|
97
144
|
|
98
145
|
To analyse a crypto currency you should start by choosing which crypto exchange you want to analyse.
|
99
146
|
|
100
147
|
``` ruby
|
101
|
-
client.
|
102
|
-
client.
|
103
|
-
|
148
|
+
client.transcripts # Retrieve the available transcripts on Finnhub (Finnhub::Transcript instances)
|
149
|
+
client.transcripts(plain: true) # As above, but it returns simply the output of the request
|
150
|
+
client.transcripts[0].transcript # Retrieve the specific transcript
|
104
151
|
```
|
105
152
|
|
106
153
|
After that you can choose, in that crypto exchange which symbol you want to check.
|
@@ -175,7 +222,7 @@ Furthermore you can create a timeseries with the same logic used for Stock times
|
|
175
222
|
|
176
223
|
## Merge
|
177
224
|
|
178
|
-
You can retrieve information about company that are merging in relation of a given country.
|
225
|
+
(PREMIUM) You can retrieve information about company that are merging in relation of a given country.
|
179
226
|
|
180
227
|
``` ruby
|
181
228
|
client.merge_countries # Retrieve the available merge countries on Finnhub (Finnhub::Merge_Country instances)
|
data/lib/Client.rb
CHANGED
@@ -48,6 +48,13 @@ module Finnhub
|
|
48
48
|
Finnhub::Websocket.new(@apikey)
|
49
49
|
end
|
50
50
|
|
51
|
+
def stock_exchanges(plain: false)
|
52
|
+
output = request("/stock/exchange")
|
53
|
+
return output if plain
|
54
|
+
|
55
|
+
output.map{|o| Finnhub::Stock_Exchange.new(client: self, code: o[:code], hash: o)}
|
56
|
+
end
|
57
|
+
|
51
58
|
def stock(symbol:)
|
52
59
|
Finnhub::Stock.new(client: self, symbol: symbol)
|
53
60
|
end
|
data/lib/Crypto.rb
CHANGED
data/lib/Stock.rb
CHANGED
@@ -1,22 +1,64 @@
|
|
1
1
|
module Finnhub
|
2
|
+
class Stock_Exchange
|
3
|
+
def initialize(client:, code:, hash:)
|
4
|
+
@client = client
|
5
|
+
@hash = hash
|
6
|
+
@code = code
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :hash, :code
|
10
|
+
|
11
|
+
def symbols(plain: false)
|
12
|
+
output = @client.request("/stock/symbol?exchange=#{@code}")
|
13
|
+
return output if plain
|
14
|
+
|
15
|
+
output.map do |o|
|
16
|
+
Finnhub::Stock.new(client: @client, exchange: @code, **o)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def symbol(**args)
|
21
|
+
Finnhub::Stock.new(client: @client, exchange: @code, **args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
2
26
|
class Stock
|
3
27
|
include Finnhub::Analysis
|
4
28
|
|
5
|
-
def initialize(client:, symbol
|
29
|
+
def initialize(client:, symbol:,
|
30
|
+
displaySymbol: nil, description: nil, exchange: nil)
|
6
31
|
@client = client
|
7
32
|
@symbol = symbol
|
33
|
+
@displaySymbol = displaySymbol
|
34
|
+
@description = description
|
35
|
+
@exchange = exchange
|
8
36
|
end
|
9
37
|
|
10
|
-
attr_reader :symbol
|
38
|
+
attr_reader :symbol, :displaySymbol, :description, :exchange
|
11
39
|
|
12
|
-
def profile
|
13
|
-
|
40
|
+
def profile(isin: nil, cusip: nil)
|
41
|
+
if !isin.nil?
|
42
|
+
string = "isin".freeze
|
43
|
+
symbol = isin
|
44
|
+
elsif !cusip.nil?
|
45
|
+
string = "cusip".freeze
|
46
|
+
symbol = cusip
|
47
|
+
else
|
48
|
+
string = "symbol".freeze
|
49
|
+
symbol = @symbol
|
50
|
+
end
|
51
|
+
@client.request("/stock/profile?#{string}=#{symbol}")
|
14
52
|
end
|
15
53
|
|
16
54
|
def ceo_compensation
|
17
55
|
@client.request("/stock/ceo-compensation?symbol=#{@symbol}")
|
18
56
|
end
|
19
57
|
|
58
|
+
def executive
|
59
|
+
@client.request("/stock/executive?symbol=#{@symbol}")
|
60
|
+
end
|
61
|
+
|
20
62
|
def recommendation
|
21
63
|
@client.request("/stock/recommendation?symbol=#{@symbol}")
|
22
64
|
end
|
@@ -25,6 +67,10 @@ module Finnhub
|
|
25
67
|
@client.request("/stock/price-target?symbol=#{@symbol}")
|
26
68
|
end
|
27
69
|
|
70
|
+
def upgrade_downgrade
|
71
|
+
@client.request("/stock/upgrade-downgrade?symbol=#{@symbol}")
|
72
|
+
end
|
73
|
+
|
28
74
|
def option_chain
|
29
75
|
@client.request("/stock/option-chain?symbol=#{@symbol}")
|
30
76
|
end
|
@@ -36,20 +82,62 @@ module Finnhub
|
|
36
82
|
output.map{|o| Finnhub::Stock.new(client: @client, symbol: o)}
|
37
83
|
end
|
38
84
|
|
39
|
-
def earnings
|
40
|
-
|
85
|
+
def earnings(limit: nil)
|
86
|
+
url = "/stock/earnings?symbol=#{@symbol}"
|
87
|
+
url += "&limit=#{limit}" unless limit.nil?
|
88
|
+
@client.request(url)
|
89
|
+
end
|
90
|
+
|
91
|
+
def metrics(metric: "price")
|
92
|
+
@client.request("/stock/metric?symbol=#{@symbol}&metric=#{metric}")
|
93
|
+
end
|
94
|
+
|
95
|
+
def investors(limit: nil)
|
96
|
+
url = "/stock/investor-ownership?symbol=#{@symbol}"
|
97
|
+
url += "&limit=#{limit}" unless limit.nil?
|
98
|
+
@client.request(url)
|
99
|
+
end
|
100
|
+
|
101
|
+
def funds(limit: nil)
|
102
|
+
url = "/stock/fund-ownership?symbol=#{@symbol}"
|
103
|
+
url += "&limit=#{limit}" unless limit.nil?
|
104
|
+
@client.request(url)
|
105
|
+
end
|
106
|
+
|
107
|
+
def financials(statement: "bs", freq: "annual")
|
108
|
+
@client.request("/stock/financials?symbol=#{@symbol}&statement=#{statement}&freq=#{freq}")
|
109
|
+
end
|
110
|
+
|
111
|
+
def quote
|
112
|
+
@client.request("/quote?symbol=#{@symbol}")
|
41
113
|
end
|
42
114
|
|
43
115
|
def news
|
44
116
|
@client.request("/news/#{@symbol}")
|
45
117
|
end
|
46
118
|
|
119
|
+
def major_development
|
120
|
+
@client.request("/major-development?symbol=#{@symbol}")
|
121
|
+
end
|
122
|
+
|
47
123
|
def sentiment
|
48
124
|
@client.request("/news-sentiment?symbol=#{@symbol}")
|
49
125
|
end
|
50
126
|
|
127
|
+
def transcripts(plain: false)
|
128
|
+
output = @client.request("/stock/transcripts/list?symbol=#{@symbol}")
|
129
|
+
return output if plain
|
130
|
+
|
131
|
+
output[:transcripts].map{|o| Finnhub::Transcript.new(client: self, id: o[:id], hash: o)}
|
132
|
+
end
|
133
|
+
|
51
134
|
def timeseries(**args)
|
52
135
|
Finnhub::Timeseries.new(client: @client, stock: self, **args)
|
53
136
|
end
|
137
|
+
alias :candles :timeseries
|
138
|
+
|
139
|
+
def tick(**args)
|
140
|
+
Finnhub::Tick.new(client: @client, stock: self, **args)
|
141
|
+
end
|
54
142
|
end
|
55
143
|
end
|
data/lib/Tick.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Finnhub
|
2
|
+
class Tick
|
3
|
+
def initialize(client:, stock:, from:, to:)
|
4
|
+
url = "/stock/candle?symbol=#{stock.symbol}"
|
5
|
+
from = from.to_i if from.is_a?(Time)
|
6
|
+
url += "&from=#{from}"
|
7
|
+
to = to.to_i if to.is_a?(Time)
|
8
|
+
@output = client.request(url)
|
9
|
+
if @output.is_a?(Hash) && @output[:s] == "ok"
|
10
|
+
@timestamps = @output[:trades][:t]&.map{|t| Time.strptime(t.to_s,'%L')}
|
11
|
+
else
|
12
|
+
@timestamps = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :output, :timestamps
|
17
|
+
|
18
|
+
def price
|
19
|
+
operation(:p)
|
20
|
+
end
|
21
|
+
|
22
|
+
def volume
|
23
|
+
operation(:v)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def status
|
28
|
+
raise Finnhub::Error message: "Output is not a hash" unless @output.is_a?(Hash)
|
29
|
+
@output[:s]
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def operation(type)
|
35
|
+
raise Finnhub::Error message: "Output is not a hash" unless @output.is_a?(Hash)
|
36
|
+
return [] if @output[:trades][0][type].nil?
|
37
|
+
@timestamps.zip(@output[:trades].map{|t| t[type]})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/Timeseries.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Finnhub
|
2
2
|
class Timeseries
|
3
3
|
def initialize(client:, stock:, resolution: "D", count: 100,
|
4
|
-
from: nil, to: nil, format: nil)
|
4
|
+
from: nil, to: nil, format: nil, adjusted: false)
|
5
5
|
url = "/stock/candle?symbol=#{stock.symbol}&resolution=#{resolution}"
|
6
6
|
url += "&count=#{count}" unless count.nil?
|
7
7
|
from = from.to_i if from.is_a?(Time)
|
@@ -9,9 +9,10 @@ module Finnhub
|
|
9
9
|
to = to.to_i if to.is_a?(Time)
|
10
10
|
url += "&to=#{to}" unless to.nil?
|
11
11
|
url += "&format=#{format}" unless format.nil?
|
12
|
+
url += "&adjusted=#{adjusted}" if adjusted
|
12
13
|
@output = client.request(url)
|
13
14
|
if @output.is_a?(Hash) && @output[:s] == "ok"
|
14
|
-
@timestamps = @output[:t]&.map{|t|
|
15
|
+
@timestamps = @output[:t]&.map{|t| Time.strptime(t.to_s,'%s')}
|
15
16
|
else
|
16
17
|
@timestamps = []
|
17
18
|
end
|
data/lib/Transcript.rb
ADDED
data/spec/1.0.0/stock.rb
CHANGED
@@ -44,7 +44,7 @@ describe "1.0.0" do
|
|
44
44
|
|
45
45
|
it "can retrieve a peers" do
|
46
46
|
output = @store[:stock].peers(plain: true)
|
47
|
-
expect(output).to include "
|
47
|
+
expect(output).to include "AAPL"
|
48
48
|
|
49
49
|
output2 = @store[:stock].peers[0].profile
|
50
50
|
expect(output2[:ticker]).to eq output[0]
|
@@ -69,7 +69,7 @@ describe "1.0.0" do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "can retrieve timeseries" do
|
72
|
-
timeseries = @store[:stock].timeseries(count: 100)
|
72
|
+
timeseries = @store[:stock].timeseries(count: 100, adjusted: true)
|
73
73
|
expect(timeseries.open.class).to be Array
|
74
74
|
expect(timeseries.high.class).to be Array
|
75
75
|
expect(timeseries.low.class).to be Array
|
data/spec/1.1.0/stock.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe "1.1.0" do
|
4
|
+
context "Stock" do
|
5
|
+
it "create a new client" do
|
6
|
+
@store[:client] = Finnhub::Client.new(key: @key, verbose: true)
|
7
|
+
expect(@store[:client].class).to be Finnhub::Client
|
8
|
+
end
|
9
|
+
|
10
|
+
it "retrieve stock exchanges" do
|
11
|
+
@store[:stock] = @store[:client].stock_exchanges
|
12
|
+
symbols = @store[:stock].map{|s| s.code}
|
13
|
+
expect(symbols).to include "US"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "retrieve symbols from stock exchanges" do
|
17
|
+
symbols = @store[:stock][0].symbols
|
18
|
+
expect(symbols[0].exchange).to eq @store[:stock][0].code
|
19
|
+
end
|
20
|
+
|
21
|
+
it "create a new stock" do
|
22
|
+
@store[:stock] = @store[:client].stock(symbol: "AAPL")
|
23
|
+
expect(@store[:stock].symbol).to eq "AAPL"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can retrieve a executive" do
|
27
|
+
output = @store[:stock].executive
|
28
|
+
|
29
|
+
expect(output[:symbol]).to eq "AAPL"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can retrieve a upgrade_downgrade" do
|
33
|
+
output = @store[:stock].upgrade_downgrade
|
34
|
+
|
35
|
+
expect(output[:symbol]).to eq "AAPL"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can retrieve metrics" do
|
39
|
+
output = @store[:stock].metrics
|
40
|
+
|
41
|
+
expect(output[:symbol]).to eq "AAPL"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can retrieve investors" do
|
45
|
+
output = @store[:stock].investors
|
46
|
+
|
47
|
+
expect(output[:symbol]).to eq "AAPL"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "can retrieve funds" do
|
51
|
+
output = @store[:stock].funds
|
52
|
+
|
53
|
+
expect(output[:symbol]).to eq "AAPL"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "can retrieve financials" do
|
57
|
+
skip "Premium" if @skip_premium
|
58
|
+
output = @store[:stock].financials
|
59
|
+
|
60
|
+
expect(output[:symbol]).to eq "AAPL"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can retrieve quote" do
|
64
|
+
skip "Premium" if @skip_premium
|
65
|
+
output = @store[:stock].quote
|
66
|
+
|
67
|
+
expect(output[:symbol]).to eq "AAPL"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "can retrieve major_development" do
|
71
|
+
output = @store[:stock].major_development
|
72
|
+
|
73
|
+
expect(output[:symbol]).to eq "AAPL"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "can retrieve transcripts" do
|
77
|
+
skip "Premium" if @skip_premium
|
78
|
+
output = @store[:stock].transcripts
|
79
|
+
|
80
|
+
expect(output[:symbol]).to eq "AAPL"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "can retrieve tick" do
|
84
|
+
skip "Premium" if @skip_premium
|
85
|
+
output = @store[:stock].tick(from: Time.now-24*30*3600, to: Time.now)
|
86
|
+
|
87
|
+
expect(output[:symbol]).to eq "AAPL"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/spec/all.rb
CHANGED
data/spec/config.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
key:
|
1
|
+
key: bn0s9fvrh5r8qh5rphq0
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
require "rspec"
|
2
2
|
require "pry-byebug"
|
3
3
|
require "yaml"
|
4
|
-
|
5
|
-
require "finnhubrb"
|
6
|
-
require "openssl"
|
7
|
-
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
4
|
+
require_relative "../lib/finnhub"
|
8
5
|
|
9
6
|
RSpec.configure do |config|
|
10
7
|
config.color = true
|
11
8
|
config.before(:all) do
|
12
9
|
val = YAML.load_file("#{__dir__}/config.yml")
|
13
10
|
@key = val["key"]
|
11
|
+
@skip_premium = val["skip_premium"].nil? ? true : val["skip_premium"]
|
14
12
|
@store = {}
|
15
13
|
end
|
16
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finnhubrb
|
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: 2020-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -164,14 +164,17 @@ files:
|
|
164
164
|
- lib/Error.rb
|
165
165
|
- lib/Forex.rb
|
166
166
|
- lib/Stock.rb
|
167
|
+
- lib/Tick.rb
|
167
168
|
- lib/Timeseries.rb
|
169
|
+
- lib/Transcript.rb
|
168
170
|
- lib/Websocket.rb
|
169
|
-
- lib/
|
171
|
+
- lib/finnhub.rb
|
170
172
|
- spec/1.0.0/crypto.rb
|
171
173
|
- spec/1.0.0/forex.rb
|
172
174
|
- spec/1.0.0/other.rb
|
173
175
|
- spec/1.0.0/stock.rb
|
174
176
|
- spec/1.0.0/websocket.rb
|
177
|
+
- spec/1.1.0/stock.rb
|
175
178
|
- spec/all.rb
|
176
179
|
- spec/config.yml
|
177
180
|
- spec/spec_helper.rb
|
@@ -195,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
198
|
- !ruby/object:Gem::Version
|
196
199
|
version: '0'
|
197
200
|
requirements: []
|
198
|
-
rubygems_version: 3.0.
|
201
|
+
rubygems_version: 3.0.6
|
199
202
|
signing_key:
|
200
203
|
specification_version: 4
|
201
204
|
summary: A gem for Alpha Vantage
|