sqa 0.0.32 → 0.0.37

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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +92 -1
  3. data/README.md +4 -0
  4. data/Rakefile +52 -10
  5. data/docs/IMPROVEMENT_PLAN.md +531 -0
  6. data/docs/advanced/index.md +1 -13
  7. data/docs/api/index.md +547 -61
  8. data/docs/api-reference/alphavantageapi.md +1057 -0
  9. data/docs/api-reference/apierror.md +31 -0
  10. data/docs/api-reference/index.md +221 -0
  11. data/docs/api-reference/notimplemented.md +27 -0
  12. data/docs/api-reference/sqa.md +267 -0
  13. data/docs/api-reference/sqa_backtest.md +137 -0
  14. data/docs/api-reference/sqa_backtest_results.md +530 -0
  15. data/docs/api-reference/sqa_badparametererror.md +13 -0
  16. data/docs/api-reference/sqa_config.md +538 -0
  17. data/docs/api-reference/sqa_configurationerror.md +13 -0
  18. data/docs/api-reference/sqa_datafetcherror.md +56 -0
  19. data/docs/api-reference/sqa_dataframe.md +752 -0
  20. data/docs/api-reference/sqa_dataframe_alphavantage.md +30 -0
  21. data/docs/api-reference/sqa_dataframe_data.md +325 -0
  22. data/docs/api-reference/sqa_dataframe_yahoofinance.md +25 -0
  23. data/docs/api-reference/sqa_ensemble.md +413 -0
  24. data/docs/api-reference/sqa_fpop.md +211 -0
  25. data/docs/api-reference/sqa_geneticprogram.md +325 -0
  26. data/docs/api-reference/sqa_geneticprogram_individual.md +114 -0
  27. data/docs/api-reference/sqa_marketregime.md +212 -0
  28. data/docs/api-reference/sqa_multitimeframe.md +227 -0
  29. data/docs/api-reference/sqa_patternmatcher.md +195 -0
  30. data/docs/api-reference/sqa_pluginmanager.md +55 -0
  31. data/docs/api-reference/sqa_portfolio.md +455 -0
  32. data/docs/api-reference/sqa_portfolio_position.md +220 -0
  33. data/docs/api-reference/sqa_portfolio_trade.md +332 -0
  34. data/docs/api-reference/sqa_portfoliooptimizer.md +248 -0
  35. data/docs/api-reference/sqa_riskmanager.md +388 -0
  36. data/docs/api-reference/sqa_seasonalanalyzer.md +121 -0
  37. data/docs/api-reference/sqa_sectoranalyzer.md +163 -0
  38. data/docs/api-reference/sqa_stock.md +649 -0
  39. data/docs/api-reference/sqa_strategy.md +178 -0
  40. data/docs/api-reference/sqa_strategy_bollingerbands.md +26 -0
  41. data/docs/api-reference/sqa_strategy_common.md +29 -0
  42. data/docs/api-reference/sqa_strategy_consensus.md +129 -0
  43. data/docs/api-reference/sqa_strategy_ema.md +41 -0
  44. data/docs/api-reference/sqa_strategy_kbs.md +154 -0
  45. data/docs/api-reference/sqa_strategy_macd.md +26 -0
  46. data/docs/api-reference/sqa_strategy_mp.md +41 -0
  47. data/docs/api-reference/sqa_strategy_mr.md +41 -0
  48. data/docs/api-reference/sqa_strategy_random.md +41 -0
  49. data/docs/api-reference/sqa_strategy_rsi.md +41 -0
  50. data/docs/api-reference/sqa_strategy_sma.md +41 -0
  51. data/docs/api-reference/sqa_strategy_stochastic.md +26 -0
  52. data/docs/api-reference/sqa_strategy_volumebreakout.md +26 -0
  53. data/docs/api-reference/sqa_strategygenerator.md +298 -0
  54. data/docs/api-reference/sqa_strategygenerator_pattern.md +264 -0
  55. data/docs/api-reference/sqa_strategygenerator_patterncontext.md +326 -0
  56. data/docs/api-reference/sqa_strategygenerator_profitablepoint.md +424 -0
  57. data/docs/api-reference/sqa_stream.md +256 -0
  58. data/docs/api-reference/sqa_ticker.md +175 -0
  59. data/docs/api-reference/string.md +135 -0
  60. data/docs/assets/images/advanced-workflow.svg +89 -0
  61. data/docs/assets/images/architecture.svg +107 -0
  62. data/docs/assets/images/data-flow.svg +138 -0
  63. data/docs/assets/images/getting-started-workflow.svg +88 -0
  64. data/docs/assets/images/strategy-flow.svg +78 -0
  65. data/docs/assets/images/system-architecture.svg +150 -0
  66. data/docs/concepts/index.md +292 -19
  67. data/docs/getting-started/index.md +1 -14
  68. data/docs/index.md +26 -23
  69. data/docs/llms.txt +109 -0
  70. data/docs/strategies/kbs.md +15 -14
  71. data/docs/strategy.md +381 -3
  72. data/docs/terms_of_use.md +1 -1
  73. data/examples/README.md +10 -0
  74. data/lib/api/alpha_vantage_api.rb +3 -7
  75. data/lib/sqa/config.rb +109 -28
  76. data/lib/sqa/data_frame/data.rb +13 -1
  77. data/lib/sqa/data_frame.rb +168 -26
  78. data/lib/sqa/errors.rb +79 -17
  79. data/lib/sqa/init.rb +70 -15
  80. data/lib/sqa/pattern_matcher.rb +4 -4
  81. data/lib/sqa/portfolio.rb +1 -1
  82. data/lib/sqa/sector_analyzer.rb +3 -11
  83. data/lib/sqa/stock.rb +169 -15
  84. data/lib/sqa/strategy.rb +62 -4
  85. data/lib/sqa/ticker.rb +106 -48
  86. data/lib/sqa/version.rb +1 -1
  87. data/lib/sqa.rb +4 -4
  88. data/mkdocs.yml +68 -81
  89. metadata +89 -21
  90. data/docs/README.md +0 -43
  91. data/examples/sinatra_app/Gemfile +0 -42
  92. data/examples/sinatra_app/Gemfile.lock +0 -268
  93. data/examples/sinatra_app/QUICKSTART.md +0 -169
  94. data/examples/sinatra_app/README.md +0 -471
  95. data/examples/sinatra_app/RUNNING_WITHOUT_TALIB.md +0 -90
  96. data/examples/sinatra_app/TROUBLESHOOTING.md +0 -95
  97. data/examples/sinatra_app/app.rb +0 -404
  98. data/examples/sinatra_app/config.ru +0 -5
  99. data/examples/sinatra_app/public/css/style.css +0 -723
  100. data/examples/sinatra_app/public/debug_macd.html +0 -82
  101. data/examples/sinatra_app/public/js/app.js +0 -107
  102. data/examples/sinatra_app/start.sh +0 -53
  103. data/examples/sinatra_app/views/analyze.erb +0 -306
  104. data/examples/sinatra_app/views/backtest.erb +0 -325
  105. data/examples/sinatra_app/views/dashboard.erb +0 -831
  106. data/examples/sinatra_app/views/error.erb +0 -58
  107. data/examples/sinatra_app/views/index.erb +0 -118
  108. data/examples/sinatra_app/views/layout.erb +0 -61
  109. data/examples/sinatra_app/views/portfolio.erb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ce65f3dece761390257e68d4b3ddaf878e27e0b932b6b4dbd2dfecac2244c5f
