Class: Alpaca::Trade::Api::Bar

Inherits:
Object
  • Object
show all
Defined in:
lib/alpaca/trade/api/bar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Bar

Returns a new instance of Bar.



9
10
11
12
13
14
15
16
# File 'lib/alpaca/trade/api/bar.rb', line 9

def initialize(json)
  @time = Time.at(json['t'])
  @open = BigDecimal(json['o'].to_s)
  @high = BigDecimal(json['h'].to_s)
  @low = BigDecimal(json['l'].to_s)
  @close = BigDecimal(json['c'].to_s)
  @volume = json['v']
end

Instance Attribute Details

#closeObject (readonly)

Returns the value of attribute close.



7
8
9
# File 'lib/alpaca/trade/api/bar.rb', line 7

def close
  @close
end

#highObject (readonly)

Returns the value of attribute high.



7
8
9
# File 'lib/alpaca/trade/api/bar.rb', line 7

def high
  @high
end

#lowObject (readonly)

Returns the value of attribute low.



7
8
9
# File 'lib/alpaca/trade/api/bar.rb', line 7

def low
  @low
end

#openObject (readonly)

Returns the value of attribute open.



7
8
9
# File 'lib/alpaca/trade/api/bar.rb', line 7

def open
  @open
end

#timeObject (readonly)

Returns the value of attribute time.



7
8
9
# File 'lib/alpaca/trade/api/bar.rb', line 7

def time
  @time
end

#volumeObject (readonly)

Returns the value of attribute volume.



7
8
9
# File 'lib/alpaca/trade/api/bar.rb', line 7

def volume
  @volume
end