Module: SQA::Strategy::Common

Included in:
Consensus, EMA, MP, MR, RSI, Random, SMA
Defined in:
lib/sqa/strategy/common.rb

Instance Method Summary collapse

Instance Method Details

#descObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sqa/strategy/common.rb', line 23

def desc
  doc_filename   = self.name.split('::').last.downcase + ".md"
  doc_path       = Pathname.new(__dir__) + doc_filename

  if doc_path.exist?
    doc = doc_path.read
  else
    doc = "A description of #{self.name} is not available"
  end

  puts doc
end

#trade_against(vector) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sqa/strategy/common.rb', line 9

def trade_against(vector)
  return :hold unless respond_to? :trade

  recommendation = trade(vector)

  if :sell == recommendation
    :buy
  elsif :buy == recommendation
    :sell
  else
    :hold
  end
end