Class: Finnhub::Stock

Inherits:
Object
  • Object
show all
Includes:
Analysis
Defined in:
lib/Stock.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Analysis

#pattern, #support_resistance, #technical_indicators

Constructor Details

#initialize(client:, symbol:) ⇒ Stock

Returns a new instance of Stock.



5
6
7
8
# File 'lib/Stock.rb', line 5

def initialize(client:, symbol:)
  @client = client
  @symbol = symbol
end

Instance Attribute Details

#symbolObject (readonly)

Returns the value of attribute symbol.



10
11
12
# File 'lib/Stock.rb', line 10

def symbol
  @symbol
end

Instance Method Details

#ceo_compensationObject



16
17
18
# File 'lib/Stock.rb', line 16

def ceo_compensation
  @client.request("/stock/ceo-compensation?symbol=#{@symbol}")
end

#earningsObject



39
40
41
# File 'lib/Stock.rb', line 39

def earnings
  @client.request("/stock/earnings?symbol=#{@symbol}")
end

#newsObject



43
44
45
# File 'lib/Stock.rb', line 43

def news
  @client.request("/news/#{@symbol}")
end

#option_chainObject



28
29
30
# File 'lib/Stock.rb', line 28

def option_chain
  @client.request("/stock/option-chain?symbol=#{@symbol}")
end

#peers(plain: false) ⇒ Object



32
33
34
35
36
37
# File 'lib/Stock.rb', line 32

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_targetObject



24
25
26
# File 'lib/Stock.rb', line 24

def price_target
  @client.request("/stock/price-target?symbol=#{@symbol}")
end

#profileObject



12
13
14
# File 'lib/Stock.rb', line 12

def profile
  @client.request("/stock/profile?symbol=#{@symbol}")
end

#recommendationObject



20
21
22
# File 'lib/Stock.rb', line 20

def recommendation
  @client.request("/stock/recommendation?symbol=#{@symbol}")
end

#sentimentObject



47
48
49
# File 'lib/Stock.rb', line 47

def sentiment
  @client.request("/news-sentiment?symbol=#{@symbol}")
end

#timeseries(**args) ⇒ Object



51
52
53
# File 'lib/Stock.rb', line 51

def timeseries(**args)
  Finnhub::Timeseries.new(client: @client, stock: self, **args)
end