Class: MoexIss::Market::Stock

Inherits:
Object
  • Object
show all
Defined in:
lib/moex_iss/market/stock.rb

Constant Summary collapse

METHODS =
{
  "BID" => :bid, "MARKETPRICETODAY" => :market_price_today,
  "MARKETPRICE" => :market_price, "SECID" => :secid,
  "SHORTNAME" => :short_name, "LATNAME" => :lat_name,
  "BOARDID" => :board_id, "BOARDNAME" => :board_name,
  "ISIN" => :isin, "PREVPRICE" => :prev_price,
  "PREVDATE" => :prev_date
}.freeze
MARKET_DATA =
%w[CLOSEPRICE OPEN LOW HIGH LAST VALUE SYSTIME]

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Stock

Returns a new instance of Stock.



19
20
21
22
23
24
25
26
27
# File 'lib/moex_iss/market/stock.rb', line 19

def initialize(response)
  @response = response.is_a?(Array) ? response.first : response

  setup_instance_varibales(@response["securities"])
  setup_instance_varibales(@response["marketdata"])
  setup_instance_varibales(@response["history"])

  @market_data = @response["marketdata"]&.slice(*MARKET_DATA)
end