sqa 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/docs/average_true_range.md +9 -0
  3. data/docs/data_frame.md +164 -0
  4. data/docs/fibonacci_retracement.md +30 -0
  5. data/docs/identify_wave_condition.md +14 -0
  6. data/docs/peaks_and_valleys.md +11 -0
  7. data/docs/stochastic_oscillator.md +4 -0
  8. data/lib/sqa/cli.rb +1 -1
  9. data/lib/sqa/data_frame/yahoo_finance.rb +24 -0
  10. data/lib/sqa/data_frame.rb +11 -0
  11. data/lib/sqa/indicator/average_true_range.rb +22 -9
  12. data/lib/sqa/indicator/bollinger_bands.rb +2 -2
  13. data/lib/sqa/indicator/candlestick_pattern_recognizer.rb +1 -1
  14. data/lib/sqa/indicator/donchian_channel.rb +1 -1
  15. data/lib/sqa/indicator/double_top_bottom_pattern.rb +1 -1
  16. data/lib/sqa/indicator/elliott_wave_theory.rb +57 -0
  17. data/lib/sqa/indicator/exponential_moving_average.rb +25 -0
  18. data/lib/sqa/indicator/exponential_moving_average_trend.rb +36 -0
  19. data/lib/sqa/indicator/fibonacci_retracement.rb +5 -7
  20. data/lib/sqa/indicator/head_and_shoulders_pattern.rb +1 -1
  21. data/lib/sqa/indicator/{classify_market_profile.rb → market_profile.rb} +7 -8
  22. data/lib/sqa/indicator/mean_reversion.rb +1 -1
  23. data/lib/sqa/indicator/momentum.rb +9 -7
  24. data/lib/sqa/indicator/moving_average_convergence_divergence.rb +1 -1
  25. data/lib/sqa/indicator/peaks_and_valleys.rb +29 -0
  26. data/lib/sqa/indicator/{relative_strength_index.md.rb → relative_strength_index.rb} +2 -2
  27. data/lib/sqa/indicator/simple_moving_average.rb +6 -3
  28. data/lib/sqa/indicator/simple_moving_average_trend.rb +15 -14
  29. data/lib/sqa/indicator/stochastic_oscillator.rb +32 -3
  30. data/lib/sqa/indicator/true_range.rb +14 -12
  31. data/lib/sqa/indicator.rb +4 -4
  32. data/lib/sqa/stock.rb +6 -13
  33. data/lib/sqa/version.rb +1 -1
  34. data/lib/sqa.rb +27 -6
  35. metadata +30 -29
  36. data/lib/sqa/datastore/active_record.rb +0 -89
  37. data/lib/sqa/datastore/csv/yahoo_finance.rb +0 -51
  38. data/lib/sqa/datastore/csv.rb +0 -93
  39. data/lib/sqa/datastore/sqlite.rb +0 -7
  40. data/lib/sqa/datastore.rb +0 -6
  41. data/lib/sqa/indicator/average_true_range.md +0 -9
  42. data/lib/sqa/indicator/ema_analysis.rb +0 -70
  43. data/lib/sqa/indicator/fibonacci_retracement.md +0 -3
  44. data/lib/sqa/indicator/identify_wave_condition.md +0 -6
  45. data/lib/sqa/indicator/identify_wave_condition.rb +0 -40
  46. data/lib/sqa/indicator/stochastic_oscillator.md +0 -5
  47. /data/{lib/sqa/indicator → docs}/README.md +0 -0
  48. /data/{lib/sqa/indicator → docs}/bollinger_bands.md +0 -0
  49. /data/{lib/sqa/indicator → docs}/candlestick_pattern_recognizer.md +0 -0
  50. /data/{lib/sqa/indicator → docs}/donchian_channel.md +0 -0
  51. /data/{lib/sqa/indicator → docs}/double_top_bottom_pattern.md +0 -0
  52. /data/{lib/sqa/indicator/ema_analysis.md → docs/exponential_moving_average.md} +0 -0
  53. /data/{lib/sqa/indicator → docs}/head_and_shoulders_pattern.md +0 -0
  54. /data/{lib/sqa/indicator/classify_market_profile.md → docs/market_profile.md} +0 -0
  55. /data/{lib/sqa/indicator → docs}/mean_reversion.md +0 -0
  56. /data/{lib/sqa/indicator → docs}/momentum.md +0 -0
  57. /data/{lib/sqa/indicator → docs}/moving_average_convergence_divergence.md +0 -0
  58. /data/{lib/sqa/indicator → docs}/relative_strength_index.md +0 -0
  59. /data/{lib/sqa/indicator → docs}/simple_moving_average.md +0 -0
  60. /data/{lib/sqa/indicator → docs}/true_range.md +0 -0
