quantitative 0.2.2 → 0.3.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/quant/{dominant_cycle_indicators.rb → dominant_cycles_source.rb} +18 -10
- data/lib/quant/experimental.rb +8 -1
- data/lib/quant/indicators/adx.rb +3 -0
- data/lib/quant/indicators/decycler.rb +16 -30
- data/lib/quant/indicators/dominant_cycles/dominant_cycle.rb +9 -0
- data/lib/quant/indicators/frama.rb +5 -8
- data/lib/quant/indicators/indicator.rb +45 -2
- data/lib/quant/indicators/pivot.rb +107 -0
- data/lib/quant/indicators/pivots/atr.rb +41 -0
- data/lib/quant/indicators/pivots/bollinger.rb +45 -0
- data/lib/quant/indicators/pivots/camarilla.rb +61 -0
- data/lib/quant/indicators/pivots/classic.rb +24 -0
- data/lib/quant/indicators/pivots/demark.rb +50 -0
- data/lib/quant/indicators/pivots/donchian.rb +40 -0
- data/lib/quant/indicators/pivots/fibbonacci.rb +22 -0
- data/lib/quant/indicators/pivots/guppy.rb +39 -0
- data/lib/quant/indicators/pivots/keltner.rb +43 -0
- data/lib/quant/indicators/pivots/murrey.rb +34 -0
- data/lib/quant/indicators/pivots/traditional.rb +36 -0
- data/lib/quant/indicators/pivots/woodie.rb +59 -0
- data/lib/quant/indicators_source.rb +140 -0
- data/lib/quant/indicators_sources.rb +36 -10
- data/lib/quant/pivots_source.rb +28 -0
- data/lib/quant/refinements/array.rb +14 -0
- data/lib/quant/series.rb +8 -19
- data/lib/quant/settings/indicators.rb +11 -0
- data/lib/quant/version.rb +1 -1
- data/possibilities.png +0 -0
- data/quantitative.gemspec +39 -0
- metadata +20 -5
- data/lib/quant/indicators.rb +0 -18
- 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.
|
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-
|
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,9 @@ files:
|
|
48
48
|
- lib/quant/asset_class.rb
|
49
49
|
- lib/quant/attributes.rb
|
50
50
|
- lib/quant/config.rb
|
51
|
-
- lib/quant/
|
51
|
+
- lib/quant/dominant_cycles_source.rb
|
52
52
|
- lib/quant/errors.rb
|
53
53
|
- lib/quant/experimental.rb
|
54
|
-
- lib/quant/indicators.rb
|
55
54
|
- lib/quant/indicators/adx.rb
|
56
55
|
- lib/quant/indicators/atr.rb
|
57
56
|
- lib/quant/indicators/cci.rb
|
@@ -69,7 +68,20 @@ files:
|
|
69
68
|
- lib/quant/indicators/mama.rb
|
70
69
|
- lib/quant/indicators/mesa.rb
|
71
70
|
- lib/quant/indicators/ping.rb
|
72
|
-
- lib/quant/
|
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
|
73
85
|
- lib/quant/indicators_sources.rb
|
74
86
|
- lib/quant/interval.rb
|
75
87
|
- lib/quant/mixins/butterworth_filters.rb
|
@@ -86,6 +98,7 @@ files:
|
|
86
98
|
- lib/quant/mixins/super_smoother.rb
|
87
99
|
- lib/quant/mixins/universal_filters.rb
|
88
100
|
- lib/quant/mixins/weighted_moving_average.rb
|
101
|
+
- lib/quant/pivots_source.rb
|
89
102
|
- lib/quant/refinements/array.rb
|
90
103
|
- lib/quant/series.rb
|
91
104
|
- lib/quant/settings.rb
|
@@ -101,6 +114,8 @@ files:
|
|
101
114
|
- lib/quant/time_period.rb
|
102
115
|
- lib/quant/version.rb
|
103
116
|
- lib/quantitative.rb
|
117
|
+
- possibilities.png
|
118
|
+
- quantitative.gemspec
|
104
119
|
homepage: https://github.com/mwlang/quantitative
|
105
120
|
licenses:
|
106
121
|
- MIT
|
data/lib/quant/indicators.rb
DELETED
@@ -1,18 +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
|
-
def adx; indicator(Indicators::Adx) end
|
10
|
-
def atr; indicator(Indicators::Atr) end
|
11
|
-
def mesa; indicator(Indicators::Mesa) end
|
12
|
-
def mama; indicator(Indicators::MAMA) end
|
13
|
-
|
14
|
-
def dominant_cycles
|
15
|
-
@dominant_cycles ||= Quant::DominantCycleIndicators.new(series:, source:)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
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
|