sqa 0.0.2 → 0.0.3

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: cc25d07a5b5662c4f07ce7cfc1446ce7de13182f100a054d799d399fbf90c87f
4
- data.tar.gz: d42fecd00d56d568011c4173ec2954bc5baa9525319e8344e4bf6c86fe7a25ca
3
+ metadata.gz: 48ca0637f3792531412ee5d07c2fd49a28f167a04f797d535a5d81e8b47907fb
4
+ data.tar.gz: e03b6c57017dab18c86a7e162ee4f9ff8c19567df92b29b0f132349959f802a9
5
5
  SHA512:
6
- metadata.gz: f609dbfdaf96ded7fc3a973fe6e51f663fe033e0ea30d6fffefa383145b90edac5b7f7164fd0896d2c33634304b5cd780f81fbe2b1ef93888a5c2db2750f6042
7
- data.tar.gz: 9b9f08cf5adf6c998d9c3fcc1df68441aef596190365218db77498b7f3f63ffca1364d49d8cf37d5407ca066f32cd16a988b0bb1a4ff4d4139358a3ad88a7b0a
6
+ metadata.gz: 5d373732f21ea218e6b2614cd8ef45d93e23e59dbfada17bded86974559c0ca4a99426bcf131ddbd5a6286edbd27e7212f1fbe9c8c3ceaa6eeca1ef9b4888451
7
+ data.tar.gz: b1c2b23bc8abd33c20c1337481c6f8e51243fe946fd6738f4cdea4f3f0c746233730f4b3cfc13710fc0f9e11dce0b248d22acfb08b21a7200599edc3a7b12a4f
data/.irbrc ADDED
@@ -0,0 +1,3 @@
1
+ # sqa/,urg
2
+
3
+ require 'sqa'
@@ -0,0 +1 @@
1
+ ad94810d7678366fc822ec4169e38e67542ebfe442ad64bd03faa6af781854e5c5943eddde65cc5f9251d7d3f7a0242f41b0da423cdc62cb9df9c9581b3b987a
data/docs/requirements.md CHANGED
@@ -38,3 +38,25 @@ Most reliable way of getting data is the scrape the website. The gem financial_
38
38
  ## Extract Indicators
39
39
 
40
40
  After sleeping on it, I think the original plan with the fin_tech gem is a better idea for how to package the indicators. I'm going to keep the name FinTech for now while I think of something better. These are indicators; but I want them to be class-level methods with established contracts in their API.
41
+
42
+ The indicators in lib/sqa/indicator are stand-alone class methods; but, its so handy to have them in this repo. I will keep them here for a while
43
+
44
+ ## Configuration
45
+
46
+ SQA::Config is managed by the gem "mixlib-config" See the gem for full documentation.
47
+
48
+ The TL;DR is:
49
+
50
+ ```ruby
51
+ require 'sqa'
52
+ # read a configuration file in yaml, toml, json, ruby
53
+ # or just accept the defaults
54
+ SQA::Config.from_file(path_to_file)
55
+
56
+ # Initialize the environment
57
+ SQA.init
58
+ ```
59
+
60
+ ## Strategy Framework
61
+
62
+ Got the first ideas for handling strategies. in place.
data/docs/strategy.md ADDED
@@ -0,0 +1,5 @@
1
+ # Strategy
2
+
3
+ A strategy is a recipe that cooks all the indicators together to make a decision on a potential trade. The SQA::Strategy class provides the framework for executing multiple strategies.
4
+
5
+ You can also think of a strategy as a set of rules like in the old days of rule-based forward/backward chaining engines. The rules are evaluated to determine whether a specific decision to trade is good or bad.
@@ -4,8 +4,13 @@
4
4
  require_relative 'data_frame/yahoo_finance'
5
5
 
6
6
  class SQA::DataFrame < Daru::DataFrame
7
+ def self.path(filename)
8
+ SQA::Config.data_dir + filename
9
+ end
10
+
7
11
  def self.from_csv(ticker)
8
- path_to_csv = SQA::Config.data_dir + "#{ticker.downcase}.csv"
9
- super(path_to_csv)
12
+ df = super(path("#{ticker.downcase}.csv"))
13
+ df[:ticker] = ticker
14
+ df
10
15
  end
11
16
  end
@@ -20,7 +20,7 @@ class SQA::Indicator; class << self
20
20
 
21
21
  {
22
22
  upper_band: upper_band, # Array
23
- pwer_band: lower_band # Array
23
+ lower_band: lower_band # Array
24
24
  }
25
25
  end
26
26
  alias_method :bb, :bollinger_bands
@@ -33,7 +33,7 @@ class SQA::Indicator; class << self
33
33
  waves.each do |wave|
34
34
  analysis << {
35
35
  wave: wave,
36
- oattern: ewt_identify_pattern(wave)
36
+ pattern: ewt_identify_pattern(wave)
37
37
  }
38
38
  end
39
39
 
@@ -11,8 +11,12 @@ class SQA::Indicator; class << self
11
11
 
12
12
  short_ma = simple_moving_average(prices, short_period)
