finnhubrb 1.1.0 → 1.2.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/FinnhubRB.gemspec +9 -10
- data/README.md +49 -12
- data/lib/Calendar.rb +8 -2
- data/lib/Client.rb +28 -6
- data/lib/Country.rb +4 -2
- data/lib/Crypto.rb +3 -0
- data/lib/Economic.rb +3 -3
- data/lib/Forex.rb +3 -0
- data/lib/Indicator.rb +60 -0
- data/lib/Stock.rb +46 -2
- data/lib/Webhook.rb +23 -0
- data/lib/finnhub.rb +2 -0
- data/spec/1.0.0/other.rb +2 -1
- data/spec/1.0.0/stock.rb +2 -4
- data/spec/1.2.0/stock.rb +40 -0
- data/spec/1.2.0/webhook.rb +25 -0
- data/spec/spec_helper.rb +1 -1
- metadata +8 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 383edf0d15e683c1a6e52bbce6c6b0756a6fdbafee0061390d0b693b5da18a00
|
4
|
+
data.tar.gz: 34e0be3ce7451d96205052b310d11bd735a2f8d5579427c510a2b2edbbbf6902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25531899c47cdd8047bc39b2d71e2c71e86a84d94f9332b62aae32499bc60e09de3915065e878f21227c447956addfb8552935d13c6385c9b8fec8b2a3978b8f
|
7
|
+
data.tar.gz: 3702050c29d90930df21f4eb4e68d2ae96bab96bf5009c425989ed4583a7dba28817589dbc02080dda8d3219de6ae319083b2de029c6334e5d3c4120a10046ae
|
data/FinnhubRB.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# lib = File.expand_path("../lib", __FILE__)
|
2
2
|
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "rake"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "finnhubrb"
|
7
|
-
s.version = "1.
|
6
|
+
s.version = "1.2.0"
|
8
7
|
s.authors = ["Stefano Martin"]
|
9
8
|
s.email = ["stefano.martin87@gmail.com"]
|
10
9
|
s.homepage = "https://github.com/StefanoMartin/FinnhubRB"
|
@@ -13,12 +12,12 @@ Gem::Specification.new do |s|
|
|
13
12
|
s.description = "A ruby wrapper for Finnhub's HTTP API"
|
14
13
|
s.platform = Gem::Platform::RUBY
|
15
14
|
s.require_paths = ["lib"]
|
16
|
-
s.files =
|
17
|
-
s.add_runtime_dependency "httparty", "
|
18
|
-
s.add_runtime_dependency "oj",
|
19
|
-
s.add_runtime_dependency "faye-websocket", "
|
20
|
-
s.add_development_dependency "pry-byebug"
|
21
|
-
s.add_development_dependency "rspec", "
|
22
|
-
s.add_development_dependency "awesome_print",
|
23
|
-
s.add_development_dependency "eventmachine", "
|
15
|
+
s.files = Dir["lib/*"] + Dir["spec/**/*"] + ["FinnhubRB.gemspec", "Gemfile", "LICENSE.md", "README.md"]
|
16
|
+
s.add_runtime_dependency "httparty", ">= 0.17.0"
|
17
|
+
s.add_runtime_dependency "oj",">= 3.9.0"
|
18
|
+
s.add_runtime_dependency "faye-websocket", ">= 0.10.9"
|
19
|
+
s.add_development_dependency "pry-byebug"
|
20
|
+
s.add_development_dependency "rspec", ">=3.5"
|
21
|
+
s.add_development_dependency "awesome_print", ">= 1.7"
|
22
|
+
s.add_development_dependency "eventmachine", ">= 1.2.7"
|
24
23
|
end
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ on the [HTTP API of Finnhub](https://finnhub.io/docs/api).
|
|
8
8
|
|
9
9
|
To install FinnhubRB: `gem install finnhubrb`
|
10
10
|
|
11
|
-
To use it in your application: `require "
|
11
|
+
To use it in your application: `require "finnhub"`
|
12
12
|
|
13
13
|
## How to test
|
14
14
|
|
@@ -70,10 +70,9 @@ Several methods are available under this class:
|
|
70
70
|
|
71
71
|
``` ruby
|
72
72
|
stock.symbol # Return the symbol
|
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
|
73
|
+
stock.profile # (PREMIUM) Retrieve profile of the stock
|
74
|
+
stock.profile(isin: "US5949181045") # (PREMIUM) Retrieve profile of the stock by its isin
|
75
|
+
stock.profile(cusip: "023135106") # (PREMIUM) Retrieve profile of the stock by its cusip
|
77
76
|
stock.ceo_compensation # Retrieve compensation of the stock's CEO
|
78
77
|
stock.executive # Retrieve list of company's executives
|
79
78
|
stock.recommendation # Retrieve recommendation about this stock
|
@@ -92,7 +91,12 @@ Several methods are available under this class:
|
|
92
91
|
stock.peers # Like the previous one, but the results are Finnhub::Stock instances
|
93
92
|
stock.pattern # Retrieve pattern
|
94
93
|
stock.support_resistance # Retrieve support resistance
|
95
|
-
stock.technical_indicators # Retrieve
|
94
|
+
stock.technical_indicators # Retrieve technical indicators
|
95
|
+
stock.revenue_estimate # Retrieve revenue estimate
|
96
|
+
stock.earnings_estimate # Retrieve earnings estimate
|
97
|
+
stock.earnings_calendar # Retrieve earnings calendar (you can add from and to)
|
98
|
+
stock.dividends(from: Time.now-24*30*3600, to: Time.now) # Retrieve dividends
|
99
|
+
stock.splits(from: Time.now-24*30*3600, to: Time.now) # Retrieve splits
|
96
100
|
```
|
97
101
|
|
98
102
|
To create a timeseries you can use:
|
@@ -135,9 +139,22 @@ The methods "open", "high", "low", "close", "volume" and "status" will not work
|
|
135
139
|
(PREMIUM) To retrieve transcripts you can use:
|
136
140
|
|
137
141
|
``` ruby
|
138
|
-
|
139
|
-
|
140
|
-
|
142
|
+
client.transcripts # Retrieve the available transcripts on Finnhub (Finnhub::Transcript instances)
|
143
|
+
client.transcripts(plain: true) # As above, but it returns simply the output of the request
|
144
|
+
client.transcripts[0].transcript # Retrieve the specific transcript
|
145
|
+
```
|
146
|
+
|
147
|
+
To handle indicators you can do:
|
148
|
+
``` ruby
|
149
|
+
timeseries = stock.indicator(from: Time.now-24*30*3600, to: Time.now, resolution: 60, indicator: "sma", args: {timeperiod: 3})
|
150
|
+
timeseries.sma # Return technical values (in this case is sma since the indicator)
|
151
|
+
timeseries.output # Return output obtained from the request
|
152
|
+
timeseries.timestamps # Return timestamps obtained from the request
|
153
|
+
timeseries.open # Return open obtained from the request
|
154
|
+
timeseries.low # Return low obtained from the request
|
155
|
+
timeseries.close # Return close obtained from the request
|
156
|
+
timeseries.volume # Return volume obtained from the request
|
157
|
+
timeseries.status # Return status obtained from the request
|
141
158
|
```
|
142
159
|
|
143
160
|
## Crypto
|
@@ -145,9 +162,9 @@ The methods "open", "high", "low", "close", "volume" and "status" will not work
|
|
145
162
|
To analyse a crypto currency you should start by choosing which crypto exchange you want to analyse.
|
146
163
|
|
147
164
|
``` ruby
|
148
|
-
client.
|
149
|
-
client.
|
150
|
-
client.
|
165
|
+
client.crypto_exchanges # Retrieve the available crypto exchanges on Finnhub (Finnhub::Crypto_Exchange instances)
|
166
|
+
client.crypto_exchanges(plain: true) # As above, but it returns simply the output of the request
|
167
|
+
crypto_exchange = client.crypto_exchange(name: "NAME_CRYPTO_EXCHANGE") # Create a single instance of Finnhub::Crypto_Exchange
|
151
168
|
```
|
152
169
|
|
153
170
|
After that you can choose, in that crypto exchange which symbol you want to check.
|
@@ -279,6 +296,26 @@ websocket.unsubscribe("AAPL") # Unubscribe to a stock
|
|
279
296
|
|
280
297
|
The symbol under subscribe/unsubscribe can be a string of a stock, a crypto_symbol or a forex_symbol. Or in alternative can be a Finnhub::Stock, Finnhub::Crypto_Symbol, or a Finnhub::Forex_Symbol instance.
|
281
298
|
|
299
|
+
# Webhook
|
300
|
+
|
301
|
+
You can manage the webhook in the following way.
|
302
|
+
|
303
|
+
``` ruby
|
304
|
+
webhook = client.webhook # Instantiate a webhook
|
305
|
+
webhook.create(body: {'event': 'earnings', 'symbol': 'AAPL'}) # Create a new webhook
|
306
|
+
webhook.id #Retrieve id of the webhook
|
307
|
+
client.webhooks # List webhooks
|
308
|
+
client.webhooks(plain: true) # As above, but it returns simply the output of the request
|
309
|
+
webhook.delete # Delete webhook
|
310
|
+
|
311
|
+
```
|
312
|
+
|
313
|
+
## Other
|
314
|
+
|
315
|
+
``` ruby
|
316
|
+
client.covid # Retrieve United States Covid-19 info
|
317
|
+
```
|
318
|
+
|
282
319
|
## Errors
|
283
320
|
|
284
321
|
Error from FinnhubRB are returned under Finnhub::Error exception. You can use e.code to retrieve the code returned to a not successful request.
|
data/lib/Calendar.rb
CHANGED
@@ -4,8 +4,14 @@ module Finnhub
|
|
4
4
|
request("/calendar/economic")
|
5
5
|
end
|
6
6
|
|
7
|
-
def earnings_calendar
|
8
|
-
|
7
|
+
def earnings_calendar(from: nil, to: nil)
|
8
|
+
url = "/calendar/earnings?"
|
9
|
+
from = from.to_date.to_s if from.is_a?(Time)
|
10
|
+
url += "&from=#{from}" unless from.nil?
|
11
|
+
to = to.to_date.to_s if to.is_a?(Time)
|
12
|
+
url += "&to=#{to}" unless to.nil?
|
13
|
+
url[-1] = "" if url[-1] == "?"
|
14
|
+
request(url)
|
9
15
|
end
|
10
16
|
|
11
17
|
def ipo_calendar
|
data/lib/Client.rb
CHANGED
@@ -12,13 +12,20 @@ module Finnhub
|
|
12
12
|
attr_accessor :verbose
|
13
13
|
attr_reader :apikey
|
14
14
|
|
15
|
-
def request(url)
|
15
|
+
def request(url, method: :get, body: nil)
|
16
16
|
send_url = "#{BASE_URI}#{url}"
|
17
17
|
send_url += send_url.include?("?") ? "&" : "?"
|
18
18
|
send_url += "token=#{@apikey}"
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
case method
|
21
|
+
when :get
|
22
|
+
puts "\nGET #{send_url}\n" if @verbose
|
23
|
+
response = HTTParty.get(send_url)
|
24
|
+
when :post
|
25
|
+
puts "\nPOST #{send_url}, body: #{body}\n" if @verbose
|
26
|
+
response = HTTParty.post(send_url, body: Oj.dump(body, mode: :json))
|
27
|
+
end
|
28
|
+
|
22
29
|
if @verbose
|
23
30
|
puts "\nCODE: #{response.code}\n"
|
24
31
|
puts "OUTPUT: #{response.body}\n"
|
@@ -48,6 +55,17 @@ module Finnhub
|
|
48
55
|
Finnhub::Websocket.new(@apikey)
|
49
56
|
end
|
50
57
|
|
58
|
+
def webhook
|
59
|
+
Finnhub::Webhook.new(client: self)
|
60
|
+
end
|
61
|
+
|
62
|
+
def webhooks(plain: false)
|
63
|
+
output = request("/webhook/list")
|
64
|
+
return output if plain
|
65
|
+
|
66
|
+
output.map{|o| Finnhub::Webhook.new(client: self, id: o[:id], hash: o)}
|
67
|
+
end
|
68
|
+
|
51
69
|
def stock_exchanges(plain: false)
|
52
70
|
output = request("/stock/exchange")
|
53
71
|
return output if plain
|
@@ -102,12 +120,16 @@ module Finnhub
|
|
102
120
|
output = request("/economic/code")
|
103
121
|
return output if plain
|
104
122
|
|
105
|
-
output.map{|o| Finnhub::Economic_Code.new(client: self, code: o[
|
123
|
+
output.map{|o| Finnhub::Economic_Code.new(client: self, code: o[:code], hash: o)}
|
106
124
|
end
|
107
125
|
|
108
|
-
def economic_code(code:,
|
126
|
+
def economic_code(code:, hash: nil)
|
109
127
|
Finnhub::Economic_Code.new(client: self, code: code,
|
110
|
-
|
128
|
+
hash: hash)
|
129
|
+
end
|
130
|
+
|
131
|
+
def covid
|
132
|
+
request("/covid19/us")
|
111
133
|
end
|
112
134
|
end
|
113
135
|
end
|
data/lib/Country.rb
CHANGED
@@ -9,8 +9,10 @@ module Finnhub
|
|
9
9
|
|
10
10
|
def merger(from: nil, to: nil)
|
11
11
|
url = "/merger?country=#{@country}"
|
12
|
-
|
13
|
-
url += "&
|
12
|
+
from = from.to_date.to_s if from.is_a?(Time)
|
13
|
+
url += "&from=#{from}"
|
14
|
+
to = to.to_date.to_s if to.is_a?(Time)
|
15
|
+
url += "&to=#{to}"
|
14
16
|
@client.request(url)
|
15
17
|
end
|
16
18
|
end
|
data/lib/Crypto.rb
CHANGED
@@ -38,6 +38,7 @@ module Finnhub
|
|
38
38
|
def timeseries(**args)
|
39
39
|
Finnhub::Crypto_Timeseries.new(client: @client, symbol: @symbol, **args)
|
40
40
|
end
|
41
|
+
alias :candles :timeseries
|
41
42
|
end
|
42
43
|
|
43
44
|
class Crypto_Timeseries < Finnhub::Timeseries
|
@@ -45,7 +46,9 @@ module Finnhub
|
|
45
46
|
from: nil, to: nil, format: nil)
|
46
47
|
url = "/crypto/candle?symbol=#{symbol}&resolution=#{resolution}"
|
47
48
|
url += "&count=#{count}" unless count.nil?
|
49
|
+
from = from.to_i if from.is_a?(Time)
|
48
50
|
url += "&from=#{from}" unless from.nil?
|
51
|
+
to = to.to_i if to.is_a?(Time)
|
49
52
|
url += "&to=#{to}" unless to.nil?
|
50
53
|
url += "&format=#{format}" unless format.nil?
|
51
54
|
@output = client.request(url)
|
data/lib/Economic.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Finnhub
|
2
2
|
class Economic_Code
|
3
|
-
def initialize(client:, code:,
|
3
|
+
def initialize(client:, code:, hash:)
|
4
4
|
@client = client
|
5
5
|
@code = code
|
6
|
-
@
|
6
|
+
@hash = hash
|
7
7
|
end
|
8
8
|
|
9
|
-
attr_reader :code, :
|
9
|
+
attr_reader :code, :hash
|
10
10
|
|
11
11
|
def data(plain: false)
|
12
12
|
output = @client.request("/economic?code=#{@code}")
|
data/lib/Forex.rb
CHANGED
@@ -38,6 +38,7 @@ module Finnhub
|
|
38
38
|
def timeseries(**args)
|
39
39
|
Finnhub::Forex_Timeseries.new(client: @client, symbol: @symbol, **args)
|
40
40
|
end
|
41
|
+
alias :candles :timeseries
|
41
42
|
end
|
42
43
|
|
43
44
|
class Forex_Timeseries < Finnhub::Timeseries
|
@@ -45,7 +46,9 @@ module Finnhub
|
|
45
46
|
from: nil, to: nil, format: nil)
|
46
47
|
url = "/forex/candle?symbol=#{symbol}&resolution=#{resolution}"
|
47
48
|
url += "&count=#{count}" unless count.nil?
|
49
|
+
from = from.to_i if from.is_a?(Time)
|
48
50
|
url += "&from=#{from}" unless from.nil?
|
51
|
+
to = to.to_i if to.is_a?(Time)
|
49
52
|
url += "&to=#{to}" unless to.nil?
|
50
53
|
url += "&format=#{format}" unless format.nil?
|
51
54
|
@output = client.request(url)
|
data/lib/Indicator.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Finnhub
|
2
|
+
class Indicator
|
3
|
+
def initialize(client:, stock:, resolution: "D", from:, to:, indicator:, args: {})
|
4
|
+
url = "/indicator?symbol=#{stock.symbol}&resolution=#{resolution}"
|
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
|
+
url += "&to=#{to}"
|
9
|
+
url += "&indicator=#{indicator}"
|
10
|
+
args.each do |attribute, value|
|
11
|
+
url += "&#{attribute}=#{value}"
|
12
|
+
end
|
13
|
+
@output = client.request(url)
|
14
|
+
if @output.is_a?(Hash) && @output[:s] == "ok"
|
15
|
+
@timestamps = @output[:t]&.map{|t| Time.strptime(t.to_s,'%s')}
|
16
|
+
else
|
17
|
+
@timestamps = []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :output, :timestamps
|
22
|
+
|
23
|
+
def open
|
24
|
+
operation(:o)
|
25
|
+
end
|
26
|
+
|
27
|
+
def high
|
28
|
+
operation(:h)
|
29
|
+
end
|
30
|
+
|
31
|
+
def low
|
32
|
+
operation(:l)
|
33
|
+
end
|
34
|
+
|
35
|
+
def close
|
36
|
+
operation(:c)
|
37
|
+
end
|
38
|
+
|
39
|
+
def volume
|
40
|
+
operation(:v)
|
41
|
+
end
|
42
|
+
|
43
|
+
def status
|
44
|
+
raise Finnhub::Error message: "Output is not a hash" unless @output.is_a?(Hash)
|
45
|
+
@output[:s]
|
46
|
+
end
|
47
|
+
|
48
|
+
def method_missing(name, *args, &block)
|
49
|
+
operation(name.to_sym)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def operation(type)
|
55
|
+
raise Finnhub::Error message: "Output is not a hash" unless @output.is_a?(Hash)
|
56
|
+
return [] if @output[type].nil?
|
57
|
+
@timestamps.zip(@output[type])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/Stock.rb
CHANGED
@@ -116,14 +116,54 @@ module Finnhub
|
|
116
116
|
@client.request("/news/#{@symbol}")
|
117
117
|
end
|
118
118
|
|
119
|
-
def major_development
|
120
|
-
|
119
|
+
def major_development(from: nil, to: nil)
|
120
|
+
url = "/major-development?symbol=#{@symbol}"
|
121
|
+
from = from.to_date.to_s if from.is_a?(Time)
|
122
|
+
url += "&from=#{from}" unless from.nil?
|
123
|
+
to = to.to_date.to_s if to.is_a?(Time)
|
124
|
+
url += "&to=#{to}" unless to.nil?
|
125
|
+
@client.request(url)
|
121
126
|
end
|
122
127
|
|
123
128
|
def sentiment
|
124
129
|
@client.request("/news-sentiment?symbol=#{@symbol}")
|
125
130
|
end
|
126
131
|
|
132
|
+
def revenue_estimate
|
133
|
+
@client.request("/stock/revenue-estimate?symbol=#{@symbol}")
|
134
|
+
end
|
135
|
+
|
136
|
+
def earnings_estimate
|
137
|
+
@client.request("/stock/eps-estimate?symbol=#{@symbol}")
|
138
|
+
end
|
139
|
+
|
140
|
+
def earnings_calendar(from: nil, to: nil)
|
141
|
+
url = "/calendar/earnings?symbol=#{@symbol}"
|
142
|
+
from = from.to_date.to_s if from.is_a?(Time)
|
143
|
+
url += "&from=#{from}" unless from.nil?
|
144
|
+
to = to.to_date.to_s if to.is_a?(Time)
|
145
|
+
url += "&to=#{to}" unless to.nil?
|
146
|
+
@client.request(url)
|
147
|
+
end
|
148
|
+
|
149
|
+
def dividends(from:, to:)
|
150
|
+
url = "/stock/dividend?symbol=#{@symbol}"
|
151
|
+
from = from.to_date.to_s if from.is_a?(Time)
|
152
|
+
url += "&from=#{from}"
|
153
|
+
to = to.to_date.to_s if to.is_a?(Time)
|
154
|
+
url += "&to=#{to}"
|
155
|
+
@client.request(url)
|
156
|
+
end
|
157
|
+
|
158
|
+
def splits(from:, to:)
|
159
|
+
url = "/stock/split?symbol=#{@symbol}"
|
160
|
+
from = from.to_date.to_s if from.is_a?(Time)
|
161
|
+
url += "&from=#{from}"
|
162
|
+
to = to.to_date.to_s if to.is_a?(Time)
|
163
|
+
url += "&to=#{to}"
|
164
|
+
@client.request(url)
|
165
|
+
end
|
166
|
+
|
127
167
|
def transcripts(plain: false)
|
128
168
|
output = @client.request("/stock/transcripts/list?symbol=#{@symbol}")
|
129
169
|
return output if plain
|
@@ -139,5 +179,9 @@ module Finnhub
|
|
139
179
|
def tick(**args)
|
140
180
|
Finnhub::Tick.new(client: @client, stock: self, **args)
|
141
181
|
end
|
182
|
+
|
183
|
+
def indicator(**args)
|
184
|
+
Finnhub::Indicator.new(client: @client, stock: self, **args)
|
185
|
+
end
|
142
186
|
end
|
143
187
|
end
|
data/lib/Webhook.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Finnhub
|
2
|
+
class Webhook
|
3
|
+
def initialize(client:, id: nil, hash: nil)
|
4
|
+
@client = client
|
5
|
+
@id = id
|
6
|
+
@hash = hash
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :id, :hash
|
10
|
+
|
11
|
+
def create(body:)
|
12
|
+
response = @client.request("/webhook/add", method: :post, body: body)
|
13
|
+
@id = response[:id]
|
14
|
+
response
|
15
|
+
end
|
16
|
+
|
17
|
+
def delete
|
18
|
+
response = @client.request("/webhook/delete", method: :post, body: {id: @id})
|
19
|
+
@id = nil
|
20
|
+
response
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/finnhub.rb
CHANGED
@@ -4,6 +4,7 @@ require "time"
|
|
4
4
|
require 'em/pure_ruby'
|
5
5
|
require "faye/websocket"
|
6
6
|
require_relative "Analysis"
|
7
|
+
require_relative "Indicator"
|
7
8
|
require_relative "Calendar"
|
8
9
|
require_relative "Timeseries"
|
9
10
|
require_relative "Client"
|
@@ -16,3 +17,4 @@ require_relative "Stock"
|
|
16
17
|
require_relative "Websocket"
|
17
18
|
require_relative "Tick"
|
18
19
|
require_relative "Transcript"
|
20
|
+
require_relative "Webhook"
|
data/spec/1.0.0/other.rb
CHANGED
@@ -22,6 +22,7 @@ describe "1.0.0" do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "can retrieve merge countries" do
|
25
|
+
skip "Premium" if @skip_premium
|
25
26
|
country = @store[:client].merge_country(country: @store[:country])
|
26
27
|
mergers = country.merger
|
27
28
|
expect(mergers[0][:targetNation]).to eq @store[:country]
|
@@ -30,7 +31,7 @@ describe "1.0.0" do
|
|
30
31
|
it "can retrieve economic codes" do
|
31
32
|
output = @store[:client].economic_codes(plain: true)
|
32
33
|
expect(output.size).to be > 100
|
33
|
-
@store[:economic_code] = output[0][
|
34
|
+
@store[:economic_code] = output[0][:code]
|
34
35
|
|
35
36
|
output = @store[:client].economic_codes
|
36
37
|
expect(output[0].class).to be Finnhub::Economic_Code
|
data/spec/1.0.0/stock.rb
CHANGED
@@ -13,6 +13,7 @@ describe "1.0.0" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "can retrieve a profile" do
|
16
|
+
skip "Premium" if @skip_premium
|
16
17
|
output = @store[:stock].profile
|
17
18
|
|
18
19
|
expect(output[:ticker]).to eq "AAPL"
|
@@ -45,9 +46,6 @@ describe "1.0.0" do
|
|
45
46
|
it "can retrieve a peers" do
|
46
47
|
output = @store[:stock].peers(plain: true)
|
47
48
|
expect(output).to include "AAPL"
|
48
|
-
|
49
|
-
output2 = @store[:stock].peers[0].profile
|
50
|
-
expect(output2[:ticker]).to eq output[0]
|
51
49
|
end
|
52
50
|
|
53
51
|
it "can retrieve a earnings" do
|
@@ -59,7 +57,7 @@ describe "1.0.0" do
|
|
59
57
|
it "can retrieve a news" do
|
60
58
|
output = @store[:stock].news
|
61
59
|
|
62
|
-
expect(output[0][:related]).to
|
60
|
+
expect(output[0][:related]).to include "AAPL"
|
63
61
|
end
|
64
62
|
|
65
63
|
it "can retrieve a sentiment" do
|
data/spec/1.2.0/stock.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe "1.2.0" do
|
4
|
+
context "Client" do
|
5
|
+
it "can retrieve information about Covid-19" do
|
6
|
+
@store[:client] = Finnhub::Client.new(key: @key, verbose: true)
|
7
|
+
output = @store[:client].covid
|
8
|
+
expect(output.size).to be >= 50
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "Stock" do
|
13
|
+
it "retrieve estimate" do
|
14
|
+
@store[:stock] = @store[:client].stock(symbol: "AAPL")
|
15
|
+
response = @store[:stock].revenue_estimate
|
16
|
+
expect(response[:symbol]).to eq "AAPL"
|
17
|
+
|
18
|
+
response = @store[:stock].earnings_estimate
|
19
|
+
expect(response[:symbol]).to eq "AAPL"
|
20
|
+
|
21
|
+
response = @store[:stock].earnings_calendar(from: Time.now-24*3600*365, to: Time.now)
|
22
|
+
expect(response[:earningsCalendar].size).to be >= 1
|
23
|
+
end
|
24
|
+
|
25
|
+
it "retrieve dividends and splits" do
|
26
|
+
response = @store[:stock].dividends(from: Time.now-24*3600*365, to: Time.now)
|
27
|
+
expect(response.size).to be >= 1
|
28
|
+
|
29
|
+
response = @store[:stock].splits(from: Time.now-10*24*3600*365, to: Time.now)
|
30
|
+
expect(response.size).to be >= 1
|
31
|
+
end
|
32
|
+
|
33
|
+
it "can use indicators" do
|
34
|
+
indicator = @store[:stock].indicator(from: Time.now-24*30*3600, to: Time.now, resolution: 60, indicator: "sma", args: {timeperiod: 3})
|
35
|
+
expect(indicator.sma.size).to be >= 1
|
36
|
+
expect(indicator.o).to eq indicator.open
|
37
|
+
expect(indicator.ciao).to eq []
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe "1.2.0" do
|
4
|
+
context "Webhook" do
|
5
|
+
it "can create webhook" do
|
6
|
+
@store[:client] = Finnhub::Client.new(key: @key, verbose: true)
|
7
|
+
@store[:webhook] = @store[:client].webhook
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can add a webhook" do
|
11
|
+
@store[:webhook].create(body: {'event': 'earnings', 'symbol': 'AAPL'})
|
12
|
+
expect(@store[:webhook].id).not_to be nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can list webhooks" do
|
16
|
+
webhooks = @store[:client].webhooks
|
17
|
+
expect(webhooks[0].id).to eq @store[:webhook].id
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can delete a webhook" do
|
21
|
+
@store[:webhook].delete
|
22
|
+
expect(@store[:webhook].id).to eq nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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.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: 2020-
|
11
|
+
date: 2020-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.17.0
|
20
|
-
- - "~>"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.17.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.17.0
|
30
|
-
- - "~>"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.17.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: oj
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -37,9 +31,6 @@ dependencies:
|
|
37
31
|
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: 3.9.0
|
40
|
-
- - "~>"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 3.9.0
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,9 +38,6 @@ dependencies:
|
|
47
38
|
- - ">="
|
48
39
|
- !ruby/object:Gem::Version
|
49
40
|
version: 3.9.0
|
50
|
-
- - "~>"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 3.9.0
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: faye-websocket
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,9 +45,6 @@ dependencies:
|
|
57
45
|
- - ">="
|
58
46
|
- !ruby/object:Gem::Version
|
59
47
|
version: 0.10.9
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.10.9
|
63
48
|
type: :runtime
|
64
49
|
prerelease: false
|
65
50
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -67,21 +52,18 @@ dependencies:
|
|
67
52
|
- - ">="
|
68
53
|
- !ruby/object:Gem::Version
|
69
54
|
version: 0.10.9
|
70
|
-
- - "~>"
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 0.10.9
|
73
55
|
- !ruby/object:Gem::Dependency
|
74
56
|
name: pry-byebug
|
75
57
|
requirement: !ruby/object:Gem::Requirement
|
76
58
|
requirements:
|
77
|
-
- - "
|
59
|
+
- - ">="
|
78
60
|
- !ruby/object:Gem::Version
|
79
61
|
version: '0'
|
80
62
|
type: :development
|
81
63
|
prerelease: false
|
82
64
|
version_requirements: !ruby/object:Gem::Requirement
|
83
65
|
requirements:
|
84
|
-
- - "
|
66
|
+
- - ">="
|
85
67
|
- !ruby/object:Gem::Version
|
86
68
|
version: '0'
|
87
69
|
- !ruby/object:Gem::Dependency
|
@@ -91,9 +73,6 @@ dependencies:
|
|
91
73
|
- - ">="
|
92
74
|
- !ruby/object:Gem::Version
|
93
75
|
version: '3.5'
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.5'
|
97
76
|
type: :development
|
98
77
|
prerelease: false
|
99
78
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -101,9 +80,6 @@ dependencies:
|
|
101
80
|
- - ">="
|
102
81
|
- !ruby/object:Gem::Version
|
103
82
|
version: '3.5'
|
104
|
-
- - "~>"
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
version: '3.5'
|
107
83
|
- !ruby/object:Gem::Dependency
|
108
84
|
name: awesome_print
|
109
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,9 +87,6 @@ dependencies:
|
|
111
87
|
- - ">="
|
112
88
|
- !ruby/object:Gem::Version
|
113
89
|
version: '1.7'
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '1.7'
|
117
90
|
type: :development
|
118
91
|
prerelease: false
|
119
92
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -121,9 +94,6 @@ dependencies:
|
|
121
94
|
- - ">="
|
122
95
|
- !ruby/object:Gem::Version
|
123
96
|
version: '1.7'
|
124
|
-
- - "~>"
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: '1.7'
|
127
97
|
- !ruby/object:Gem::Dependency
|
128
98
|
name: eventmachine
|
129
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,9 +101,6 @@ dependencies:
|
|
131
101
|
- - ">="
|
132
102
|
- !ruby/object:Gem::Version
|
133
103
|
version: 1.2.7
|
134
|
-
- - "~>"
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: 1.2.7
|
137
104
|
type: :development
|
138
105
|
prerelease: false
|
139
106
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -141,9 +108,6 @@ dependencies:
|
|
141
108
|
- - ">="
|
142
109
|
- !ruby/object:Gem::Version
|
143
110
|
version: 1.2.7
|
144
|
-
- - "~>"
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
version: 1.2.7
|
147
111
|
description: A ruby wrapper for Finnhub's HTTP API
|
148
112
|
email:
|
149
113
|
- stefano.martin87@gmail.com
|
@@ -163,10 +127,12 @@ files:
|
|
163
127
|
- lib/Economic.rb
|
164
128
|
- lib/Error.rb
|
165
129
|
- lib/Forex.rb
|
130
|
+
- lib/Indicator.rb
|
166
131
|
- lib/Stock.rb
|
167
132
|
- lib/Tick.rb
|
168
133
|
- lib/Timeseries.rb
|
169
134
|
- lib/Transcript.rb
|
135
|
+
- lib/Webhook.rb
|
170
136
|
- lib/Websocket.rb
|
171
137
|
- lib/finnhub.rb
|
172
138
|
- spec/1.0.0/crypto.rb
|
@@ -175,6 +141,8 @@ files:
|
|
175
141
|
- spec/1.0.0/stock.rb
|
176
142
|
- spec/1.0.0/websocket.rb
|
177
143
|
- spec/1.1.0/stock.rb
|
144
|
+
- spec/1.2.0/stock.rb
|
145
|
+
- spec/1.2.0/webhook.rb
|
178
146
|
- spec/all.rb
|
179
147
|
- spec/config.yml
|
180
148
|
- spec/spec_helper.rb
|