cotcube-indicators 0.1.10 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63178d5a731cb55b8b5d9c6f63ac5aa9931d909fc30490bceea514d2dff1beb9
4
- data.tar.gz: 0e0beac7a246973767faabafefd412cb76a08ecdbadb4ce0e390c96027c5ae51
3
+ metadata.gz: 5ec4481000ff50b9942da8148f1660af15473bf29a5f88dc8b3876f14cfaf1f1
4
+ data.tar.gz: d0e2ae25f2fb53c7c041800e9b8386f28d8461725501f80f279f1590df5126b1
5
5
  SHA512:
6
- metadata.gz: fcb3bc43b9cb2548e4901d24ad2d422ed37319510add433ba43adbb97308ab39b00ce6ee371acfbcd0372161b212a9117b4b4620cee5bba8a15265592d57214d
7
- data.tar.gz: 2ebd19d2f1fe549198ecdb9b2ae6e70e27f6d76f80f4b83d57f1c8dafc16387b40e36859b60a0b332afaefb92334ce6d06c7294bf31b85472569dd18347d92a7
6
+ metadata.gz: 11df83e20a57e00447cdc2d58bce8a6bcaee8c3b8de70bc2c226a2bba754141c3332036518953b243d1293f473eb7d2a95d34c1adb7cd4238b4daa02fb97203b
7
+ data.tar.gz: e40de6cc45107c3eacc8de3ead08e48bb85f171f438db2635f029f39bcdf09121c71499d331798207afbb54c796140c0ed0f298058494735d9d7bd05315b6080
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.1.14 (July 31, 2021)
2
+ - calc: adding support for more param variables (a .. e)
3
+
4
+ ## 0.1.13 (December 30, 2020)
5
+ - small fix to #score and #index to support missing values in series
6
+
7
+ ## 0.1.12 (December 05, 2020)
8
+ - added tests for SMA, EMA, RSI
9
+
10
+ ## 0.1.11 (December 05, 2020)
11
+ - Fixing 'smoothing' keyword argument in EMA
12
+
1
13
  ## 0.1.10 (December 03, 2020)
2
14
  - added indicator 'threshold' including spec
3
15
  - some minor improvements to .gitignore and .gemspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.10
1
+ 0.1.14
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Cotcube
4
4
  module Indicators
5
- def calc(a:, b:, &block) # rubocop:disable Naming/MethodParameterName
5
+ def calc(a:, b:, c:nil, d:nil, e:nil, &block) # rubocop:disable Naming/MethodParameterName
6
6
  lambda do |x|
7
- block.call(x[a.to_sym], x[b.to_sym]).to_f
7
+ block.call(x[a.to_sym], x[b.to_sym], x[c.to_sym], x[d.to_sym], x[e.to_sym]).to_f
8
8
  end
9
9
  end
10
10
  end
@@ -3,12 +3,13 @@
3
3
  module Cotcube
4
4
  module Indicators
5
5
  # the classic exponential moving average
6
- def ema(key:, length:, smoothing:)
7
- raise 'Missing parameter, need :length' if length.nil? || (not length.is_a? Integer)
8
- raise 'Missing parameter, need :key' if key.nil?
6
+ def ema(key:, length:, smoothing: nil)
7
+ raise ArgumentError, 'Improper :length parameter, should be positive Integer' unless length.is_a? Integer and length.positive?
9
8
 
10
9
  smoothing ||= (2 / (length - 1).to_f.round(2))
11
- carrier = Carrier.new(length)
10
+ raise ArgumentError, 'Improper smoothing, should be Numeric' unless smoothing.is_a? Numeric
11
+
12
+ carrier = Cotcube::Indicators::Carrier.new(length: length)
12
13
  lambda do |x|
13
14
  current = x[key.to_sym]
14
15
  carrier << if carrier.empty?
@@ -24,7 +24,7 @@ module Cotcube
24
24
  puts "RESULT: #{res}" if debug
25
25
  return reverse ? (1 - res.to_f).round(3).to_f : res.round(3).to_f
26
26
  else
27
- carrier.shift
27
+ carrier << 0
28
28
  return 0
29
29
  end
30
30
  end
@@ -3,8 +3,6 @@
3
3
  module Cotcube
4
4
  module Indicators
5
5
  def rsi(length:, key:, debug: false)
6
- raise 'Missing parameter, need :key and :length options' if length.nil? || key.nil?
7
-
8
6
  carrier = Carrier.new(length: length)
9
7
 
10
8
  lambda do |x|
@@ -11,7 +11,7 @@ module Cotcube
11
11
  current = x[key.to_sym]
12
12
  current = current.abs if abs
13
13
  if current.zero?
14
- carrier.shift
14
+ carrier << 0
15
15
  return 0
16
16
 
17
17
  end
@@ -3,7 +3,6 @@
3
3
  module Cotcube
4
4
  module Indicators
5
5
  def sma(length:, key:)
6
- raise 'Missing parameter, need :length and :value options' if opts[:length].nil? || opts[:value].nil?
7
6
 
8
7
  carrier = Cotcube::Indicators::Carrier.new(length: length)
9
8
  lambda do |x|
@@ -7,7 +7,7 @@ module Cotcube
7
7
  raise ArgumentError, "Need to set :upper: (set to Float::INFINITY to omit)" if upper.nil?
8
8
  raise ArgumentError, "Need to set :lower unless :abs is set" if lower.nil? and not abs
9
9
  raise ArgumentError, ":lower, upper must be numeric" if not upper.is_a?(Numeric) and ( abs ? true : lower.is_a?(Numeric) )
10
- raise ArgumentError, "Found bogus, :lower #{lower} must be lower than :upper #{upper}" if not abs and lower >= upper
10
+ raise ArgumentError, "Found bogus, :lower #{lower} must be lower than :upper #{upper}" if not abs and lower > upper
11
11
  # For this indicator, we just need to remembers -1, 0 or 1. That does not need a helper class.
12
12
  carrier = 0
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cotcube-indicators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin L. Tischendorf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2021-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake