quantitative 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -4
  3. data/Gemfile.lock +9 -1
  4. data/README.md +5 -0
  5. data/lib/quant/{indicators/dominant_cycle_indicators.rb → dominant_cycles_source.rb} +19 -8
  6. data/lib/quant/experimental.rb +8 -1
  7. data/lib/quant/indicators/adx.rb +83 -0
  8. data/lib/quant/indicators/atr.rb +79 -0
  9. data/lib/quant/indicators/cci.rb +63 -0
  10. data/lib/quant/indicators/decycler.rb +71 -0
  11. data/lib/quant/indicators/dominant_cycles/acr.rb +2 -0
  12. data/lib/quant/indicators/dominant_cycles/band_pass.rb +2 -0
  13. data/lib/quant/indicators/dominant_cycles/differential.rb +3 -1
  14. data/lib/quant/indicators/dominant_cycles/dominant_cycle.rb +12 -6
  15. data/lib/quant/indicators/dominant_cycles/half_period.rb +2 -0
  16. data/lib/quant/indicators/dominant_cycles/homodyne.rb +4 -2
  17. data/lib/quant/indicators/dominant_cycles/phase_accumulator.rb +8 -4
  18. data/lib/quant/indicators/frama.rb +50 -0
  19. data/lib/quant/indicators/indicator.rb +50 -2
  20. data/lib/quant/indicators/mama.rb +143 -0
  21. data/lib/quant/indicators/mesa.rb +86 -0
  22. data/lib/quant/indicators/pivot.rb +107 -0
  23. data/lib/quant/indicators/pivots/atr.rb +41 -0
  24. data/lib/quant/indicators/pivots/bollinger.rb +45 -0
  25. data/lib/quant/indicators/pivots/camarilla.rb +61 -0
  26. data/lib/quant/indicators/pivots/classic.rb +24 -0
  27. data/lib/quant/indicators/pivots/demark.rb +50 -0
  28. data/lib/quant/indicators/pivots/donchian.rb +40 -0
  29. data/lib/quant/indicators/pivots/fibbonacci.rb +22 -0
  30. data/lib/quant/indicators/pivots/guppy.rb +39 -0
  31. data/lib/quant/indicators/pivots/keltner.rb +43 -0
  32. data/lib/quant/indicators/pivots/murrey.rb +34 -0
  33. data/lib/quant/indicators/pivots/traditional.rb +36 -0
  34. data/lib/quant/indicators/pivots/woodie.rb +59 -0
  35. data/lib/quant/indicators_source.rb +140 -0
  36. data/lib/quant/indicators_sources.rb +36 -10
  37. data/lib/quant/mixins/stochastic.rb +1 -1
  38. data/lib/quant/mixins/super_smoother.rb +11 -2
  39. data/lib/quant/pivots_source.rb +28 -0
  40. data/lib/quant/refinements/array.rb +14 -0
  41. data/lib/quant/series.rb +8 -19
  42. data/lib/quant/settings/indicators.rb +11 -0
  43. data/lib/quant/version.rb +1 -1
  44. data/possibilities.png +0 -0
  45. data/quantitative.gemspec +39 -0
  46. metadata +27 -5
  47. data/lib/quant/indicators.rb +0 -14
  48. data/lib/quant/indicators_proxy.rb +0 -68
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quantitative
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Lang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-16 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -48,10 +48,13 @@ files:
48
48
  - lib/quant/asset_class.rb
49
49
  - lib/quant/attributes.rb
50
50
  - lib/quant/config.rb
51
+ - lib/quant/dominant_cycles_source.rb
51
52
  - lib/quant/errors.rb
52
53
  - lib/quant/experimental.rb
53
- - lib/quant/indicators.rb
54
- - lib/quant/indicators/dominant_cycle_indicators.rb
54
+ - lib/quant/indicators/adx.rb
55
+ - lib/quant/indicators/atr.rb
56
+ - lib/quant/indicators/cci.rb
57
+ - lib/quant/indicators/decycler.rb
55
58
  - lib/quant/indicators/dominant_cycles/acr.rb
56
59
  - lib/quant/indicators/dominant_cycles/band_pass.rb
57
60
  - lib/quant/indicators/dominant_cycles/differential.rb
@@ -59,10 +62,26 @@ files:
59
62
  - lib/quant/indicators/dominant_cycles/half_period.rb
60
63
  - lib/quant/indicators/dominant_cycles/homodyne.rb
61
64
  - lib/quant/indicators/dominant_cycles/phase_accumulator.rb
65
+ - lib/quant/indicators/frama.rb
62
66
  - lib/quant/indicators/indicator.rb
63
67
  - lib/quant/indicators/indicator_point.rb
68
+ - lib/quant/indicators/mama.rb
69
+ - lib/quant/indicators/mesa.rb
64
70
  - lib/quant/indicators/ping.rb
65
- - lib/quant/indicators_proxy.rb
71
+ - lib/quant/indicators/pivot.rb
72
+ - lib/quant/indicators/pivots/atr.rb
73
+ - lib/quant/indicators/pivots/bollinger.rb
74
+ - lib/quant/indicators/pivots/camarilla.rb
75
+ - lib/quant/indicators/pivots/classic.rb
76
+ - lib/quant/indicators/pivots/demark.rb
77
+ - lib/quant/indicators/pivots/donchian.rb
78
+ - lib/quant/indicators/pivots/fibbonacci.rb
79
+ - lib/quant/indicators/pivots/guppy.rb
80
+ - lib/quant/indicators/pivots/keltner.rb
81
+ - lib/quant/indicators/pivots/murrey.rb
82
+ - lib/quant/indicators/pivots/traditional.rb
83
+ - lib/quant/indicators/pivots/woodie.rb
84
+ - lib/quant/indicators_source.rb
66
85
  - lib/quant/indicators_sources.rb
67
86
  - lib/quant/interval.rb
68
87
  - lib/quant/mixins/butterworth_filters.rb
@@ -79,6 +98,7 @@ files:
79
98
  - lib/quant/mixins/super_smoother.rb
80
99
  - lib/quant/mixins/universal_filters.rb
81
100
  - lib/quant/mixins/weighted_moving_average.rb
101
+ - lib/quant/pivots_source.rb
82
102
  - lib/quant/refinements/array.rb
83
103
  - lib/quant/series.rb
84
104
  - lib/quant/settings.rb
@@ -94,6 +114,8 @@ files:
94
114
  - lib/quant/time_period.rb
95
115
  - lib/quant/version.rb
96
116
  - lib/quantitative.rb
117
+ - possibilities.png
118
+ - quantitative.gemspec
97
119
  homepage: https://github.com/mwlang/quantitative
98
120
  licenses:
99
121
  - MIT
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "indicators_proxy"
4
- module Quant
5
- # TODO: build an Indicator registry so new indicators can be added and
6
- # used outside those shipped with the library.
7
- class Indicators < IndicatorsProxy
8
- def ping; indicator(Indicators::Ping) end
9
-
10
- def dominant_cycles
11
- @dominant_cycles ||= Indicators::DominantCycleIndicators.new(series:, source:)
12
- end
13
- end
14
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Quant
4
- # The {Quant::IndicatorsProxy} class is responsible for lazily loading indicators
5
- # so that not all indicators are always engaged and computing their values.
6
- # If the indicator is never accessed, it's never computed, saving valuable
7
- # processing CPU cycles.
8
- #
9
- # Indicators are generally built around the concept of a source input value and
10
- # that source is designated by the source parameter when instantiating the
11
- # {Quant::IndicatorsProxy} class.
12
- #
13
- # By design, the {Quant::Indicator} class holds the {Quant::Ticks::Tick} instance
14
- # alongside the indicator's computed values for that tick.
15
- class IndicatorsProxy
16
- attr_reader :series, :source, :dominant_cycle, :indicators
17
-
18
- def initialize(series:, source:)
19
- @series = series
20
- @source = source
21
- @indicators = {}
22
- @dominant_cycle = dominant_cycle_indicator
23
- end
24
-
25
- def dominant_cycle_indicator
26
- kind = Quant.config.indicators.dominant_cycle_kind.to_s
27
- base_class_name = kind.split("_").map(&:capitalize).join
28
- class_name = "Quant::Indicators::DominantCycles::#{base_class_name}"
29
- indicator_class = Object.const_get(class_name)
30
- indicator_class.new(series:, source:)
31
- end
32
-
33
- # Instantiates the indicator class and stores it in the indicators hash. Once
34
- # prepared, the indicator becomes active and all ticks pushed into the series
35
- # are sent to the indicator for processing.
36
- def indicator(indicator_class)
37
- indicators[indicator_class] ||= indicator_class.new(series:, source:)
38
- end
39
-
40
- # Adds the tick to all active indicators, triggering them to compute
41
- # new values against the latest tick.
42
- #
43
- # NOTE: Dominant cycle indicators must be computed first as many
44
- # indicators are adaptive and require the dominant cycle period.
45
- # The IndicatorsProxy class is not responsible for enforcing
46
- # this order of events.
47
- def <<(tick)
48
- dominant_cycle << tick
49
- indicators.each_value { |indicator| indicator << tick }
50
- end
51
-
52
- # Attaches a given Indicator class and defines the method for
53
- # accessing it using the given name. Indicators take care of
54
- # computing their values when first attached to a populated
55
- # series.
56
- #
57
- # The indicators shipped with the library are all wired into the framework, thus
58
- # this method should be used for custom indicators not shipped with the library.
59
- #
60
- # @param name [Symbol] The name of the method to define for accessing the indicator.
61
- # @param indicator_class [Class] The class of the indicator to attach.
62
- # @example
63
- # series.indicators.oc2.attach(name: :foo, indicator_class: Indicators::Foo)
64
- def attach(name:, indicator_class:)
65
- define_singleton_method(name) { indicator(indicator_class) }
66
- end
67
- end
68
- end