Class: MyTradeWizard::DailyBars

Inherits:
Object
  • Object
show all
Defined in:
lib/mytradewizard/daily_bars.rb

Instance Method Summary collapse

Constructor Details

#initializeDailyBars

Returns a new instance of DailyBars.



4
5
6
# File 'lib/mytradewizard/daily_bars.rb', line 4

def initialize
  @hash = Hash.new
end

Instance Method Details

#add(day, bar) ⇒ Object



12
13
14
# File 'lib/mytradewizard/daily_bars.rb', line 12

def add(day, bar)
  @hash[day] = bar
end

#day(day) ⇒ Object



24
25
26
# File 'lib/mytradewizard/daily_bars.rb', line 24

def day(day)
  @hash[day]
end

#days(daily_range) ⇒ Object



28
29
30
# File 'lib/mytradewizard/daily_bars.rb', line 28

def days(daily_range)
  @hash.select { |day, bar| daily_range.begin <= day && day <= daily_range.end }.values
end

#lengthObject



8
9
10
# File 'lib/mytradewizard/daily_bars.rb', line 8

def length
  @hash.length
end

#most_recentObject



20
21
22
# File 'lib/mytradewizard/daily_bars.rb', line 20

def most_recent
  @hash[today]
end

#todayObject



16
17
18
# File 'lib/mytradewizard/daily_bars.rb', line 16

def today
  @hash.keys.max
end