Module: Quant::Mixins::Direction

Defined in:
lib/quant/mixins/direction.rb

Instance Method Summary collapse

Instance Method Details

#dir_label(colorize) ⇒ Object



16
17
18
# File 'lib/quant/mixins/direction.rb', line 16

def dir_label(average, current)
  { up: "UP", flat: "--", down: "DN" }[direction(average, current)]
end

#direction(average, current) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/quant/mixins/direction.rb', line 6

def direction(average, current)
  if average < current
    :up
  elsif average > current
    :down
  else
    :flat
  end
end

#down?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/quant/mixins/direction.rb', line 28

def down?
  direction == :down
end

#down_or_flat?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/quant/mixins/direction.rb', line 36

def down_or_flat?
  down? || flat?
end

#flat?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/quant/mixins/direction.rb', line 24

def flat?
  direction == :flat
end

#up?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/quant/mixins/direction.rb', line 20

def up?
  direction == :up
end

#up_or_flat?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/quant/mixins/direction.rb', line 32

def up_or_flat?
  up? || flat?
end