Module: Util

Defined in:
lib/util.rb

Class Method Summary collapse

Class Method Details

.compare_2_arrays_of_floats(a, b) ⇒ Object



3
4
5
# File 'lib/util.rb', line 3

def self.compare_2_arrays_of_floats(a, b)
  delete_nans_and_truncate_floats_to_strings(a) == delete_nans_and_truncate_floats_to_strings(b)
end

.delete_nans_and_truncate_floats_to_strings(a) ⇒ Object



11
12
13
# File 'lib/util.rb', line 11

def self.delete_nans_and_truncate_floats_to_strings(a)
  a.delete_if{ |e| e.nan? }.map{ |e| truncate_float_to_string(e) }
end

.ohlc(opens, highs, lows, closes) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/util.rb', line 15

def self.ohlc(opens, highs, lows, closes)
  o = []
  opens.each_with_index do |e, i|
    o << [opens[i], highs[i], lows[i], closes[i]]
  end
  o
end

.truncate_float_to_string(f) ⇒ Object



7
8
9
# File 'lib/util.rb', line 7

def self.truncate_float_to_string(f)
  "%.10f" % f
end