Sha256: 1b531d8375f58ed90260d6a033772f82cf3b5cb67d259b69fe17f65d7d0db040
Contents?: true
Size: 948 Bytes
Versions: 1
Compression:
Stored size: 948 Bytes
Contents
require "signal_tools/stock_data" require "signal_tools/stock" require "signal_tools/technicals/average_directional_index" require "signal_tools/technicals/average_true_range" require "signal_tools/technicals/common" require "signal_tools/technicals/ema" require "signal_tools/technicals/fast_stochastic" require "signal_tools/technicals/slow_stochastic" require "signal_tools/technicals/macd" module SignalTools def self.sum(array) array.inject(0) {|accum, c| accum + c.to_f } end def self.average(array) return nil if !array || array.size == 0 sum(array).to_f / array.size end # Truncates all arrays to the size of the shortest array by cutting off the front # of the longer arrays. def self.truncate_to_shortest!(*arrays) shortest_size = arrays.inject(arrays.first.size) { |size, array| array.size < size ? array.size : size } arrays.each { |array| array.slice!(0...(array.size - shortest_size)) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
signal_tools-0.3.1 | lib/signal_tools.rb |