Class: IB::Bar

Inherits:
Model show all
Includes:
BaseProperties
Defined in:
lib/models/ib/bar.rb

Overview

This is a single data point delivered by HistoricData or RealTimeBar messages. Instantiate with a Hash of attributes, to be auto-set via initialize in Model.

Instance Method Summary collapse

Methods included from BaseProperties

#content_attributes, #default_attributes, #set_attribute_defaults, #update_missing

Instance Method Details

#==(other) ⇒ Object

Order comparison



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/models/ib/bar.rb', line 25

def == other
  super(other) ||
    other.is_a?(self.class) &&
    time == other.time &&
    open == other.open &&
    high == other.high &&
    low == other.low &&
    close == other.close &&
    wap == other.wap &&
    trades == other.trades &&
    volume == other.volume
end

#to_humanObject Also known as: to_s



38
39
40
41
# File 'lib/models/ib/bar.rb', line 38

def to_human
  "<Bar: #{time} wap #{wap} OHLC #{open} #{high} #{low} #{close} " +
    (trades ? "trades #{trades}" : "") + " vol #{volume} gaps #{has_gaps}>"
end