sqa 0.0.10 → 0.0.11

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: b699ff032eee80858f9cfc3c3cba7e1ad5c0b537cd9b014085d184f4ce052451
4
- data.tar.gz: 3c7211690c31b6486718306d7e62fdf71c9466a421cfc694955a64e0d0184e66
3
+ metadata.gz: a524561e1371d56e98fb6f217ba88e377c142e06b93233eeae92cf9adeff3687
4
+ data.tar.gz: ce938d1e68f85f66da30e22428c166f28c8ea13cd93c9d8a42255390f645c034
5
5
  SHA512:
6
- metadata.gz: f8a319f9b59ce9af8cccf6ee0cd436e7847db90e95703da13ea50cf33d03cd5c5aeb996b87503f2ddc6f7991f18441be7c49a099377a19a89b6c8bd7ceb4eb3b
7
- data.tar.gz: 9b7e5b5a16f21d256c44f8a491b6f4bc0b60cc507d9124b49b12d6da9c2e487f64b0f2388ecdc4e0d24e10eb4b4f2fd69f5ca190eb5a4f51af9aba7a1123d6ea
6
+ metadata.gz: f88857d621fc46c3d5af5e0e3735304ee1f390cf5dd9ceceab25741eed080287ecdd6f46113e91ebed832baef9e78c99222cd84f6e4c2e666b0bb8a1fa82bb97
7
+ data.tar.gz: b462fe96808649c282e4ff2eddde19b0dadb8ff22e598d6b64064262e47231504ae2bef27a21960a9660ce52dbd92e0691cc5f47eb0df857b50ff4f2d3779fc1
@@ -0,0 +1 @@
1
+ 9fad1def1db23b0f3f28e116cac5032d263921d31f336dba356c5f5fb5cfe911aa73c69615710fcc22662560b96bcc2b683dc5db1044b4acb3337726d6244a45
@@ -7,14 +7,14 @@ require 'nokogiri'
7
7
  class SQA::DataFrame < Daru::DataFrame
8
8
  class YahooFinance
9
9
  CONNECTION = Faraday.new(url: 'https://finance.yahoo.com')
10
- HEADERS = %i[
11
- timestamp # 0
12
- open_price # 1
13
- high_price # 2
14
- low_price # 3
15
- close_price # 4
16
- adj_close_price # 5
17
- volume # 6
10
+ HEADERS = [
11
+ :timestamp, # 0
12
+ :open_price, # 1
13
+ :high_price, # 2
14
+ :low_price, # 3
15
+ :close_price, # 4
16
+ :adj_close_price, # 5
17
+ :volume, # 6
18
18
  ]
19
19
 
20
20
  # The Yahoo Finance Headers are being remapped so that
@@ -64,8 +64,18 @@ class SQA::DataFrame < Daru::DataFrame
64
64
  data = []
65
65
 
66
66
  rows.each do |row|
67
- cols = row.css('td').map{|c| c&.text}
67
+ cols = row.css('td').map{|c| c.children[0].text}
68
+
69
+ next unless 7 == cols.size
68
70
  next if cols[1]&.include?("Dividend")
71
+
72
+ if cols.any?(nil)
73
+ debug_me('== ERROR =='){[
74
+ :cols
75
+ ]}
76
+ next
77
+ end
78
+
69
79
  cols[0] = Date.parse(cols[0]).to_s
70
80
  cols[6] = cols[6].tr(',','').to_i
71
81
  (1..5).each {|x| cols[x] = cols[x].to_f}
@@ -60,4 +60,29 @@ class SQA::Indicator; class << self
60
60
  result
61
61
  end
62
62
 
63
+
64
+ def pnv3(prices, prediction_window)
65
+ predicted_prices = []
66
+ known = prices.last(prediction_window+2).dup
67
+
68
+ # Loop through the prediction window size
69
+ (1..prediction_window).each do |x|
70
+ current_price = known.last
71
+
72
+ # Calculate the percentage change between the current price and its previous price
73
+ percentage_change = (current_price - known[-1]) / known[-1] # .to_f
74
+
75
+ # Calculate the predicted price based on the percentage change
76
+ predicted_price = current_price + (current_price * percentage_change)
77
+ predicted_prices.unshift(predicted_price)
78
+
79
+ # Update the prices array for the next iteration
80
+ known.pop
81
+ end
82
+
83
+ predicted_prices
84
+ end
85
+
86
+
87
+
63
88
  end; end
data/lib/sqa/stock.rb CHANGED
@@ -21,10 +21,12 @@ class SQA::Stock
21
21
  df2 = @klass.recent(@ticker)
22
22
  @df = @klass.append(df1, df2)
23
23
 
24
- unless @df.size == df1.size
24
+ if @df.nrows > df1.nrows
25
25
  @df.send("to_#{@type}", SQA::DataFrame.path(@filename))
26
26
  end
27
27
 
28
+ # Adding a ticker vector in case I want to do
29
+ # some multi-stock analysis in the same data frame.
28
30
  @df[:ticker] = @ticker
29
31
  end
30
32
 
data/lib/sqa/version.rb CHANGED
@@ -4,7 +4,7 @@ require 'sem_version'
4
4
  require 'sem_version/core_ext'
5
5
 
6
6
  module SQA
7
- VERSION = "0.0.10"
7
+ VERSION = "0.0.11"
8
8
 
9
9
  class << self
10
10
  def version
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.10
4
+ version: 0.0.11
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-09 00:00:00.000000000 Z
11
+ date: 2023-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -279,6 +279,7 @@ files:
279
279
  - bin/sqa
280
280
  - checksums/sqa-0.0.1.gem.sha512
281
281
  - checksums/sqa-0.0.10.gem.sha512
282
+ - checksums/sqa-0.0.11.gem.sha512
282
283
  - checksums/sqa-0.0.2.gem.sha512
283
284
  - checksums/sqa-0.0.3.gem.sha512
284
285
  - checksums/sqa-0.0.4.gem.sha512