Class: Finnhub::Stock
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#ceo_compensation ⇒ Object
-
#dividends(from:, to:) ⇒ Object
-
#earnings(limit: nil) ⇒ Object
-
#earnings_calendar(from: nil, to: nil) ⇒ Object
-
#earnings_estimate ⇒ Object
-
#executive ⇒ Object
-
#financials(statement: "bs", freq: "annual") ⇒ Object
-
#funds(limit: nil) ⇒ Object
-
#indicator(**args) ⇒ Object
-
#initialize(client:, symbol:, displaySymbol: nil, description: nil, exchange: nil) ⇒ Stock
constructor
-
#investors(limit: nil) ⇒ Object
-
#major_development(from: nil, to: nil) ⇒ Object
-
#metrics(metric: "price") ⇒ Object
-
#news ⇒ Object
-
#option_chain ⇒ Object
-
#peers(plain: false) ⇒ Object
-
#price_target ⇒ Object
-
#profile(isin: nil, cusip: nil) ⇒ Object
-
#quote ⇒ Object
-
#recommendation ⇒ Object
-
#revenue_estimate ⇒ Object
-
#sentiment ⇒ Object
-
#splits(from:, to:) ⇒ Object
-
#tick(**args) ⇒ Object
-
#timeseries(**args) ⇒ Object
(also: #candles)
-
#transcripts(plain: false) ⇒ Object
-
#upgrade_downgrade ⇒ Object
Methods included from Analysis
#pattern, #support_resistance, #technical_indicators
Constructor Details
#initialize(client:, symbol:, displaySymbol: nil, description: nil, exchange: nil) ⇒ Stock
Returns a new instance of Stock.
29
30
31
32
33
34
35
36
|
# File 'lib/Stock.rb', line 29
def initialize(client:, symbol:,
displaySymbol: nil, description: nil, exchange: nil)
@client = client
@symbol = symbol
@displaySymbol = displaySymbol
@description = description
@exchange = exchange
end
|
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
38
39
40
|
# File 'lib/Stock.rb', line 38
def description
@description
end
|
#displaySymbol ⇒ Object
Returns the value of attribute displaySymbol.
38
39
40
|
# File 'lib/Stock.rb', line 38
def displaySymbol
@displaySymbol
end
|
#exchange ⇒ Object
Returns the value of attribute exchange.
38
39
40
|
# File 'lib/Stock.rb', line 38
def exchange
@exchange
end
|
#symbol ⇒ Object
Returns the value of attribute symbol.
38
39
40
|
# File 'lib/Stock.rb', line 38
def symbol
@symbol
end
|
Instance Method Details
#ceo_compensation ⇒ Object
54
55
56
|
# File 'lib/Stock.rb', line 54
def ceo_compensation
@client.request("/stock/ceo-compensation?symbol=#{@symbol}")
end
|
#dividends(from:, to:) ⇒ Object
149
150
151
152
153
154
155
156
|
# File 'lib/Stock.rb', line 149
def dividends(from:, to:)
url = "/stock/dividend?symbol=#{@symbol}"
from = from.to_date.to_s if from.is_a?(Time)
url += "&from=#{from}"
to = to.to_date.to_s if to.is_a?(Time)
url += "&to=#{to}"
@client.request(url)
end
|
#earnings(limit: nil) ⇒ Object
85
86
87
88
89
|
# File 'lib/Stock.rb', line 85
def earnings(limit: nil)
url = "/stock/earnings?symbol=#{@symbol}"
url += "&limit=#{limit}" unless limit.nil?
@client.request(url)
end
|
#earnings_calendar(from: nil, to: nil) ⇒ Object
140
141
142
143
144
145
146
147
|
# File 'lib/Stock.rb', line 140
def earnings_calendar(from: nil, to: nil)
url = "/calendar/earnings?symbol=#{@symbol}"
from = from.to_date.to_s if from.is_a?(Time)
url += "&from=#{from}" unless from.nil?
to = to.to_date.to_s if to.is_a?(Time)
url += "&to=#{to}" unless to.nil?
@client.request(url)
end
|
#earnings_estimate ⇒ Object
136
137
138
|
# File 'lib/Stock.rb', line 136
def earnings_estimate
@client.request("/stock/eps-estimate?symbol=#{@symbol}")
end
|
#executive ⇒ Object
58
59
60
|
# File 'lib/Stock.rb', line 58
def executive
@client.request("/stock/executive?symbol=#{@symbol}")
end
|
#financials(statement: "bs", freq: "annual") ⇒ Object
107
108
109
|
# File 'lib/Stock.rb', line 107
def financials(statement: "bs", freq: "annual")
@client.request("/stock/financials?symbol=#{@symbol}&statement=#{statement}&freq=#{freq}")
end
|
#funds(limit: nil) ⇒ Object
101
102
103
104
105
|
# File 'lib/Stock.rb', line 101
def funds(limit: nil)
url = "/stock/fund-ownership?symbol=#{@symbol}"
url += "&limit=#{limit}" unless limit.nil?
@client.request(url)
end
|
#indicator(**args) ⇒ Object
183
184
185
|
# File 'lib/Stock.rb', line 183
def indicator(**args)
Finnhub::Indicator.new(client: @client, stock: self, **args)
end
|
#investors(limit: nil) ⇒ Object
95
96
97
98
99
|
# File 'lib/Stock.rb', line 95
def investors(limit: nil)
url = "/stock/investor-ownership?symbol=#{@symbol}"
url += "&limit=#{limit}" unless limit.nil?
@client.request(url)
end
|
#major_development(from: nil, to: nil) ⇒ Object
119
120
121
122
123
124
125
126
|
# File 'lib/Stock.rb', line 119
def major_development(from: nil, to: nil)
url = "/major-development?symbol=#{@symbol}"
from = from.to_date.to_s if from.is_a?(Time)
url += "&from=#{from}" unless from.nil?
to = to.to_date.to_s if to.is_a?(Time)
url += "&to=#{to}" unless to.nil?
@client.request(url)
end
|
#metrics(metric: "price") ⇒ Object
91
92
93
|
# File 'lib/Stock.rb', line 91
def metrics(metric: "price")
@client.request("/stock/metric?symbol=#{@symbol}&metric=#{metric}")
end
|
#news ⇒ Object
115
116
117
|
# File 'lib/Stock.rb', line 115
def news
@client.request("/news/#{@symbol}")
end
|
#option_chain ⇒ Object
74
75
76
|
# File 'lib/Stock.rb', line 74
def option_chain
@client.request("/stock/option-chain?symbol=#{@symbol}")
end
|
#peers(plain: false) ⇒ Object
78
79
80
81
82
83
|
# File 'lib/Stock.rb', line 78
def peers(plain: false)
output = @client.request("/stock/peers?symbol=#{@symbol}")
return output if plain
output.map{|o| Finnhub::Stock.new(client: @client, symbol: o)}
end
|
#price_target ⇒ Object
66
67
68
|
# File 'lib/Stock.rb', line 66
def price_target
@client.request("/stock/price-target?symbol=#{@symbol}")
end
|
#profile(isin: nil, cusip: nil) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/Stock.rb', line 40
def profile(isin: nil, cusip: nil)
if !isin.nil?
string = "isin".freeze
symbol = isin
elsif !cusip.nil?
string = "cusip".freeze
symbol = cusip
else
string = "symbol".freeze
symbol = @symbol
end
@client.request("/stock/profile?#{string}=#{symbol}")
end
|
#quote ⇒ Object
111
112
113
|
# File 'lib/Stock.rb', line 111
def quote
@client.request("/quote?symbol=#{@symbol}")
end
|
#recommendation ⇒ Object
62
63
64
|
# File 'lib/Stock.rb', line 62
def recommendation
@client.request("/stock/recommendation?symbol=#{@symbol}")
end
|
#revenue_estimate ⇒ Object
132
133
134
|
# File 'lib/Stock.rb', line 132
def revenue_estimate
@client.request("/stock/revenue-estimate?symbol=#{@symbol}")
end
|
#sentiment ⇒ Object
128
129
130
|
# File 'lib/Stock.rb', line 128
def sentiment
@client.request("/news-sentiment?symbol=#{@symbol}")
end
|
#splits(from:, to:) ⇒ Object
158
159
160
161
162
163
164
165
|
# File 'lib/Stock.rb', line 158
def splits(from:, to:)
url = "/stock/split?symbol=#{@symbol}"
from = from.to_date.to_s if from.is_a?(Time)
url += "&from=#{from}"
to = to.to_date.to_s if to.is_a?(Time)
url += "&to=#{to}"
@client.request(url)
end
|
#tick(**args) ⇒ Object
179
180
181
|
# File 'lib/Stock.rb', line 179
def tick(**args)
Finnhub::Tick.new(client: @client, stock: self, **args)
end
|
#timeseries(**args) ⇒ Object
Also known as:
candles
174
175
176
|
# File 'lib/Stock.rb', line 174
def timeseries(**args)
Finnhub::Timeseries.new(client: @client, stock: self, **args)
end
|
#transcripts(plain: false) ⇒ Object
167
168
169
170
171
172
|
# File 'lib/Stock.rb', line 167
def transcripts(plain: false)
output = @client.request("/stock/transcripts/list?symbol=#{@symbol}")
return output if plain
output[:transcripts].map{|o| Finnhub::Transcript.new(client: self, id: o[:id], hash: o)}
end
|
#upgrade_downgrade ⇒ Object
70
71
72
|
# File 'lib/Stock.rb', line 70
def upgrade_downgrade
@client.request("/stock/upgrade-downgrade?symbol=#{@symbol}")
end
|