@@ -1,70 +0,0 @@
1
- # lib/sqa/indicator/ema_analysis.rb
2
-
3
- module SQA::Indicator; class << self
4
-
5
- def ema_analysis(
6
- prices, # Array of prices
7
- period # Integer number of entries to consider
8
- )
9
- return {} if prices.empty? || period <= 0
10
-
11
- ema_values = []
12
- ema_values << prices.first
13
-
14
- multiplier = (2.0 / (period + 1))
15
-
16
- (1...prices.length).each do |i|
17
- ema = (prices[i] - ema_values.last) * multiplier + ema_values.last
18
- ema_values << ema.round(2)
19
- end
20
-
21
- analysis = {}
22
-
23
- analysis[:ema_values] = ema_values
24
- analysis[:trend] = ema_determine_trend(ema_values)
25
- analysis[:support] = ema_determine_support(ema_values)
26
- analysis[:resistance] = ema_determine_resistance(ema_values)
27
-
28
- analysis
29
- end
30
-
31
-
32
- # @param ema_values [Array] An array of EMA values.
33
- # @return [Symbol] The trend: :up, :down, or :sideways.
34
- #
35
- private def ema_determine_trend(ema_values)
36
- return :sideways if ema_values.empty?
37
-
38
- last_ema = ema_values.last
39
- previous_ema = ema_values[-2]
40
-
41
- if last_ema > previous_ema
42
- :up
43
- elsif last_ema < previous_ema
44
- :down
45
- else
46
- :sideways
47
- end
48
- end
49
-
50
-
51
- # @param ema_values [Array] An array of EMA values.
52
- # @return [Float] The support level.
53
- #
54
- private def ema_determine_support(ema_values)
55
- return 0.0 if ema_values.empty?
56
-
57
- ema_values.min
58
- end
59
-
60
-
61
- # @param ema_values [Array] An array of EMA values.
62
- # @return [Float] The resistance level.
63
- private def ema_determine_resistance(ema_values)
64
- return 0.0 if ema_values.empty?
65
-
66
- ema_values.max
67
- end
68
-
69
- end; end
70
-
@@ -1,3 +0,0 @@
1
- # Fibonacci Retracement
2
-
3
- Fibonacci retracement uses Fibonacci ratios to identify potential support and resistance levels based on the price's previous significant moves.
@@ -1,6 +0,0 @@
1
- # Wave Theory
2
-
3
- Wave theory, such as Elliott Wave Theory, suggests that price movements follow repetitive patterns or waves. It aims to identify and predict these patterns to make trading decisions.
4
-
5
- Identifies a wave condition in a stock's price history based on a given price series.
6
-
@@ -1,40 +0,0 @@
1
- # lib/sqa/indicator/identify_wave_condition.rb
2
-
3
- module SQA::Indicator; class << self
4
-
5
- def identify_wave_condition?(
6
- prices, # Array of prices
7
- wave_length, # Integer expected length of a wave pattern
8
- tolerance # Float delta change in price that would indicate a wave
9
- )
10
- return false if prices.length < wave_length
11
-
12
- wave_start = 0
13
- wave_end = wave_length - 1
14
-
15
- while wave_end < prices.length
16
- wave = prices[wave_start..wave_end]
17
-
18
- if wave.length == wave_length &&
19
- wave_pattern?(wave, tolerance)
20
- return true
21
- end
22
-
23
- wave_start += 1
24
- wave_end += 1
25
- end
26
-
27
- false
28
- end
29
-
30
-
31
- private def wave_pattern?(wave, tolerance)
32
- wave.each_cons(2) do |a, b|
33
- return false if (b - a).abs > tolerance
34
- end
35
-
36
- true
37
- end
38
-
39
- end; end
40
-
@@ -1,5 +0,0 @@
1
- # Stochastic Oscillator
2
-
3
- Calculates the Stochastic Oscillator for a given set of price data.
4
-
5
- Stochastic Oscillator: The Stochastic Oscillator compares a security's closing price to its price range over a specified period. It helps identify potential trend reversals and overbought/oversold conditions.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes