sqa 0.0.18 → 0.0.19

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: b7733f5cb84c4ccbad5e68105e818b35f1aca450fd97eeb3186cfb9a1962d44e
4
- data.tar.gz: a9b2bf2a0fa6a91de1367fd73beac6a28d263024ded37c216520120cc3181cc9
3
+ metadata.gz: a8dd5577340edd8f74a73428779129e4f97bcfbb4b8eaa23ce02c6b1f290baa4
4
+ data.tar.gz: fa03b7e2203edbb69da04b9ff022776a6932a481e33a7290e4ff46b573375a89
5
5
  SHA512:
6
- metadata.gz: 27280c675c37a92f450d5108c40848cc65a3975e8e783ca25cbbee0bfa18b1c570d697c4c33d4fd73d84c57d717df3e6cbb8667c51fb3ed8fe48df509f9d1f7e
7
- data.tar.gz: 475333a102814f5bef21dbea61126bf6b0b61836cccb6a333acc2dbcaa2ba5bc14c8c9191b31065777ca984fcec883fb37da36b07a9121f2afeb0a0004bc841b
6
+ metadata.gz: ca34483321c0ac6391d322acef9ed2a9ba5d1e87db15201d4c89f760346e1c620b1ce5182cf203c393b118703a743bf535f84e52f099bad12445eacc1b82d39b
7
+ data.tar.gz: 89cb9767f3febdc9e20970e0d73a679f378f75260b4e6b146bd413dc49d942200a60f03c2ecb7f02ae6e87662ece5744fa45aead39d147fa7aad81d2037128fc
@@ -0,0 +1 @@
1
+ be42cf0864e1e35a06e177102943577683057e0023751a35421939fc6e096b0e1d16d2e218e33c9c363b45a5a9f57ed22d4361766365154433f5eb371210fb48
@@ -0,0 +1,58 @@
1
+ # sqa/lib/patches/string.rb
2
+
3
+
4
+ #####################################################################
5
+ ###
6
+ ## File: string.rb
7
+ ## Desc: Monkey to the String class.
8
+ #
9
+
10
+ class String
11
+
12
+ ##################################
13
+ ## Convert CamelCase to camel_case
14
+ def to_underscore
15
+ self.gsub(/::/, '/')
16
+ .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
17
+ .gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("- ", "_")
18
+ .downcase
19
+ end
20
+
21
+ alias :to_snakecase :to_underscore
22
+ alias :snakecase :to_underscore
23
+ alias :snake_case :to_underscore
24
+ alias :underscore :to_underscore
25
+
26
+
27
+ ##################################
28
+ ## Convert camel_case to CamelCase
29
+ def to_camelcase
30
+ self.gsub(/\/(.?)/) { "::" + $1.upcase }
31
+ .gsub(/(^|_)(.)/) { $2.upcase }
32
+ end
33
+
34
+ alias :camelcase :to_camelcase
35
+ alias :camelize :to_camelcase
36
+
37
+
38
+ ##################################
39
+ ## Convert "CamelCase" into CamelCase
40
+ def to_constant
41
+ names = self.split('::')
42
+ names.shift if names.empty? || names.first.empty?
43
+
44
+ constant = Object
45
+ names.each do |name|
46
+ if '1.9' == RUBY_VERSION[0,3]
47
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
48
+ else
49
+ constant = constant.const_get(name) || constant.const_missing(name)
50
+ end
51
+ end
52
+ constant
53
+ end
54
+
55
+ alias :constantize :to_constant
56
+ end
57
+
58
+
@@ -74,9 +74,11 @@ class SQA::DataFrame
74
74
  def_delegator :@data, :[]=, :[]=
75
75
 
76
76
 
77
+ # same as values.transpose
78
+ # TODO: do benchmark to see if the transpose method if faster
77
79
  def rows
78
80
  result = []
79
- (0..size - 1).each do |x|
81
+ size.times do |x|
80
82
  entry = row(x)
81
83
  result << entry
82
84
  end
@@ -110,14 +112,14 @@ class SQA::DataFrame
110
112
  end
111
113
 
112
114
 
113
- def append(new_df)
115
+ def append!(new_df)
114
116
  raise(BadParameterError, "Key mismatch") if keys != new_df.keys
115
117
 
116
118
  keys.each do |key|
117
119
  @data[key] += new_df[key]
118
120
  end
119
121
  end
120
- alias_method :concat, :append
122
+ alias_method :concat!, :append!
121
123
 
122
124
 
123
125
  # Creates a new instance with new keys
@@ -144,7 +146,7 @@ class SQA::DataFrame
144
146
  # price: -> (v) {v.to_f.round(3)}
145
147
  # }
146
148
  #
147
- def coerce_vectors(transformers)
149
+ def coerce_vectors!(transformers)
148
150
  transformers.each_pair do |key, transformer|
149
151
  @data[key].map!{|v| transformer.call(v)}
150
152
  end
@@ -170,8 +172,8 @@ class SQA::DataFrame
170
172
  #################################################
171
173
  class << self
172
174
 
173
- def append(base_df, other_df)
174
- base_df.append(other_df)
175
+ def concat(base_df, other_df)
176
+ base_df.concat!(other_df)
175
177
  end
176
178
 
177
179
 
@@ -191,7 +193,7 @@ class SQA::DataFrame
191
193
  end
192
194
 
193
195
  unless transformers.empty?
194
- df.coerce_vectors(transformers)
196
+ df.coerce_vectors!(transformers)
195
197
  end
196
198
 
197
199
  df
data/lib/sqa/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SQA
4
- VERSION = "0.0.18"
4
+ VERSION = "0.0.19"
5
5
 
6
6
  class << self
7
7
  def version
data/lib/sqa.rb CHANGED
@@ -16,8 +16,7 @@ end
16
16
  #############################################
17
17
  ## Additional Libraries
18
18
 
19
- require 'active_support/core_ext/string'
20
- require 'alphavantage' # TODO: add rate limiter to it; ** PR submitted! **
19
+ require 'alphavantage'
21
20
  require 'api_key_manager'
22
21
  require 'amazing_print'
23
22
  require 'faraday'
@@ -31,6 +30,12 @@ require 'tty-option'
31
30
  require 'tty-table'
32
31
 
33
32
 
33
+ #############################################
34
+ ## Apply core class monkey patches
35
+
36
+ require_relative "patches/string.rb"
37
+
38
+
34
39
  #############################################
35
40
  ## SQA soecufuc code
36
41
 
@@ -46,7 +51,7 @@ require_relative 'sqa/init.rb'
46
51
 
47
52
  require_relative "sqa/config"
48
53
  require_relative "sqa/constants" # SMELL: more app than gem
49
- require_relative "sqa/data_frame" # TODO: drop the daru gem
54
+ require_relative "sqa/data_frame"
50
55
  require_relative "sqa/indicator"
51
56
  require_relative "sqa/portfolio"
52
57
  require_relative "sqa/strategy"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
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-10-18 00:00:00.000000000 Z
11
+ date: 2023-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 7.0.6
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 7.0.6
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: alphavantage
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -243,6 +229,7 @@ files:
243
229
  - checksums/sqa-0.0.15.gem.sha512
244
230
  - checksums/sqa-0.0.17.gem.sha512
245
231
  - checksums/sqa-0.0.18.gem.sha512
232
+ - checksums/sqa-0.0.19.gem.sha512
246
233
  - checksums/sqa-0.0.2.gem.sha512
247
234
  - checksums/sqa-0.0.3.gem.sha512
248
235
  - checksums/sqa-0.0.4.gem.sha512
@@ -277,6 +264,7 @@ files:
277
264
  - docs/stochastic_oscillator.md
278
265
  - docs/strategy.md
279
266
  - docs/true_range.md
267
+ - lib/patches/string.rb
280
268
  - lib/sqa.rb
281
269
  - lib/sqa/activity.rb
282
270
  - lib/sqa/analysis.rb