Class: Em::Nordnet::Instrument

Inherits:
Object
  • Object
show all
Defined in:
lib/em-nordnet/instrument.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Instrument

Returns a new instance of Instrument.



12
13
14
15
16
17
18
19
20
# File 'lib/em-nordnet/instrument.rb', line 12

def initialize attributes={}
  self.id          = attributes[:id] || attributes[:identifier]
  self.market_id   = attributes[:market_id] || attributes[:marketID]
  self.currency    = attributes[:currency]
  self.shortname   = attributes[:shortname]
  self.longname    = attributes[:longname]
  self.is_in_code  = attributes[:is_in_code] || attributes[:isinCode]
  self.ticksize_id = attributes[:ticksize_id] || attributes[:ticksizeID]
end

Instance Attribute Details

#currencyObject

Returns the value of attribute currency.



4
5
6
# File 'lib/em-nordnet/instrument.rb', line 4

def currency
  @currency
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/em-nordnet/instrument.rb', line 4

def id
  @id
end

#is_in_codeObject

Returns the value of attribute is_in_code.



4
5
6
# File 'lib/em-nordnet/instrument.rb', line 4

def is_in_code
  @is_in_code
end

#longnameObject

Returns the value of attribute longname.



4
5
6
# File 'lib/em-nordnet/instrument.rb', line 4

def longname
  @longname
end

#market_idObject

Returns the value of attribute market_id.



4
5
6
# File 'lib/em-nordnet/instrument.rb', line 4

def market_id
  @market_id
end

#shortnameObject

Returns the value of attribute shortname.



4
5
6
# File 'lib/em-nordnet/instrument.rb', line 4

def shortname
  @shortname
end

#ticksize_idObject

Returns the value of attribute ticksize_id.



4
5
6
# File 'lib/em-nordnet/instrument.rb', line 4

def ticksize_id
  @ticksize_id
end

Class Method Details

.search(symbol, options = {}) ⇒ Object



6
7
8
9
10
# File 'lib/em-nordnet/instrument.rb', line 6

def self.search symbol, options={}
  search_options = {query: symbol, type: 'A', country: ['SE','US']}.merge options
  results = Nordnet.api.instrument_search(search_options)
  results.map { |attributes| new attributes }
end

Instance Method Details

#subscribe_params(type) ⇒ Object



22
23
24
# File 'lib/em-nordnet/instrument.rb', line 22

def subscribe_params type
  { 't' => type.to_s, 'i' => id, 'm' => market_id }
end