Class: Alpaca::Trade::Api::Bar
- Inherits:
-
Object
- Object
- Alpaca::Trade::Api::Bar
- Defined in:
- lib/alpaca/trade/api/bar.rb
Instance Attribute Summary collapse
-
#close ⇒ Object
readonly
Returns the value of attribute close.
-
#high ⇒ Object
readonly
Returns the value of attribute high.
-
#low ⇒ Object
readonly
Returns the value of attribute low.
-
#open ⇒ Object
readonly
Returns the value of attribute open.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#volume ⇒ Object
readonly
Returns the value of attribute volume.
Instance Method Summary collapse
-
#initialize(json) ⇒ Bar
constructor
A new instance of Bar.
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
#close ⇒ Object (readonly)
Returns the value of attribute close.
7 8 9 |
# File 'lib/alpaca/trade/api/bar.rb', line 7 def close @close end |
#high ⇒ Object (readonly)
Returns the value of attribute high.
7 8 9 |
# File 'lib/alpaca/trade/api/bar.rb', line 7 def high @high end |
#low ⇒ Object (readonly)
Returns the value of attribute low.
7 8 9 |
# File 'lib/alpaca/trade/api/bar.rb', line 7 def low @low end |
#open ⇒ Object (readonly)
Returns the value of attribute open.
7 8 9 |
# File 'lib/alpaca/trade/api/bar.rb', line 7 def open @open end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
7 8 9 |
# File 'lib/alpaca/trade/api/bar.rb', line 7 def time @time end |
#volume ⇒ Object (readonly)
Returns the value of attribute volume.
7 8 9 |
# File 'lib/alpaca/trade/api/bar.rb', line 7 def volume @volume end |