sqa 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8dd371b757bcc5da8e913681a06666715cbe88ca11f582df64d68ef305391d28
4
- data.tar.gz: 8b1851af5e7875266acbd3fb35a7ba108fdb267d7490eb19984819bba5f15538
3
+ metadata.gz: 0fcc7dbda5b62549fa1fb9691bf7ef9af1a0ba5dfcff63494ce2cdf6ca7e578a
4
+ data.tar.gz: 9527508fa1573a09536ef4bf735671761d722d1611494d3aeb8615ba25385f2c
5
5
  SHA512:
6
- metadata.gz: ab803635e2f85e71bebacab6be10cc345f6050a890c730a658741d4a3ae4530490be33fc692a3ced0e843e473cc5613644dc5a0c0d0bfd3a43d5c0d2b4d41510
7
- data.tar.gz: 7ee788d760d4020efb41baa3f5bc894cc4824d0308144b68f8c352bed03a01ce2049547bace95636264fab1c7b58ab12f97c99209433e2b32719db575017d25c
6
+ metadata.gz: c5ce2164cd95cf91c62e054dad4fef84ed105d7713207bf5f5e39fbad282785184217ed303fe73b24801b871e9ca0db371c0f514949803aace37b788ebec6140
7
+ data.tar.gz: f7336d71e365388d571267e87fbdd82a66dbd532da8e386e9670e1a9f7034d2279202e6df16ce30d14410b2ab39923ecf4bb78e0941b554bf11ee3101fdb9a41
@@ -0,0 +1 @@
1
+ 524fd82ea9501f1b1b1a3bf3e0f1a500e675d3f4664d342b8b377995f310c1e40a597f61d8e0bf8d2fa8dd83202f7a415b517df371dbf370c25f59fb0fb42d96
@@ -0,0 +1 @@
1
+ ae291d1c8a3a80fc6f24a6a1194c6db1b6e1fbdbee586546ae34db6ee304a3e431ea59a154ea976af0f25f3b0d6519f2e0a1aad4ddf3c3cdf77b7d37aabf425f
@@ -0,0 +1 @@
1
+ d4f3ab1bf26de034f0f044a5cab9d86e61221fc2d160056c1c24c166586e7ce72d90095ebea01965f5cabf989c4116e7409f8fc6749cabe7d5a13e34f87f4b96
@@ -0,0 +1,62 @@
1
+ # Alpha Vantage
2
+ ## Technical Indicators
3
+
4
+ The following technical indicators are available from Alpha Vantage
5
+ using a free API key.
6
+
7
+ | Acronym | Indicator Description |
8
+ |-----------|----------------------------------------------------------|
9
+ | AD | Accumulation/Distribution |
10
+ | ADOSC | Accumulation/Distribution Oscillator |
11
+ | ADX | Average Directional Index |
12
+ | ADXR | Average Directional Movement Rating |
13
+ | APO | Absolute Price Oscillator |
14
+ | AROON | Aroon Indicator |
15
+ | AROONOSC | Aroon Oscillator |
16
+ | ATR | Average True Range |
17
+ | BBANDS | Bollinger Bands |
18
+ | BOP | Balance of Power |
19
+ | CCI | Commodity Channel Index |
20
+ | CMO | Chande Momentum Oscillator |
21
+ | DEMA | Double Exponential Moving Average |
22
+ | DX | Directional Movement Index |
23
+ | EMA | Exponential Moving Average |
24
+ | HT_DCPERIOD | Hilbert Transform - Dominant Cycle Period |
25
+ | HT_DCPHASE | Hilbert Transform - Dominant Cycle Phase |
26
+ | HT_PHASOR | Hilbert Transform - Phasor Components |
27
+ | HT_SINE | Hilbert Transform - SineWave |
28
+ | HT_TRENDLINE | Hilbert Transform - Instantaneous Trendline |
29
+ | HT_TRENDMODE | Hilbert Transform - Trend vs Cycle Mode |
30
+ | KAMA | Kaufman Adaptive Moving Average |
31
+ | MACD | Moving Average Convergence Divergence |
32
+ | MACDEXT | MACD with controllable MA type |
33
+ | MAMA | MESA Adaptive Moving Average |
34
+ | MFI | Money Flow Index |
35
+ | MIDPOINT | MidPoint over period |
36
+ | MIDPRICE | Midpoint Price over period |
37
+ | MINUS_DI | Minus Directional Indicator |
38
+ | MINUS_DM | Minus Directional Movement |
39
+ | MOM | Momentum |
40
+ | NATR | Normalized Average True Range |
41
+ | OBV | On Balance Volume |
42
+ | PLUS_DI | Plus Directional Indicator |
43
+ | PLUS_DM | Plus Directional Movement |
44
+ | PPO | Percentage Price Oscillator |
45
+ | ROC | Rate of Change |
46
+ | ROCR | Rate of Change Ratio |
47
+ | RSI | Relative Strength Index |
48
+ | SAR | Parabolic SAR |
49
+ | SMA | Simple Moving Average |
50
+ | STOCH | Stochastic Oscillator |
51
+ | STOCHF | Stochastic Fast |
52
+ | STOCHRSI | Stochastic Relative Strength Index |
53
+ | T3 | Triple Exponential Moving Average (T3) |
54
+ | TEMA | Triple Exponential Moving Average |
55
+ | TRANGE | True Range |
56
+ | TRIMA | Triangular Moving Average |
57
+ | TRIX | 1-day Rate of Change of a Triple Smooth EMA |
58
+ | ULTOSC | Ultimate Oscillator |
59
+ | VWAP | Volume Weighted Average Price |
60
+ | WILLR | Williams' %R |
61
+ | WMA | Weighted Moving Average |
62
+
@@ -1,6 +1,5 @@
1
1
  # lib/patches/daru/plotting/svg-graph.rb
2
2
 
3
- require 'svg-graph'
4
3
 
5
4
  require_relative 'SvgGraph/category.rb'
6
5
  require_relative 'SvgGraph/vector.rb'
data/lib/sqa/cli.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # lib/sqa/cli.rb
2
2
 
3
- require 'tty-option'
4
3
 
5
4
  require_relative '../sqa'
6
5
 
data/lib/sqa/config.rb CHANGED
@@ -6,17 +6,18 @@
6
6
  # config file ..... overrides envar
7
7
  # command line parameters ...... overrides config file
8
8
 
9
- require 'hashie'
10
- require 'yaml'
11
- require 'json'
12
- require 'toml-rb'
13
-
14
9
 
15
10
  module SQA
16
11
  class Config < Hashie::Dash
17
12
  include Hashie::Extensions::Dash::PropertyTranslation
18
13
  include Hashie::Extensions::Coercion
19
- include Hashie::Extensions::Dash::PredefinedValues
14
+
15
+ # FIXME: Getting undefined error PredefinedValues
16
+ # I'm thinking that Ruby is dropping it from the ObjectSpace
17
+ # Looks like it is only used for the log level. Should
18
+ # able to work around that.
19
+ #
20
+ # include Hashie::Extensions::Dash::PredefinedValues
20
21
 
21
22
  property :config_file #,a String filepath for the current config overriden by cli options
22
23
  property :dump_config # a String filepath into which to dump the current config
@@ -4,8 +4,6 @@
4
4
  # Using the Alpha Vantage JSON interface
5
5
  #
6
6
 
7
- require 'faraday'
8
- require 'json'
9
7
 
10
8
  class SQA::DataFrame < Daru::DataFrame
11
9
  class AlphaVantage
@@ -1,8 +1,6 @@
1
1
  # lib/sqa/data_frame/yahoo_finance.rb
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'faraday'
5
- require 'nokogiri'
6
4
 
7
5
  class SQA::DataFrame < Daru::DataFrame
8
6
  class YahooFinance
data/lib/sqa/init.rb ADDED
@@ -0,0 +1,46 @@
1
+ # sqa/lib/sqa/init.rb
2
+
3
+ module SQA
4
+ class << self
5
+ @@config = nil
6
+
7
+ # Initializes the SQA modules
8
+ # returns the configuration
9
+ #
10
+ def init(argv=ARGV)
11
+ if argv.is_a? String
12
+ argv = argv.split()
13
+ end
14
+
15
+
16
+ # Ran at SQA::Config elaboration time
17
+ # @@config = Config.new
18
+
19
+ if defined? CLI
20
+ CLI.run(argv)
21
+ else
22
+ # There are no real command line parameters
23
+ # because the sqa gem is being required within
24
+ # the context of a larger program.
25
+ end
26
+
27
+ config.data_dir = homify(config.data_dir)
28
+
29
+ Daru.lazy_update = config.lazy_update
30
+ Daru.plotting_library = config.plotting_library
31
+
32
+ config
33
+ end
34
+
35
+ def debug?() = @@config.debug?
36
+ def verbose?() = @@config.verbose?
37
+
38
+ def homify(filepath) = filepath.gsub(/^~/, Nenv.home)
39
+ def data_dir() = Pathname.new(config.data_dir)
40
+ def config() = @@config
41
+
42
+ def config=(an_object)
43
+ @@config = an_object
44
+ end
45
+ end
46
+ end
data/lib/sqa/stock.rb CHANGED
@@ -1,6 +1,13 @@
1
1
  # lib/sqa/stock.rb
2
2
 
3
+
4
+ # SMELL: SQA::Stock is now pretty coupled to the Alpha Vantage
5
+ # API service. Should that stuff be extracted into a
6
+ # separate class and injected by the requiring program?
7
+
3
8
  class SQA::Stock
9
+ CONNECTION = Faraday.new(url: "https://www.alphavantage.co")
10
+
4
11
  attr_accessor :company_name
5
12
  attr_accessor :df # The DataFrane
6
13
  attr_accessor :ticker
@@ -51,4 +58,72 @@ class SQA::Stock
51
58
  def to_s
52
59
  "#{ticker} with #{@df.size} data points from #{@df.timestamp.first} to #{@df.timestamp.last}"
53
60
  end
61
+
62
+ # TODO: Turn this into a class Stock::Overview
63
+ # which is a sub-class of Hashie::Dash
64
+ def overview
65
+ return @overview unless @overview.nil?
66
+
67
+ temp = JSON.parse(
68
+ CONNECTION.get("/query?function=OVERVIEW&symbol=#{@ticker.upcase}&apikey=#{Nenv.av_api_key}")
69
+ .to_hash[:body]
70
+ )
71
+
72
+ # TODO: CamelCase hash keys look common in Alpha Vantage
73
+ # JSON; look at making a special Hashie-based class
74
+ # to convert the keys to normal Ruby standards.
75
+
76
+ temp2 = {}
77
+
78
+ string_values = %w[ address asset_type cik country currency description dividend_date ex_dividend_date exchange fiscal_year_end industry latest_quarter name sector symbol ]
79
+
80
+ temp.keys.each do |k|
81
+ new_k = k.underscore
82
+ temp2[new_k] = string_values.include?(new_k) ? temp[k] : temp[k].to_f
83
+ end
84
+
85
+ @overview = Hashie::Mash.new temp2
86
+ end
87
+
88
+
89
+ #############################################
90
+ ## Class Methods
91
+
92
+ class << self
93
+ @@top = nil
94
+
95
+ # Top Gainers, Losers and Most Active for most
96
+ # recent closed trading day.
97
+ #
98
+ def top
99
+ return @@top unless @@top.nil?
100
+
101
+ a_hash = JSON.parse(
102
+ CONNECTION.get(
103
+ "/query?function=TOP_GAINERS_LOSERS&apikey=#{Nenv.av_api_key}"
104
+ ).to_hash[:body]
105
+ )
106
+
107
+ mash = Hashie::Mash.new(a_hash)
108
+
109
+ keys = mash.top_gainers.first.keys
110
+
111
+ %w[top_gainers top_losers most_actively_traded].each do |collection|
112
+ mash.send(collection).each do |e|
113
+ keys.each do |k|
114
+ case k
115
+ when 'ticker'
116
+ # Leave it as a String
117
+ when 'volume'
118
+ e[k] = e[k].to_i
119
+ else
120
+ e[k] = e[k].to_f
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+ @@top = mash
127
+ end
128
+ end
54
129
  end
data/lib/sqa/version.rb CHANGED
@@ -1,10 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'sem_version'
4
- require 'sem_version/core_ext'
5
-
6
3
  module SQA
7
- VERSION = "0.0.13"
4
+ VERSION = "0.0.15"
8
5
 
9
6
  class << self
10
7
  def version
data/lib/sqa/web.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # lib/sqa/command/web.rb
2
2
 
3
- require 'tty-option'
3
+ # require 'tty-option'
4
4
 
5
5
 
6
6
  module SQA
data/lib/sqa.rb CHANGED
@@ -1,79 +1,57 @@
1
1
  # lib/sqa.rb
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'active_support'
5
- require 'active_support/core_ext/string'
6
- require 'daru'
7
- require 'date'
8
- require 'descriptive_statistics'
9
- require 'nenv'
10
- require 'pathname'
4
+ # TODO: Create a new gem for the dumbstockapi website
11
5
 
12
- require_relative "sqa/version"
13
- require_relative "sqa/errors"
6
+ #############################################
7
+ ## Standard Libraries
14
8
 
9
+ require 'date'
10
+ require 'pathname'
15
11
 
16
12
  unless defined?(HOME)
17
- HOME = Pathname.new(Nenv.home)
13
+ HOME = Pathname.new(ENV['HOME'])
18
14
  end
19
15
 
16
+ #############################################
17
+ ## Additional Libraries
20
18
 
21
- module SQA
22
- class << self
23
- @@config = nil
24
-
25
- def init(argv=ARGV)
26
- if argv.is_a? String
27
- argv = argv.split()
28
- end
29
-
30
-
31
- # Ran at SQA::Config elaboration time
32
- # @@config = Config.new
33
-
34
- if defined? CLI
35
- CLI.run(argv)
36
- else
37
- # There are no real command line parameters
38
- # because the sqa gem is being required within
39
- # the context of a larger program.
40
- end
41
-
42
- config.data_dir = homify(config.data_dir)
43
-
44
- Daru.lazy_update = config.lazy_update
45
- Daru.plotting_library = config.plotting_library
46
-
47
- if config.debug? || config.verbose?
48
- debug_me{[
49
- :config
50
- ]}
51
- end
19
+ require 'active_support/core_ext/string'
20
+ require 'alphavantage' # TODO: add rate limiter to it
21
+ require 'amazing_print'
22
+ require 'daru' # TODO: Replace this gem with something better
23
+ require 'descriptive_statistics'
24
+ require 'faraday'
25
+ require 'hashie'
26
+ require 'nenv'
27
+ require 'sem_version'
28
+ require 'sem_version/core_ext'
29
+ require 'tty-option'
30
+ require 'tty-table'
52
31
 
53
- nil
54
- end
55
32
 
56
- def debug?() = @@config.debug?
57
- def verbose?() = @@config.verbose?
33
+ #############################################
34
+ ## SQA soecufuc code
58
35
 
59
- def homify(filepath) = filepath.gsub(/^~/, Nenv.home)
60
- def data_dir() = Pathname.new(config.data_dir)
61
- def config() = @@config
36
+ require_relative "sqa/version"
37
+ require_relative "sqa/errors"
62
38
 
63
- def config=(an_object)
64
- @@config = an_object
65
- end
66
- end
67
- end
39
+ require_relative 'sqa/init.rb'
68
40
 
69
41
  # require_relative "patches/daru" # TODO: extract Daru::DataFrame in new gem sqa-data_frame
70
42
 
43
+ # TODO: Some of these components make direct calls to the
44
+ # Alpha Vantage API. Convert them to use the
45
+ # alphavantage gem.
46
+
71
47
  require_relative "sqa/config"
72
- require_relative "sqa/constants"
73
- require_relative "sqa/data_frame"
48
+ require_relative "sqa/constants" # SMELL: more app than gem
49
+ require_relative "sqa/data_frame" # TODO: drop the daru gem
74
50
  require_relative "sqa/indicator"
75
51
  require_relative "sqa/portfolio"
76
52
  require_relative "sqa/strategy"
77
53
  require_relative "sqa/stock"
78
54
  require_relative "sqa/ticker"
79
- require_relative "sqa/trade"
55
+ require_relative "sqa/trade" # SMELL: Not really a core gem; more of an application thing
56
+
57
+
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.13
4
+ version: 0.0.15
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-09-22 00:00:00.000000000 Z
11
+ date: 2023-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: daru
28
+ name: alphavantage
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,49 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: descriptive_statistics
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: hashie
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: nenv
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: tty-logger
42
+ name: daru
85
43
  requirement: !ruby/object:Gem::Requirement
86
44
  requirements:
87
45
  - - ">="
@@ -95,7 +53,7 @@ dependencies:
95
53
  - !ruby/object:Gem::Version
96
54
  version: '0'
97
55
  - !ruby/object:Gem::Dependency
98
- name: tty-markdown
56
+ name: descriptive_statistics
99
57
  requirement: !ruby/object:Gem::Requirement
100
58
  requirements:
101
59
  - - ">="
@@ -109,7 +67,7 @@ dependencies:
109
67
  - !ruby/object:Gem::Version
110
68
  version: '0'
111
69
  - !ruby/object:Gem::Dependency
112
- name: tty-option
70
+ name: faraday
113
71
  requirement: !ruby/object:Gem::Requirement
114
72
  requirements:
115
73
  - - ">="
@@ -123,21 +81,21 @@ dependencies:
123
81
  - !ruby/object:Gem::Version
124
82
  version: '0'
125
83
  - !ruby/object:Gem::Dependency
126
- name: tty-progressbar
84
+ name: hashie
127
85
  requirement: !ruby/object:Gem::Requirement
128
86
  requirements:
129
- - - ">="
87
+ - - "~>"
130
88
  - !ruby/object:Gem::Version
131
- version: '0'
89
+ version: 4.1.0
132
90
  type: :runtime
133
91
  prerelease: false
134
92
  version_requirements: !ruby/object:Gem::Requirement
135
93
  requirements:
136
- - - ">="
94
+ - - "~>"
137
95
  - !ruby/object:Gem::Version
138
- version: '0'
96
+ version: 4.1.0
139
97
  - !ruby/object:Gem::Dependency
140
- name: tty-prompt
98
+ name: nenv
141
99
  requirement: !ruby/object:Gem::Requirement
142
100
  requirements:
143
101
  - - ">="
@@ -151,7 +109,7 @@ dependencies:
151
109
  - !ruby/object:Gem::Version
152
110
  version: '0'
153
111
  - !ruby/object:Gem::Dependency
154
- name: tty-reader
112
+ name: sem_version
155
113
  requirement: !ruby/object:Gem::Requirement
156
114
  requirements:
157
115
  - - ">="
@@ -165,7 +123,7 @@ dependencies:
165
123
  - !ruby/object:Gem::Version
166
124
  version: '0'
167
125
  - !ruby/object:Gem::Dependency
168
- name: tty-spinner
126
+ name: tty-option
169
127
  requirement: !ruby/object:Gem::Requirement
170
128
  requirements:
171
129
  - - ">="
@@ -281,6 +239,9 @@ files:
281
239
  - checksums/sqa-0.0.10.gem.sha512
282
240
  - checksums/sqa-0.0.11.gem.sha512
283
241
  - checksums/sqa-0.0.12.gem.sha512
242
+ - checksums/sqa-0.0.13.gem.sha512
243
+ - checksums/sqa-0.0.14.gem.sha512
244
+ - checksums/sqa-0.0.15.gem.sha512
284
245
  - checksums/sqa-0.0.2.gem.sha512
285
246
  - checksums/sqa-0.0.3.gem.sha512
286
247
  - checksums/sqa-0.0.4.gem.sha512
@@ -291,6 +252,7 @@ files:
291
252
  - checksums/sqa-0.0.9.gem.sha512
292
253
  - docs/.gitignore
293
254
  - docs/README.md
255
+ - docs/alpha_vantage_technical_indicators.md
294
256
  - docs/average_true_range.md
295
257
  - docs/bollinger_bands.md
296
258
  - docs/candlestick_pattern_recognizer.md
@@ -354,6 +316,7 @@ files:
354
316
  - lib/sqa/indicator/simple_moving_average_trend.rb
355
317
  - lib/sqa/indicator/stochastic_oscillator.rb
356
318
  - lib/sqa/indicator/true_range.rb
319
+ - lib/sqa/init.rb
357
320
  - lib/sqa/portfolio.rb
358
321
  - lib/sqa/stock.rb
359
322
  - lib/sqa/strategy.rb