4
- data.tar.gz: 4dc160dda96a433049aeb06898a8a3cbfe1ecec439e1a9942d8272593658be14
3
+ metadata.gz: 484455cc08530992abd5fc38f02ae973bf1fb243aced961bdf7a8961e3f1b161
4
+ data.tar.gz: dd3f4cfc5fc7112d6c6e84973f1f5c6376678e69d7713a653c9e04223df35cd1
5
5
  SHA512:
6
- metadata.gz: 3194aaf4f55f8b2e388af48012ad71b5e282e4a69505f59dae78b29d30d2cb38c74ea06a25eff4b0323644a5b05581562b1c846c80ae0f7a39b2bc2210a58e1b
7
- data.tar.gz: 5f5c72d9cbb21e508d85318a2d4173a6ea0e77cbe10f866131a90004b7fe8cb7278422f033038477dcd215cc46fd2738a841d3217b61da6e7ac8f05c18b149dc
6
+ metadata.gz: bce9d957fb7014508833d97fc733eafb0b776fd824b9c2c5fd8417c94ce29f0ff3cbd6a164a19f82f8a5c25cff657ed200f89d223e6a246ddc19bb9857e4befb
7
+ data.tar.gz: 57477ab3cc699310ebd205588855252db79127dd160ca981ae2ab0b6ebebd39f3dd19b7b26829f130decaf1a38fe006c3c20857e6a739342b793390d5f3fecea
data/CHANGELOG.md CHANGED
@@ -1,6 +1,97 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.0.32] 2025-11-12
3
+ ## [0.0.36] - 2025-11-24
4
+
5
+ ### Changed
6
+ - **Phase 3 Architecture & Design Improvements**:
7
+ - Added deprecation warning for auto-initialization at require time (will be removed in v1.0)
8
+ - Added `SQA::Config.initialized?` class method to track initialization state
9
+ - Warning only shows when `$VERBOSE` is set
10
+ - `concat_and_deduplicate!` now enforces ascending order for TA-Lib compatibility
11
+ - Warns and forces `descending: false` if `descending: true` is passed
12
+ - Prevents silent calculation errors from incorrect data ordering
13
+ - Extracted Faraday connection to configurable dependency in `SQA::Stock`
14
+ - Added `ALPHA_VANTAGE_URL` constant
15
+ - Added class methods: `connection`, `connection=`, `default_connection`, `reset_connection!`
16
+ - Allows injection of custom connections for testing/mocking
17
+ - Deprecated `CONNECTION` constant (will be removed in v1.0)
18
+
19
+ ### Added
20
+ - **Test Coverage for Phase 3**:
21
+ - Added 2 tests to `test/config_test.rb` for `initialized?` method
22
+ - Added 7 tests to `test/stock_test.rb` for configurable connection
23
+ - Updated `test/data_frame_test.rb` to verify ascending order enforcement
24
+
25
+ ## [0.0.35] - 2025-11-23
26
+
27
+ ### Changed
28
+ - **Phase 2 Code Quality & Best Practices**:
29
+ - Replaced class variables (`@@var`) with class instance variables (`@var`) for thread safety
30
+ - `SQA::init.rb`: `@@config`, `@@av_api_key` → `@config`, `@av_api_key`
31
+ - `SQA::Ticker`: Restructured with `class << self` block, added `reset!` method
32
+ - `SQA::Stock`: `@@top` → `@top`, added `reset_top!` method
33
+ - Replaced `puts` statements with `debug_me` in `SQA::SectorAnalyzer`
34
+ - Simplified `method_missing` in `SQA::DataFrame` (no longer dynamically defines methods)
35
+ - Fixed type checking pattern in `SQA::Strategy#add` to use `is_a?` instead of `.class ==`
36
+ - Fixed `SQA::Strategy#available` to use `.name` instead of `.to_s` (avoids pretty_please gem conflict)
37
+ - Removed magic placeholder "xyzzy" from `SQA::Stock#create_data`
38
+
39
+ ### Fixed
40
+ - **DataFrame.from_aofh**: Fixed Polars compatibility by converting to hash-of-arrays format
41
+ - **DataFrame.from_aofh**: Now properly passes `mapping:` and `transformers:` parameters
42
+ - **Ticker.valid?**: Now handles nil and empty string inputs gracefully
43
+ - **Ticker.lookup**: Now handles nil and empty string inputs gracefully
44
+
45
+ ### Added
46
+ - **Test Coverage for Phase 2**:
47
+ - New `test/ticker_test.rb` with 10 tests for Ticker class
48
+ - New `test/strategy_test.rb` with 10 tests for Strategy class
49
+ - Added 4 tests to `test/data_frame_test.rb` for `from_aofh` and `method_missing`
50
+ - Added 2 tests to `test/stock_test.rb` for `reset_top!` method
51
+
52
+ ## [0.0.34] - 2025-11-23
53
+
54
+ ### Fixed
55
+ - **Test Suite**: Fixed 15+ pre-existing test failures
56
+ - Fixed typo in RiskManagerTest (`var` → `cvar`)
57
+ - Fixed Portfolio test expectations (total_cost, P&L calculation, summary keys)
58
+ - Fixed URL trailing slash comparisons in AlphaVantage/YahooFinance tests
59
+ - Fixed FPOP test expectation (implementation returns partial windows)
60
+ - Fixed SectorAnalyzer symbol/string comparison
61
+ - Fixed AlphaVantage header mapping test (timestamp, no adjusted_close)
62
+ - **PatternMatcher**: Fixed integer division bug in `pattern_quality` method
63
+ - Added `.to_f` conversion to prevent truncation with integer inputs
64
+ - **Config Coercion**: Fixed string-to-symbol coercion for `log_level` and `plotting_library`
65
+ - Added explicit `coerce_key` handlers
66
+
67
+ ### Added
68
+ - **Portfolio**: Added `commission` to `attr_accessor` for public access
69
+ - **Error Namespacing**: Added `SQA::BadParameterError` namespace with backwards-compatible alias
70
+
71
+ ### Changed
72
+ - **Phase 1 Security & Correctness** (from improvement plan):
73
+ - Replaced shell injection vulnerability (`touch` backticks → `FileUtils.touch`)
74
+ - Replaced deprecated `has_key?` with `key?` across codebase
75
+ - Added `SQA::DataFetchError` and `SQA::ConfigurationError` exception classes
76
+ - Replaced bare `rescue` clauses with specific exception types
77
+
78
+ ## [0.0.33] - 2025-11-23
79
+
80
+ ### Removed
81
+ - **Sinatra Example App**: Removed `examples/sinatra_app/` directory
82
+ - Functionality moved to separate gem: [sqa_demo-sinatra](https://github.com/MadBomber/sqa_demo-sinatra)
83
+ - Cleaner separation between library and demo application
84
+
85
+ ### Added
86
+ - **Documentation**: Added links to sqa_demo-sinatra demo application
87
+ - Updated README.md with Web Demo Application section
88
+ - Updated docs/index.md with Demo Application section
89
+ - Updated examples/README.md with reference to web demo
90
+ - **LLM Documentation**: Added llms.txt for AI assistant compatibility
91
+ - **Improvement Plan**: Added docs/IMPROVEMENT_PLAN.md for upcoming code quality improvements
92
+
93
+ ## [0.0.32] - 2024-11-12
94
+
4
95
  ### Added
5
96
  - **CSV Updates**: Conditional CSV updates based on timestamp
6
97
  - Only updates CSV files when new data is available
data/README.md CHANGED
@@ -913,6 +913,10 @@ ruby examples/strategy_generator_example.rb
913
913
 
914
914
  See `examples/README.md` for detailed documentation and integration patterns.
915
915
 
916
+ ### Web Demo Application
917
+
918
+ For a complete web-based demonstration of SQA's capabilities, see the **[sqa_demo-sinatra](https://github.com/MadBomber/sqa_demo-sinatra)** gem. This Sinatra application provides a visual interface for exploring stock analysis, technical indicators, and trading strategies.
919
+
916
920
  ## Architecture
917
921
 
918
922
  **Core Components:**
data/Rakefile CHANGED
@@ -1,25 +1,67 @@
1
1
  # frozen_string_literal: true
2
2
 
3
-
4
-
5
3
  begin
6
- require "tocer/rake/register"
7
- rescue LoadError => error
8
- puts error.message
4
+ require 'tocer/rake/register'
5
+ rescue LoadError => e
6
+ puts e.message
9
7
  end
10
8
 
11
9
  Tocer::Rake::Register.call
12
10
 
11
+ begin
12
+ require 'yard'
13
+
14
+ namespace :docs do
15
+ desc 'Build complete documentation site (API markdown + MkDocs)'
16
+ task :build do
17
+ puts 'Step 1: Generating API documentation from YARD comments...'
18
+ sh 'ruby bin/generate_api_docs.rb'
19
+
20
+ puts "\nStep 2: Building MkDocs site with Material theme..."
21
+ sh 'mkdocs build'
13
22
 
23
+ puts "\nDocumentation complete!"
24
+ puts ' Site: site/index.html'
25
+ puts ' API Reference: site/api-reference/index.html'
26
+ puts "\nTo preview: rake docs:serve"
27
+ end
28
+
29
+ desc 'Serve documentation locally with live reload'
30
+ task :serve do
31
+ puts 'Starting MkDocs development server...'
32
+ puts 'View at: http://127.0.0.1:8000'
33
+ puts 'Press Ctrl+C to stop'
34
+ sh 'mkdocs serve'
35
+ end
36
+
37
+ desc 'Clean generated documentation files'
38
+ task :clean do
39
+ puts 'Cleaning generated documentation...'
40
+ sh 'rm -rf docs/api-reference site .yardoc'
41
+ puts 'Done!'
42
+ end
43
+
44
+ desc 'Deploy documentation to GitHub Pages'
45
+ task deploy: :build do
46
+ puts "\nDeploying to GitHub Pages..."
47
+ sh 'mkdocs gh-deploy --force'
48
+
49
+ puts "\nDeployment complete!"
50
+ puts 'Documentation is live at: https://madbomber.github.io/sqa/'
51
+ end
52
+ end
53
+ rescue LoadError
54
+ # YARD not available
55
+ end
14
56
 
15
- require "bundler/gem_tasks"
16
- require "minitest/test_task"
57
+ require 'bundler/gem_tasks'
58
+ require 'minitest/test_task'
17
59
 
18
60
  Minitest::TestTask.create(:test) do |t|
19
- t.libs << "test"
20
- t.libs << "lib"
61
+ t.libs << 'test'
62
+ t.libs << 'lib'
21
63
  t.warning = false
22
- t.test_globs = ["test/**/*_test.rb"]
64
+ t.test_globs = ['test/**/*_test.rb']
23
65
  end
24
66
 
25
67
  task default: %i[]