sqa 0.0.32 → 0.0.38

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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +154 -1
  3. data/README.md +4 -0
  4. data/Rakefile +52 -10
  5. data/docs/advanced/index.md +1 -13
  6. data/docs/api/index.md +547 -61
  7. data/docs/api-reference/alphavantageapi.md +1057 -0
  8. data/docs/api-reference/apierror.md +31 -0
  9. data/docs/api-reference/index.md +221 -0
  10. data/docs/api-reference/notimplemented.md +27 -0
  11. data/docs/api-reference/sqa.md +267 -0
  12. data/docs/api-reference/sqa_backtest.md +171 -0
  13. data/docs/api-reference/sqa_backtest_results.md +530 -0
  14. data/docs/api-reference/sqa_badparametererror.md +13 -0
  15. data/docs/api-reference/sqa_config.md +538 -0
  16. data/docs/api-reference/sqa_configurationerror.md +13 -0
  17. data/docs/api-reference/sqa_datafetcherror.md +56 -0
  18. data/docs/api-reference/sqa_dataframe.md +779 -0
  19. data/docs/api-reference/sqa_dataframe_alphavantage.md +30 -0
  20. data/docs/api-reference/sqa_dataframe_data.md +325 -0
  21. data/docs/api-reference/sqa_dataframe_yahoofinance.md +25 -0
  22. data/docs/api-reference/sqa_ensemble.md +413 -0
  23. data/docs/api-reference/sqa_fpop.md +211 -0
  24. data/docs/api-reference/sqa_geneticprogram.md +325 -0
  25. data/docs/api-reference/sqa_geneticprogram_individual.md +114 -0
  26. data/docs/api-reference/sqa_marketregime.md +212 -0
  27. data/docs/api-reference/sqa_multitimeframe.md +227 -0
  28. data/docs/api-reference/sqa_patternmatcher.md +195 -0
  29. data/docs/api-reference/sqa_pluginmanager.md +55 -0
  30. data/docs/api-reference/sqa_portfolio.md +512 -0
  31. data/docs/api-reference/sqa_portfolio_position.md +220 -0
  32. data/docs/api-reference/sqa_portfolio_trade.md +332 -0
  33. data/docs/api-reference/sqa_portfoliooptimizer.md +248 -0
  34. data/docs/api-reference/sqa_riskmanager.md +388 -0
  35. data/docs/api-reference/sqa_seasonalanalyzer.md +121 -0
  36. data/docs/api-reference/sqa_sectoranalyzer.md +163 -0
  37. data/docs/api-reference/sqa_stock.md +661 -0
  38. data/docs/api-reference/sqa_strategy.md +178 -0
  39. data/docs/api-reference/sqa_strategy_bollingerbands.md +26 -0
  40. data/docs/api-reference/sqa_strategy_common.md +29 -0
  41. data/docs/api-reference/sqa_strategy_consensus.md +129 -0
  42. data/docs/api-reference/sqa_strategy_ema.md +41 -0
  43. data/docs/api-reference/sqa_strategy_kbs.md +154 -0
  44. data/docs/api-reference/sqa_strategy_macd.md +26 -0
  45. data/docs/api-reference/sqa_strategy_mp.md +41 -0
  46. data/docs/api-reference/sqa_strategy_mr.md +41 -0
  47. data/docs/api-reference/sqa_strategy_random.md +41 -0
  48. data/docs/api-reference/sqa_strategy_rsi.md +41 -0
  49. data/docs/api-reference/sqa_strategy_sma.md +41 -0
  50. data/docs/api-reference/sqa_strategy_stochastic.md +26 -0
  51. data/docs/api-reference/sqa_strategy_volumebreakout.md +26 -0
  52. data/docs/api-reference/sqa_strategygenerator.md +298 -0
  53. data/docs/api-reference/sqa_strategygenerator_pattern.md +264 -0
  54. data/docs/api-reference/sqa_strategygenerator_patterncontext.md +326 -0
  55. data/docs/api-reference/sqa_strategygenerator_profitablepoint.md +424 -0
  56. data/docs/api-reference/sqa_stream.md +256 -0
  57. data/docs/api-reference/sqa_ticker.md +175 -0
  58. data/docs/api-reference/string.md +135 -0
  59. data/docs/assets/images/advanced-workflow.svg +89 -0
  60. data/docs/assets/images/architecture.svg +107 -0
  61. data/docs/assets/images/data-flow.svg +138 -0
  62. data/docs/assets/images/getting-started-workflow.svg +88 -0
  63. data/docs/assets/images/strategy-flow.svg +78 -0
  64. data/docs/assets/images/system-architecture.svg +150 -0
  65. data/docs/concepts/index.md +292 -19
  66. data/docs/file_formats.md +250 -0
  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/backtest.rb +32 -0
  76. data/lib/sqa/config.rb +109 -28
  77. data/lib/sqa/data_frame/data.rb +13 -1
  78. data/lib/sqa/data_frame.rb +193 -26
  79. data/lib/sqa/errors.rb +79 -17
  80. data/lib/sqa/init.rb +70 -15
  81. data/lib/sqa/pattern_matcher.rb +4 -4
  82. data/lib/sqa/portfolio.rb +55 -1
  83. data/lib/sqa/sector_analyzer.rb +3 -11
  84. data/lib/sqa/stock.rb +180 -15
  85. data/lib/sqa/strategy.rb +62 -4
  86. data/lib/sqa/ticker.rb +106 -48
  87. data/lib/sqa/version.rb +1 -1
  88. data/lib/sqa.rb +4 -4
  89. data/mkdocs.yml +69 -81
  90. metadata +89 -21
  91. data/docs/README.md +0 -43
  92. data/examples/sinatra_app/Gemfile +0 -42
  93. data/examples/sinatra_app/Gemfile.lock +0 -268
  94. data/examples/sinatra_app/QUICKSTART.md +0 -169
  95. data/examples/sinatra_app/README.md +0 -471
  96. data/examples/sinatra_app/RUNNING_WITHOUT_TALIB.md +0 -90
  97. data/examples/sinatra_app/TROUBLESHOOTING.md +0 -95
  98. data/examples/sinatra_app/app.rb +0 -404
  99. data/examples/sinatra_app/config.ru +0 -5
  100. data/examples/sinatra_app/public/css/style.css +0 -723
  101. data/examples/sinatra_app/public/debug_macd.html +0 -82
  102. data/examples/sinatra_app/public/js/app.js +0 -107
  103. data/examples/sinatra_app/start.sh +0 -53
  104. data/examples/sinatra_app/views/analyze.erb +0 -306
  105. data/examples/sinatra_app/views/backtest.erb +0 -325
  106. data/examples/sinatra_app/views/dashboard.erb +0 -831
  107. data/examples/sinatra_app/views/error.erb +0 -58
  108. data/examples/sinatra_app/views/index.erb +0 -118
  109. data/examples/sinatra_app/views/layout.erb +0 -61
  110. 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: 830fbff0a1f2441e67e9781a2996774575cf021440c787804d308cde4b1fd7d5
4
+ data.tar.gz: be89088467543c775860ba3eee54a68c9998c50a1043ade62334678bc9175b05
5
5
  SHA512:
6
- metadata.gz: 3194aaf4f55f8b2e388af48012ad71b5e282e4a69505f59dae78b29d30d2cb38c74ea06a25eff4b0323644a5b05581562b1c846c80ae0f7a39b2bc2210a58e1b
7
- data.tar.gz: 5f5c72d9cbb21e508d85318a2d4173a6ea0e77cbe10f866131a90004b7fe8cb7278422f033038477dcd215cc46fd2738a841d3217b61da6e7ac8f05c18b149dc
6
+ metadata.gz: 3b592a70012e50b0199d70f7511c02bda585b9c5a410a142d2945ba7af2e85565d06ebbcd7d26ecdb540c203f00dec3f6e7234df6b53bb73c597d780ebaf371d
7
+ data.tar.gz: eab323c5c1c7531042729a952a3f66e1ed21d6da872a92fa8ffe3a68cf63e3ebf50f7d4b47fe436d1301b5573530ee4acc9d477bce9f969bfd077fbaa2b53918
data/CHANGELOG.md CHANGED
@@ -1,6 +1,159 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.0.32] 2025-11-12
3
+ ## [0.0.39] - 2025-11-24
4
+
5
+ ### Added
6
+ - **YARD Documentation Examples**:
7
+ - Added comprehensive usage examples to 15+ critical methods across core classes
8
+ - `SQA::Portfolio`: Examples for `#buy`, `#sell`, `#value`, `#summary` methods
9
+ - `SQA::Backtest`: Examples for `#run` method showing RSI strategy, custom date ranges, and equity curve access
10
+ - `SQA::Stock`: Examples for `#update` method with API metadata fetching
11
+ - `SQA::DataFrame`: Examples for `#concat_and_deduplicate!` and `#to_csv` methods
12
+ - All examples demonstrate real-world usage with expected outputs
13
+
14
+ - **File Formats Documentation**:
15
+ - Created comprehensive `docs/file_formats.md` documenting all CSV and JSON formats
16
+ - **Portfolio Positions CSV**: Schema and usage for `save_to_csv()` / `load_from_csv()`
17
+ - **Trade History CSV**: Schema and usage for `save_trades_to_csv()`
18
+ - **Stock Data CSV**: OHLCV format with critical TA-Lib ordering requirements
19
+ - **Stock Metadata JSON**: Company overview data structure
20
+ - **Configuration Files**: YAML/TOML format documentation
21
+ - Added to MkDocs navigation under User Guide > Core Concepts
22
+
23
+ ### Changed
24
+ - **API Documentation Improvements**:
25
+ - Regenerated all 51+ API reference markdown files with new examples
26
+ - Examples now appear in purple Material Design admonition boxes
27
+ - Improved discoverability of common usage patterns
28
+
29
+ ## [0.0.38] - 2025-11-24
30
+
31
+ ### Added
32
+ - **Integrated YARD Documentation into MkDocs**:
33
+ - Created `bin/generate_api_docs.rb` script to convert YARD comments to markdown
34
+ - Generates 51+ API reference markdown files in `docs/api-reference/`
35
+ - Unified Material theme across all documentation pages
36
+ - Auto-generated documentation includes timestamp and complete class/module information
37
+
38
+ ### Changed
39
+ - **Enhanced Documentation Formatting**:
40
+ - Markdown generation now uses Material Design admonitions (note, info, success, example)
41
+ - Added emojis for visual hierarchy (📦 classes, 🔧 modules, 🏭 class methods, 🔨 instance methods, 📝 attributes, 🔢 constants)
42
+ - Parameters displayed in formatted tables instead of lists
43
+ - Return values in green success boxes with type badges
44
+ - Usage examples in purple example boxes with proper syntax highlighting
45
+ - Collapsible source location sections to reduce visual clutter
46
+ - Attribute access indicators (🔄 read/write, 👁️ read-only, ✍️ write-only)
47
+
48
+ - **Simplified Rake Tasks**:
49
+ - Consolidated documentation tasks under `docs:` namespace
50
+ - `docs:build` - Generate API markdown from YARD + build MkDocs site
51
+ - `docs:serve` - Serve documentation locally with live reload
52
+ - `docs:clean` - Clean generated documentation files
53
+ - `docs:deploy` - Deploy to GitHub Pages
54
+ - Removed legacy tasks: `yard`, `yard_server`, `api_docs`
55
+
56
+ - **Documentation Visual Improvements**:
57
+ - Updated `docs/index.md` with flexbox layout (logo left, features right)
58
+ - Converted 6 mermaid diagrams to colorful SVG images with transparent backgrounds
59
+ - High-contrast colors for better readability
60
+ - Added namespace icons (🎯 SQA, 📊 strategies) in API index
61
+
62
+ ### Dependencies
63
+ - Added `yard` and `yard-markdown` gems for API documentation generation
64
+
65
+ ## [0.0.36] - 2025-11-24
66
+
67
+ ### Changed
68
+ - **Phase 3 Architecture & Design Improvements**:
69
+ - Added deprecation warning for auto-initialization at require time (will be removed in v1.0)
70
+ - Added `SQA::Config.initialized?` class method to track initialization state
71
+ - Warning only shows when `$VERBOSE` is set
72
+ - `concat_and_deduplicate!` now enforces ascending order for TA-Lib compatibility
73
+ - Warns and forces `descending: false` if `descending: true` is passed
74
+ - Prevents silent calculation errors from incorrect data ordering
75
+ - Extracted Faraday connection to configurable dependency in `SQA::Stock`
76
+ - Added `ALPHA_VANTAGE_URL` constant
77
+ - Added class methods: `connection`, `connection=`, `default_connection`, `reset_connection!`
78
+ - Allows injection of custom connections for testing/mocking
79
+ - Deprecated `CONNECTION` constant (will be removed in v1.0)
80
+
81
+ ### Added
82
+ - **Test Coverage for Phase 3**:
83
+ - Added 2 tests to `test/config_test.rb` for `initialized?` method
84
+ - Added 7 tests to `test/stock_test.rb` for configurable connection
85
+ - Updated `test/data_frame_test.rb` to verify ascending order enforcement
86
+
87
+ ## [0.0.35] - 2025-11-23
88
+
89
+ ### Changed
90
+ - **Phase 2 Code Quality & Best Practices**:
91
+ - Replaced class variables (`@@var`) with class instance variables (`@var`) for thread safety
92
+ - `SQA::init.rb`: `@@config`, `@@av_api_key` → `@config`, `@av_api_key`
93
+ - `SQA::Ticker`: Restructured with `class << self` block, added `reset!` method
94
+ - `SQA::Stock`: `@@top` → `@top`, added `reset_top!` method
95
+ - Replaced `puts` statements with `debug_me` in `SQA::SectorAnalyzer`
96
+ - Simplified `method_missing` in `SQA::DataFrame` (no longer dynamically defines methods)
97
+ - Fixed type checking pattern in `SQA::Strategy#add` to use `is_a?` instead of `.class ==`
98
+ - Fixed `SQA::Strategy#available` to use `.name` instead of `.to_s` (avoids pretty_please gem conflict)
99
+ - Removed magic placeholder "xyzzy" from `SQA::Stock#create_data`
100
+
101
+ ### Fixed
102
+ - **DataFrame.from_aofh**: Fixed Polars compatibility by converting to hash-of-arrays format
103
+ - **DataFrame.from_aofh**: Now properly passes `mapping:` and `transformers:` parameters
104
+ - **Ticker.valid?**: Now handles nil and empty string inputs gracefully
105
+ - **Ticker.lookup**: Now handles nil and empty string inputs gracefully
106
+
107
+ ### Added
108
+ - **Test Coverage for Phase 2**:
109
+ - New `test/ticker_test.rb` with 10 tests for Ticker class
110
+ - New `test/strategy_test.rb` with 10 tests for Strategy class
111
+ - Added 4 tests to `test/data_frame_test.rb` for `from_aofh` and `method_missing`
112
+ - Added 2 tests to `test/stock_test.rb` for `reset_top!` method
113
+
114
+ ## [0.0.34] - 2025-11-23
115
+
116
+ ### Fixed
117
+ - **Test Suite**: Fixed 15+ pre-existing test failures
118
+ - Fixed typo in RiskManagerTest (`var` → `cvar`)
119
+ - Fixed Portfolio test expectations (total_cost, P&L calculation, summary keys)
120
+ - Fixed URL trailing slash comparisons in AlphaVantage/YahooFinance tests
121
+ - Fixed FPOP test expectation (implementation returns partial windows)
122
+ - Fixed SectorAnalyzer symbol/string comparison
123
+ - Fixed AlphaVantage header mapping test (timestamp, no adjusted_close)
124
+ - **PatternMatcher**: Fixed integer division bug in `pattern_quality` method
125
+ - Added `.to_f` conversion to prevent truncation with integer inputs
126
+ - **Config Coercion**: Fixed string-to-symbol coercion for `log_level` and `plotting_library`
127
+ - Added explicit `coerce_key` handlers
128
+
129
+ ### Added
130
+ - **Portfolio**: Added `commission` to `attr_accessor` for public access
131
+ - **Error Namespacing**: Added `SQA::BadParameterError` namespace with backwards-compatible alias
132
+
133
+ ### Changed
134
+ - **Phase 1 Security & Correctness** (from improvement plan):
135
+ - Replaced shell injection vulnerability (`touch` backticks → `FileUtils.touch`)
136
+ - Replaced deprecated `has_key?` with `key?` across codebase
137
+ - Added `SQA::DataFetchError` and `SQA::ConfigurationError` exception classes
138
+ - Replaced bare `rescue` clauses with specific exception types
139
+
140
+ ## [0.0.33] - 2025-11-23
141
+
142
+ ### Removed
143
+ - **Sinatra Example App**: Removed `examples/sinatra_app/` directory
144
+ - Functionality moved to separate gem: [sqa_demo-sinatra](https://github.com/MadBomber/sqa_demo-sinatra)
145
+ - Cleaner separation between library and demo application
146
+
147
+ ### Added
148
+ - **Documentation**: Added links to sqa_demo-sinatra demo application
149
+ - Updated README.md with Web Demo Application section
150
+ - Updated docs/index.md with Demo Application section
151
+ - Updated examples/README.md with reference to web demo
152
+ - **LLM Documentation**: Added llms.txt for AI assistant compatibility
153
+ - **Improvement Plan**: Added docs/IMPROVEMENT_PLAN.md for upcoming code quality improvements
154
+
155
+ ## [0.0.32] - 2024-11-12
156
+
4
157
  ### Added
5
158
  - **CSV Updates**: Conditional CSV updates based on timestamp
6
159
  - 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[]
@@ -76,19 +76,7 @@ Future Period of Performance analysis for risk/reward calculations.
76
76
 
77
77
  ## Example Workflow
78
78
 
79
- ```mermaid
80
- graph LR
81
- A[Historical Data] --> B[Strategy Generator]
82
- B --> C[Discovered Patterns]
83
- C --> D[Generated Strategies]
84
- D --> E[Genetic Programming]
85
- E --> F[Optimized Parameters]
86
- F --> G[Backtest]
87
- G --> H{Results Good?}
88
- H -->|Yes| I[Live Stream]
89
- H -->|No| D
90
- I --> J[Portfolio Management]
91
- ```
79
+ ![Advanced Workflow](../assets/images/advanced-workflow.svg)
92
80
 
93
81
  ## Use Cases
94
82