quantitative 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/lib/quant/asset.rb +0 -2
- data/lib/quant/experimental.rb +3 -1
- data/lib/quant/indicators/adx.rb +1 -5
- data/lib/quant/indicators/atr.rb +1 -4
- data/lib/quant/indicators/cci.rb +1 -1
- data/lib/quant/indicators/decycler.rb +1 -1
- data/lib/quant/indicators/dominant_cycles/acr.rb +3 -6
- data/lib/quant/indicators/dominant_cycles/band_pass.rb +2 -4
- data/lib/quant/indicators/dominant_cycles/differential.rb +2 -2
- data/lib/quant/indicators/dominant_cycles/dominant_cycle.rb +2 -4
- data/lib/quant/indicators/dominant_cycles/half_period.rb +2 -4
- data/lib/quant/indicators/dominant_cycles/homodyne.rb +2 -5
- data/lib/quant/indicators/dominant_cycles/phase_accumulator.rb +2 -4
- data/lib/quant/indicators/frama.rb +1 -1
- data/lib/quant/indicators/indicator.rb +1 -1
- data/lib/quant/indicators/indicator_point.rb +1 -1
- data/lib/quant/indicators/mama.rb +1 -1
- data/lib/quant/indicators/mesa.rb +1 -1
- data/lib/quant/indicators/ping.rb +1 -1
- data/lib/quant/indicators/pivot.rb +1 -1
- data/lib/quant/indicators/pivots/atr.rb +2 -2
- data/lib/quant/indicators/pivots/bollinger.rb +2 -2
- data/lib/quant/indicators/pivots/camarilla.rb +2 -2
- data/lib/quant/indicators/pivots/classic.rb +2 -2
- data/lib/quant/indicators/pivots/demark.rb +2 -2
- data/lib/quant/indicators/pivots/donchian.rb +2 -2
- data/lib/quant/indicators/pivots/fibbonacci.rb +2 -2
- data/lib/quant/indicators/pivots/guppy.rb +2 -2
- data/lib/quant/indicators/pivots/keltner.rb +2 -2
- data/lib/quant/indicators/pivots/murrey.rb +2 -3
- data/lib/quant/indicators/pivots/traditional.rb +2 -2
- data/lib/quant/indicators/pivots/woodie.rb +3 -3
- data/lib/quant/indicators.rb +6 -0
- data/lib/quant/indicators_source.rb +0 -1
- data/lib/quant/mixins/filters.rb +0 -3
- data/lib/quant/mixins/moving_averages.rb +0 -3
- data/lib/quant/ticks/ohlc.rb +0 -2
- data/lib/quant/ticks/spot.rb +0 -2
- data/lib/quant/version.rb +1 -1
- data/lib/quantitative.rb +21 -4
- metadata +18 -4
- data/quantitative.gemspec +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cfda18120bf7e3432b359a53d19d633f70f66e3ea4468098673cfc89ac2f77e
|
4
|
+
data.tar.gz: 598dc565f6da96ce9565afee249f38bc909234177d7b484ce82cba226e2e8d60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b2625954abe0e72a776de95da8d26af213440cb7e2d7beddd48529dfdb70d7247562066b09a3edd1dd3f171ad3ff8a32390ffe337729ca9712f65bdb147084e
|
7
|
+
data.tar.gz: 780f81a808f14d2d63b53aa81f8f30920b252979f17409d1ba48105ed5eadc91dadc253ada0cd75c6c21b8e6a8450cf39c75ce542adb450759fb097679899cce
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
quantitative (0.3.
|
4
|
+
quantitative (0.3.1)
|
5
5
|
oj (~> 3.10)
|
6
|
+
zeitwerk (~> 2.6)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -126,6 +127,7 @@ GEM
|
|
126
127
|
unicode-display_width (2.5.0)
|
127
128
|
vernier (0.5.1)
|
128
129
|
yard (0.9.34)
|
130
|
+
zeitwerk (2.6.15)
|
129
131
|
|
130
132
|
PLATFORMS
|
131
133
|
arm64-darwin-22
|
data/lib/quant/asset.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "asset_class"
|
4
|
-
|
5
3
|
module Quant
|
6
4
|
# A {Quant::Asset} is a representation of a financial instrument such as a stock, option, future, or currency.
|
7
5
|
# It is used to represent the instrument that is being traded, analyzed, or managed.
|
data/lib/quant/experimental.rb
CHANGED
data/lib/quant/indicators/adx.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "indicator_point"
|
4
|
-
require_relative "indicator"
|
5
|
-
require_relative "atr"
|
6
|
-
|
7
3
|
module Quant
|
8
|
-
|
4
|
+
module Indicators
|
9
5
|
class AdxPoint < IndicatorPoint
|
10
6
|
attribute :dmu, default: 0.0
|
11
7
|
attribute :dmd, default: 0.0
|
data/lib/quant/indicators/atr.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "indicator_point"
|
4
|
-
require_relative "indicator"
|
5
|
-
|
6
3
|
module Quant
|
7
|
-
|
4
|
+
module Indicators
|
8
5
|
class AtrPoint < IndicatorPoint
|
9
6
|
attribute :tr, default: 0.0
|
10
7
|
attribute :period, default: :min_period
|
data/lib/quant/indicators/cci.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Quant
|
4
|
-
|
4
|
+
module Indicators
|
5
5
|
# The decycler oscillator can be useful for determining the transition be- tween uptrends and downtrends by the crossing of the zero
|
6
6
|
# line. Alternatively, the changes of slope of the decycler oscillator are easier to identify than the changes in slope of the
|
7
7
|
# original decycler. Optimum cutoff periods can easily be found by experimentation.
|
@@ -1,12 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "../indicator_point"
|
4
|
-
require_relative "dominant_cycle"
|
5
|
-
|
6
3
|
module Quant
|
7
|
-
|
8
|
-
|
9
|
-
class AcrPoint <
|
4
|
+
module Indicators
|
5
|
+
module DominantCycles
|
6
|
+
class AcrPoint < Quant::Indicators::IndicatorPoint
|
10
7
|
attribute :hp, default: 0.0
|
11
8
|
attribute :filter, default: 0.0
|
12
9
|
attribute :interim_period, default: 0.0
|
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "dominant_cycle"
|
4
|
-
|
5
3
|
module Quant
|
6
|
-
|
7
|
-
|
4
|
+
module Indicators
|
5
|
+
module DominantCycles
|
8
6
|
class BandPassPoint < Quant::Indicators::IndicatorPoint
|
9
7
|
attribute :hp, default: 0.0
|
10
8
|
attribute :bp, default: 0.0
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Quant
|
4
|
-
|
5
|
-
|
4
|
+
module Indicators
|
5
|
+
module DominantCycles
|
6
6
|
# The Dual Differentiator algorithm computes the phase angle from the
|
7
7
|
# analytic signal as the arctangent of the ratio of the imaginary
|
8
8
|
# component to the real component. Further, the angular frequency
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "../indicator"
|
4
|
-
|
5
3
|
module Quant
|
6
|
-
|
4
|
+
module Indicators
|
7
5
|
# Dominant Cycles measure the primary cycle within a given range. By default, the library
|
8
6
|
# is wired to look for cycles between 10 and 48 bars. These values can be adjusted by setting
|
9
7
|
# the `min_period` and `max_period` configuration values in {Quant::Config}.
|
@@ -18,7 +16,7 @@ module Quant
|
|
18
16
|
# The purpose of these indicators is to compute the dominant cycle and underpin the various
|
19
17
|
# indicators that would otherwise be setting an arbitrary lookback period. This makes the
|
20
18
|
# indicators adaptive and auto-tuning to the market dynamics. Or so the theory goes!
|
21
|
-
|
19
|
+
module DominantCycles
|
22
20
|
class DominantCyclePoint < Quant::Indicators::IndicatorPoint
|
23
21
|
attribute :smooth, default: 0.0
|
24
22
|
attribute :detrend, default: 0.0
|
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "dominant_cycle"
|
4
|
-
|
5
3
|
module Quant
|
6
|
-
|
7
|
-
|
4
|
+
module Indicators
|
5
|
+
module DominantCycles
|
8
6
|
# This dominant cycle indicator is based on the half period
|
9
7
|
# that is the midpoint of the `min_period` and `max_period`
|
10
8
|
# configured in the `Quant.config.indicators` object.
|
@@ -1,11 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "../indicator_point"
|
4
|
-
require_relative "dominant_cycle"
|
5
|
-
|
6
3
|
module Quant
|
7
|
-
|
8
|
-
|
4
|
+
module Indicators
|
5
|
+
module DominantCycles
|
9
6
|
# Homodyne means the signal is multiplied by itself. More precisely,
|
10
7
|
# we want to multiply the signal of the current bar with the complex
|
11
8
|
# value of the signal one bar ago
|
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "dominant_cycle"
|
4
|
-
|
5
3
|
module Quant
|
6
|
-
|
7
|
-
|
4
|
+
module Indicators
|
5
|
+
module DominantCycles
|
8
6
|
# The phase accumulation method of computing the dominant cycle is perhaps
|
9
7
|
# the easiest to comprehend. In this technique, we measure the phase
|
10
8
|
# at each sample by taking the arctangent of the ratio of the quadrature
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Quant
|
4
|
-
|
4
|
+
module Indicators
|
5
5
|
# A simple point used primarily to test the indicator system in unit tests.
|
6
6
|
# It has a simple computation that just sets the pong value to the input value
|
7
7
|
# and increments the compute_count by 1 each time compute is called.
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Quant
|
4
|
-
|
5
|
-
|
4
|
+
module Indicators
|
5
|
+
module Pivots
|
6
6
|
# Camarilla pivot point calculations are rather straightforward. We need to
|
7
7
|
# input the previous day’s open, high, low and close. The formulas for each
|
8
8
|
# resistance and support level are:
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Quant
|
4
|
-
|
5
|
-
|
4
|
+
module Indicators
|
5
|
+
module Pivots
|
6
6
|
# One of the key differences in calculating Woodie's Pivot Point to other pivot
|
7
7
|
# points is that the current session's open price is used in the PP formula with
|
8
8
|
# the previous session's high and low. At the time-of-day that we calculate the
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "dominant_cycles_source"
|
4
3
|
module Quant
|
5
4
|
# {Quant::IndicatorSource} holds a collection of {Quant::Indicators::Indicator} for a given input source.
|
6
5
|
# This class ensures dominant cycle computations come before other indicators that depend on them.
|
data/lib/quant/mixins/filters.rb
CHANGED
data/lib/quant/ticks/ohlc.rb
CHANGED
data/lib/quant/ticks/spot.rb
CHANGED
data/lib/quant/version.rb
CHANGED
data/lib/quantitative.rb
CHANGED
@@ -4,14 +4,31 @@ require "time"
|
|
4
4
|
require "date"
|
5
5
|
require "oj"
|
6
6
|
require "csv"
|
7
|
+
require "zeitwerk"
|
7
8
|
|
8
9
|
lib_folder = File.expand_path(File.join(File.dirname(__FILE__)))
|
9
10
|
quant_folder = File.join(lib_folder, "quant")
|
10
11
|
|
11
|
-
# require
|
12
|
-
|
12
|
+
# Explicitly require module functions since Zeitwerk isn't configured, yet.
|
13
|
+
require_relative "quant/time_methods"
|
14
|
+
require_relative "quant/config"
|
15
|
+
require_relative "quant/experimental"
|
16
|
+
module Quant
|
17
|
+
include TimeMethods
|
18
|
+
include Config
|
19
|
+
include Experimental
|
20
|
+
end
|
21
|
+
|
22
|
+
# Configure Zeitwerk to autoload the Quant module.
|
23
|
+
loader = Zeitwerk::Loader.for_gem
|
24
|
+
loader.push_dir(quant_folder, namespace: Quant)
|
25
|
+
|
26
|
+
loader.inflector.inflect "ohlc" => "OHLC"
|
27
|
+
loader.inflector.inflect "version" => "VERSION"
|
28
|
+
|
29
|
+
loader.setup
|
13
30
|
|
14
|
-
#
|
15
|
-
%w(refinements
|
31
|
+
# Refinements aren't autoloaded by Zeitwerk, so we need to require them manually.
|
32
|
+
%w(refinements).each do |sub_folder|
|
16
33
|
Dir.glob(File.join(quant_folder, sub_folder, "**/*.rb")).each { |fn| require fn }
|
17
34
|
end
|
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.3.
|
4
|
+
version: 0.3.1
|
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-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: zeitwerk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.6'
|
27
41
|
description: Quantitative and statistical tools written for Ruby 3.2+ for trading
|
28
42
|
and finance.
|
29
43
|
email:
|
@@ -51,6 +65,7 @@ files:
|
|
51
65
|
- lib/quant/dominant_cycles_source.rb
|
52
66
|
- lib/quant/errors.rb
|
53
67
|
- lib/quant/experimental.rb
|
68
|
+
- lib/quant/indicators.rb
|
54
69
|
- lib/quant/indicators/adx.rb
|
55
70
|
- lib/quant/indicators/atr.rb
|
56
71
|
- lib/quant/indicators/cci.rb
|
@@ -115,7 +130,6 @@ files:
|
|
115
130
|
- lib/quant/version.rb
|
116
131
|
- lib/quantitative.rb
|
117
132
|
- possibilities.png
|
118
|
-
- quantitative.gemspec
|
119
133
|
homepage: https://github.com/mwlang/quantitative
|
120
134
|
licenses:
|
121
135
|
- MIT
|
@@ -139,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
153
|
- !ruby/object:Gem::Version
|
140
154
|
version: '0'
|
141
155
|
requirements: []
|
142
|
-
rubygems_version: 3.5.
|
156
|
+
rubygems_version: 3.5.11
|
143
157
|
signing_key:
|
144
158
|
specification_version: 4
|
145
159
|
summary: Quantitative and statistical tools written for Ruby 3.2+ for trading and
|
data/quantitative.gemspec
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/quant/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "quantitative"
|
7
|
-
spec.version = Quant::VERSION
|
8
|
-
spec.authors = ["Michael Lang"]
|
9
|
-
spec.email = ["mwlang@cybrains.net"]
|
10
|
-
|
11
|
-
spec.summary = "Quantitative and statistical tools written for Ruby 3.2+ for trading and finance."
|
12
|
-
spec.description = spec.summary
|
13
|
-
spec.homepage = "https://github.com/mwlang/quantitative"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 3.2"
|
16
|
-
|
17
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
-
|
19
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
-
spec.metadata["changelog_uri"] = spec.homepage
|
22
|
-
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
-
spec.files = Dir.chdir(__dir__) do
|
26
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
28
|
-
end
|
29
|
-
end
|
30
|
-
spec.bindir = "exe"
|
31
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = ["lib"]
|
33
|
-
|
34
|
-
# Uncomment to register a new dependency of your gem
|
35
|
-
spec.add_dependency "oj", "~> 3.10"
|
36
|
-
|
37
|
-
# For more information and examples about making a new gem, check out our
|
38
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
-
end
|