13
13
  long_ma = simple_moving_average(prices, long_period)
14
- macd_line = short_ma.last - long_ma.last
15
- signal_line = simple_moving_average(short_ma, signal_period).last
14
+ signal_line = simple_moving_average(short_ma, signal_period)
15
+ macd_line = []
16
+
17
+ prices.size.times do |x|
18
+ macd_line << short_ma[x] - long_ma[x]
19
+ end
16
20
 
17
21
  {
18
22
  macd: macd_line, # Array
@@ -0,0 +1,65 @@
1
+ # lib/sqa/strategy.rb
2
+
3
+ class SQA::Strategy
4
+ attr_accessor :strategies
5
+
6
+ def initialize
7
+ @strategies = []
8
+ end
9
+
10
+ def add(a_proc=nil, &block)
11
+ @strategies << a_proc unless a_proc.nil?
12
+ @strategies << block if a_proc.nil? && block_given?
13
+ end
14
+
15
+ def execute(v)
16
+ result = []
17
+ # TODO: Can do this in parallel ...
18
+ @strategies.each { |signal| result << signal.call(v) }
19
+ result
20
+ end
21
+ end
22
+
23
+ __END__
24
+
25
+ Example Usage
26
+ =============
27
+
28
+ ss = SQA::Strategy.new
29
+
30
+ ss.add do |vector|
31
+ case rand(10)
32
+ when (8..)
33
+ :buy
34
+ when (..3)
35
+ :sell
36
+ else
37
+ :hold
38
+ end
39
+ end
40
+
41
+
42
+ ss.add do |vector|
43
+ case rand(10)
44
+ when (8..)
45
+ :sell
46
+ when (..3)
47
+ :buy
48
+ else
49
+ :keep
50
+ end
51
+ end
52
+
53
+ def magic(vector)
54
+ 0 == rand(2) ? :spend : :save
55
+ end
56
+
57
+ ss.add method(:magic)
58
+
59
+ class MyClass
60
+ def self.my_method(vector)
61
+ vector.rsi[:rsi]
62
+ end
63
+ end
64
+
65
+ ss.add MyClass.method(:my_method)
data/lib/sqa/version.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SQA
4
- VERSION = "0.0.2"
4
+ module Version
5
+ VERSION = "0.0.3"
6
+ end
5
7
  end
data/lib/sqa.rb CHANGED
@@ -12,22 +12,39 @@ require 'descriptive_statistics'
12
12
  require 'mixlib/config'
13
13
  require 'nenv'
14
14
  require 'pathname'
15
+ require "version_gem"
15
16
 
16
17
  unless defined?(HOME)
17
18
  HOME = Pathname.new(Nenv.home)
18
19
  end
19
20
 
21
+
20
22
  module SQA
21
23
  module Config
22
24
  extend Mixlib::Config
23
25
  config_strict_mode true
24
26
 
25
- default :data_dir, HOME + "sqa_data"
27
+ default :data_dir, HOME + "sqa_data"
28
+ default :plotting_library, :gruff
29
+ default :lazy_update, false
30
+ end
31
+
32
+ def self.init
33
+ Daru.lazy_update = Config.lazy_update
34
+ Daru.plotting_library = Config.plotting_library
35
+
36
+ nil
26
37
  end
27
38
  end
28
39
 
29
40
  require_relative "sqa/data_frame"
30
41
  require_relative "sqa/errors"
31
42
  require_relative "sqa/indicator"
43
+ require_relative "sqa/strategy"
32
44
  require_relative "sqa/stock"
33
45
  require_relative "sqa/version"
46
+
47
+
48
+ SQA::Version.class_eval do
49
+ extend VersionGem::Basic
50
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-08-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simplistic playpen (e.g. not for serious use) for doing technical analysis
14
14
  of stock prices.
@@ -20,12 +20,14 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - ".envrc"
23
+ - ".irbrc"
23
24
  - CHANGELOG.md
24
25
  - LICENSE
25
26
  - README.md
26
27
  - Rakefile
27
28
  - bin/sqa
28
29
  - checksums/sqa-0.0.1.gem.sha512
30
+ - checksums/sqa-0.0.2.gem.sha512
29
31
  - docs/README.md
30
32
  - docs/average_true_range.md
31
33
  - docs/bollinger_bands.md
@@ -46,6 +48,7 @@ files:
46
48
  - docs/requirements.md
47
49
  - docs/simple_moving_average.md
48
50
  - docs/stochastic_oscillator.md
51
+ - docs/strategy.md
49
52
  - docs/true_range.md
50
53
  - lib/sqa.rb
51
54
  - lib/sqa/activity.rb
@@ -76,6 +79,7 @@ files:
76
79
  - lib/sqa/indicator/true_range.rb
77
80
  - lib/sqa/protfolio.rb
78
81
  - lib/sqa/stock.rb
82
+ - lib/sqa/strategy.rb
79
83
  - lib/sqa/version.rb
80
84
  homepage: https://github.com/MadBomber/sqa
81
85
  licenses: