jsf-core 0.7.0__tar.gz

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 (119) hide show
  1. jsf_core-0.7.0/CHANGELOG.md +632 -0
  2. jsf_core-0.7.0/CONTRIBUTING.md +207 -0
  3. jsf_core-0.7.0/LICENSE +21 -0
  4. jsf_core-0.7.0/MANIFEST.in +38 -0
  5. jsf_core-0.7.0/PKG-INFO +400 -0
  6. jsf_core-0.7.0/README.md +332 -0
  7. jsf_core-0.7.0/docs/CENTRALIZED_CONFIG_IMPLEMENTATION.md +176 -0
  8. jsf_core-0.7.0/docs/PHASE_1_COMPLETE.md +188 -0
  9. jsf_core-0.7.0/docs/PHASE_2_COMPLETE.md +333 -0
  10. jsf_core-0.7.0/docs/QUICKSTART_TELEGRAM.md +137 -0
  11. jsf_core-0.7.0/docs/SENTIMENT_INVESTING.md +621 -0
  12. jsf_core-0.7.0/docs/TELEGRAM_SETUP.md +274 -0
  13. jsf_core-0.7.0/pyproject.toml +213 -0
  14. jsf_core-0.7.0/requirements-dev.txt +22 -0
  15. jsf_core-0.7.0/requirements.txt +114 -0
  16. jsf_core-0.7.0/setup.cfg +4 -0
  17. jsf_core-0.7.0/src/jsf/__init__.py +226 -0
  18. jsf_core-0.7.0/src/jsf/alerts/__init__.py +86 -0
  19. jsf_core-0.7.0/src/jsf/alerts/base.py +243 -0
  20. jsf_core-0.7.0/src/jsf/alerts/console.py +98 -0
  21. jsf_core-0.7.0/src/jsf/alerts/factory.py +188 -0
  22. jsf_core-0.7.0/src/jsf/alerts/integration.py +259 -0
  23. jsf_core-0.7.0/src/jsf/alerts/manager.py +400 -0
  24. jsf_core-0.7.0/src/jsf/alerts/telegram.py +317 -0
  25. jsf_core-0.7.0/src/jsf/assets/__init__.py +135 -0
  26. jsf_core-0.7.0/src/jsf/assets/base.py +450 -0
  27. jsf_core-0.7.0/src/jsf/assets/crypto.py +601 -0
  28. jsf_core-0.7.0/src/jsf/assets/forex.py +624 -0
  29. jsf_core-0.7.0/src/jsf/assets/futures.py +740 -0
  30. jsf_core-0.7.0/src/jsf/assets/options.py +914 -0
  31. jsf_core-0.7.0/src/jsf/broker/__init__.py +121 -0
  32. jsf_core-0.7.0/src/jsf/broker/alpaca.py +631 -0
  33. jsf_core-0.7.0/src/jsf/broker/base.py +570 -0
  34. jsf_core-0.7.0/src/jsf/broker/models.py +551 -0
  35. jsf_core-0.7.0/src/jsf/broker/paper.py +766 -0
  36. jsf_core-0.7.0/src/jsf/cli/__init__.py +5 -0
  37. jsf_core-0.7.0/src/jsf/cli/setup_telegram.py +261 -0
  38. jsf_core-0.7.0/src/jsf/config/__init__.py +68 -0
  39. jsf_core-0.7.0/src/jsf/config/base.py +155 -0
  40. jsf_core-0.7.0/src/jsf/config/defaults.py +312 -0
  41. jsf_core-0.7.0/src/jsf/config/enums.py +114 -0
  42. jsf_core-0.7.0/src/jsf/config/schemas.py +421 -0
  43. jsf_core-0.7.0/src/jsf/dashboard/__init__.py +63 -0
  44. jsf_core-0.7.0/src/jsf/dashboard/app.py +553 -0
  45. jsf_core-0.7.0/src/jsf/dashboard/collectors.py +617 -0
  46. jsf_core-0.7.0/src/jsf/dashboard/components/__init__.py +16 -0
  47. jsf_core-0.7.0/src/jsf/dashboard/components/pnl.py +541 -0
  48. jsf_core-0.7.0/src/jsf/dashboard/components/portfolio.py +341 -0
  49. jsf_core-0.7.0/src/jsf/dashboard/components/risk.py +528 -0
  50. jsf_core-0.7.0/src/jsf/dashboard/components/trades.py +475 -0
  51. jsf_core-0.7.0/src/jsf/dashboard/metrics.py +717 -0
  52. jsf_core-0.7.0/src/jsf/dashboard/models.py +469 -0
  53. jsf_core-0.7.0/src/jsf/data/__init__.py +67 -0
  54. jsf_core-0.7.0/src/jsf/data/base.py +297 -0
  55. jsf_core-0.7.0/src/jsf/data/loaders.py +448 -0
  56. jsf_core-0.7.0/src/jsf/data/preprocessing.py +386 -0
  57. jsf_core-0.7.0/src/jsf/data/sources/__init__.py +16 -0
  58. jsf_core-0.7.0/src/jsf/data/sources/csv_enhanced.py +504 -0
  59. jsf_core-0.7.0/src/jsf/data/sources/yahoo.py +349 -0
  60. jsf_core-0.7.0/src/jsf/data/universe.py +322 -0
  61. jsf_core-0.7.0/src/jsf/evaluation/__init__.py +3 -0
  62. jsf_core-0.7.0/src/jsf/live/__init__.py +52 -0
  63. jsf_core-0.7.0/src/jsf/live/data_handler.py +777 -0
  64. jsf_core-0.7.0/src/jsf/live/engine.py +735 -0
  65. jsf_core-0.7.0/src/jsf/live/order_manager.py +684 -0
  66. jsf_core-0.7.0/src/jsf/ml/__init__.py +267 -0
  67. jsf_core-0.7.0/src/jsf/ml/export.py +553 -0
  68. jsf_core-0.7.0/src/jsf/ml/features.py +584 -0
  69. jsf_core-0.7.0/src/jsf/ml/models.py +772 -0
  70. jsf_core-0.7.0/src/jsf/ml/montecarlo.py +996 -0
  71. jsf_core-0.7.0/src/jsf/ml/neural.py +1622 -0
  72. jsf_core-0.7.0/src/jsf/ml/preprocessing.py +401 -0
  73. jsf_core-0.7.0/src/jsf/ml/registry.py +761 -0
  74. jsf_core-0.7.0/src/jsf/ml/rl_agent.py +1183 -0
  75. jsf_core-0.7.0/src/jsf/ml/strategy.py +554 -0
  76. jsf_core-0.7.0/src/jsf/ml/transformers/__init__.py +269 -0
  77. jsf_core-0.7.0/src/jsf/ml/transformers/attention.py +480 -0
  78. jsf_core-0.7.0/src/jsf/ml/transformers/bert.py +755 -0
  79. jsf_core-0.7.0/src/jsf/ml/transformers/sentiment.py +451 -0
  80. jsf_core-0.7.0/src/jsf/ml/validation.py +572 -0
  81. jsf_core-0.7.0/src/jsf/optimization/__init__.py +33 -0
  82. jsf_core-0.7.0/src/jsf/optimization/grid_search.py +282 -0
  83. jsf_core-0.7.0/src/jsf/optimization/walk_forward.py +648 -0
  84. jsf_core-0.7.0/src/jsf/portfolio/__init__.py +99 -0
  85. jsf_core-0.7.0/src/jsf/portfolio/base.py +403 -0
  86. jsf_core-0.7.0/src/jsf/portfolio/constraints.py +471 -0
  87. jsf_core-0.7.0/src/jsf/portfolio/constructors.py +462 -0
  88. jsf_core-0.7.0/src/jsf/portfolio/optimization.py +507 -0
  89. jsf_core-0.7.0/src/jsf/portfolio/rebalancing.py +559 -0
  90. jsf_core-0.7.0/src/jsf/portfolio/sizing.py +416 -0
  91. jsf_core-0.7.0/src/jsf/reporting/__init__.py +3 -0
  92. jsf_core-0.7.0/src/jsf/settings.py +228 -0
  93. jsf_core-0.7.0/src/jsf/signals/__init__.py +141 -0
  94. jsf_core-0.7.0/src/jsf/signals/base.py +396 -0
  95. jsf_core-0.7.0/src/jsf/signals/composites.py +454 -0
  96. jsf_core-0.7.0/src/jsf/signals/fundamental.py +413 -0
  97. jsf_core-0.7.0/src/jsf/signals/sentiment.py +897 -0
  98. jsf_core-0.7.0/src/jsf/signals/statistical.py +391 -0
  99. jsf_core-0.7.0/src/jsf/signals/technical.py +442 -0
  100. jsf_core-0.7.0/src/jsf/signals/transforms.py +468 -0
  101. jsf_core-0.7.0/src/jsf/simulation/__init__.py +35 -0
  102. jsf_core-0.7.0/src/jsf/simulation/backtest.py +271 -0
  103. jsf_core-0.7.0/src/jsf/simulation/metrics.py +225 -0
  104. jsf_core-0.7.0/src/jsf/strategies/__init__.py +23 -0
  105. jsf_core-0.7.0/src/jsf/strategies/base.py +180 -0
  106. jsf_core-0.7.0/src/jsf/strategies/templates.py +233 -0
  107. jsf_core-0.7.0/src/jsf/utils/__init__.py +39 -0
  108. jsf_core-0.7.0/src/jsf/utils/io.py +150 -0
  109. jsf_core-0.7.0/src/jsf/utils/logging.py +121 -0
  110. jsf_core-0.7.0/src/jsf/utils/parallel.py +94 -0
  111. jsf_core-0.7.0/src/jsf/utils/time_utils.py +132 -0
  112. jsf_core-0.7.0/src/jsf/visualization/__init__.py +24 -0
  113. jsf_core-0.7.0/src/jsf/visualization/plots.py +505 -0
  114. jsf_core-0.7.0/src/jsf_core.egg-info/PKG-INFO +400 -0
  115. jsf_core-0.7.0/src/jsf_core.egg-info/SOURCES.txt +117 -0
  116. jsf_core-0.7.0/src/jsf_core.egg-info/dependency_links.txt +1 -0
  117. jsf_core-0.7.0/src/jsf_core.egg-info/entry_points.txt +2 -0
  118. jsf_core-0.7.0/src/jsf_core.egg-info/requires.txt +47 -0
  119. jsf_core-0.7.0/src/jsf_core.egg-info/top_level.txt +1 -0
@@ -0,0 +1,632 @@
1
+ # Changelog
2
+
3
+ All notable changes to JSF-Core will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.7.0] - 2026-02-18
9
+
10
+ ### Dashboard Overhaul & Release
11
+
12
+ #### Fixed - Dashboard
13
+ - MockDataCollector now generates 90 days of historical equity + 40 mock trades on startup
14
+ - SnapshotHistory retention expanded to accommodate full historical data
15
+ - P&L page: full date range filter (Start Date, End Date, Quick Select: 7/30/90 days, YTD, All Time)
16
+ - Removed all emojis from UI (titles, sidebar, buttons, expanders)
17
+ - Fixed deprecated `Styler.applymap` → `Styler.map` (pandas 2.x)
18
+ - Fixed deprecated `use_container_width=True` → `width="stretch"` (Streamlit 1.54)
19
+ - Fixed `calculate_calmar` import fallback in `risk.py`
20
+ - Fixed auto-refresh to call `st.rerun()` correctly
21
+ - Fixed SyntaxError in `app.py` (mismatched parenthesis in style chain)
22
+ - Enhanced `start_demo_mode()` to populate `equity_history` and `trade_history` in state
23
+ - Dashboard version now reads from `jsf.__version__` dynamically
24
+
25
+ #### Changed - Dependencies
26
+ - Moved `tensorflow`, `torch`, `transformers` from hard dependencies to optional `[ml]` extra
27
+ - Added `streamlit`, `python-dotenv` as optional `[dashboard]` extra
28
+ - Added `alpaca-trade-api` as optional `[trading]` extra
29
+ - Added `python-telegram-bot` as optional `[alerts]` extra
30
+ - Added `tqdm`, `joblib` to core dependencies
31
+ - Updated minimum PyTorch version to 2.6.0 (required by transformers 5.x, CVE-2025-32434)
32
+
33
+ #### Installation
34
+ ```bash
35
+ pip install jsf-core # Core backtesting engine
36
+ pip install jsf-core[ml] # + NLP/sentiment (tensorflow, torch, transformers)
37
+ pip install jsf-core[dashboard] # + Streamlit monitoring dashboard
38
+ pip install jsf-core[trading] # + Alpaca live trading
39
+ pip install jsf-core[ml,dashboard,trading] # Everything
40
+ ```
41
+
42
+ ---
43
+
44
+ ## [0.7.0-dev] - 2026-02-13
45
+
46
+ ### Phase 19: NLP & Sentiment Analysis (Final)
47
+
48
+ This release completes Phase 19 with advanced NLP-based sentiment signals using BERT models.
49
+
50
+ #### Added - NLP Sentiment Signals
51
+ - **`TextSentimentSignal`** (`jsf.signals.sentiment`):
52
+ - NLP-based sentiment analysis using BERT or rule-based models
53
+ - Support for external text data (news, social media, SEC filings)
54
+ - Configurable sentiment thresholds and smoothing windows
55
+ - Mock fallback for testing without transformers library
56
+ - Lazy imports to avoid dependency errors
57
+
58
+ - **`SentimentMomentumSignal`** (`jsf.signals.sentiment`):
59
+ - Combines sentiment scores with momentum analysis
60
+ - BUY signal: sentiment > threshold AND rising momentum
61
+ - SELL signal: sentiment < -threshold AND falling momentum
62
+ - 5-day default smoothing with configurable lookback
63
+
64
+ - **`SentimentDivergenceSignal`** (`jsf.signals.sentiment`):
65
+ - Detects price-sentiment divergence for reversal signals
66
+ - Bullish divergence: price falling, sentiment rising → BUY
67
+ - Bearish divergence: price rising, sentiment falling → SELL
68
+ - Normalized momentum calculations for robust signals
69
+
70
+ - **BERT Integration Enhancements**:
71
+ - Lazy loading of NLP models (`_get_sentiment_analyzer`)
72
+ - Graceful degradation when transformers not installed
73
+ - Support for both FinBERT and SimpleSentiment backends
74
+ - Automatic sentiment score normalization
75
+
76
+ #### Added - Demos & Examples
77
+ - Refactored examples into `demos/` folder for better organization
78
+ - Added real-time news source integrations
79
+ - Created synthetic data testing for FinBERT
80
+ - ML integration examples for sentiment-based trading
81
+
82
+ #### Testing
83
+ - **24 new tests** in `test_sentiment_signals.py`
84
+ - All sentiment signal tests passing
85
+ - Mock sentiment data generation for testing
86
+ - **Total test count: 635 passed** (up from 509)
87
+
88
+ #### Documentation
89
+ - Added `SENTIMENT_INVESTING.md` roadmap for future enhancements
90
+ - Documented multi-source sentiment aggregation architecture
91
+ - Phase 20 preparation: PyPI publication guidelines
92
+
93
+ #### Technical Improvements
94
+ - Version bumped to `0.7.0-dev` across all files
95
+ - Fixed version inconsistency between `__version__` and `pyproject.toml`
96
+ - Updated README badges (tests: 509 → 635, progress: Phase 19 complete)
97
+ - Created `MANIFEST.in` for PyPI distribution
98
+
99
+ #### Contributors
100
+ - Core ML implementation: Jai Ansh Bindra
101
+ - NLP sentiment signals: Anubhav
102
+ - BERT integration: Jai Ansh Bindra & Anubhav
103
+
104
+ ---
105
+
106
+ ## [0.6.0-dev] - 2026-02-04
107
+
108
+ ### Phase 19: Machine Learning Integration
109
+
110
+ #### Added
111
+ - **ML module** (`jsf.ml`):
112
+ - Complete machine learning integration for trading strategies
113
+ - Modular architecture with preprocessing, features, models, and validation
114
+
115
+ - **Feature Extraction** (`jsf.ml.features`):
116
+ - `FeatureExtractor` - Extracts 20+ features from price data
117
+ - `FeatureConfig` - Configuration for feature extraction
118
+ - `FEATURE_GROUPS` - Predefined feature groups (momentum, volatility, trend, etc.)
119
+ - `create_feature_extractor` - Factory function for preset configurations
120
+ - Support for lag features (1, 5, 10 days)
121
+ - Cross-sectional normalization and ranking
122
+ - Automatic handling of MultiIndex data
123
+
124
+ - **ML Model Wrappers** (`jsf.ml.models`):
125
+ - `MLModel` - Abstract base class for ML models
126
+ - `RandomForestModel` - Scikit-learn Random Forest wrapper
127
+ - `XGBoostModel` - XGBoost wrapper (optional dependency)
128
+ - `LightGBMModel` - LightGBM wrapper (optional dependency)
129
+ - `EnsembleModel` - Weighted ensemble with configurable voting
130
+ - `PredictionType` - Enum for regression/classification/both
131
+ - Feature importance extraction
132
+ - Model serialization (save/load)
133
+
134
+ - **ML Strategy** (`jsf.ml.strategy`):
135
+ - `MLStrategy` - ML-based trading strategy
136
+ - `MLStrategyConfig` - Strategy configuration
137
+ - Walk-forward training with configurable retraining frequency
138
+ - Automatic drift monitoring
139
+ - Signal generation from predictions
140
+ - Long-only and top-N selection support
141
+
142
+ - **Walk-Forward Validation** (`jsf.ml.validation`):
143
+ - `WalkForwardMLValidator` - Time-series cross-validation
144
+ - `MLValidationResult` - Validation results with metrics
145
+ - `validate_ml_strategy` - Convenience function
146
+ - Efficiency ratio for overfitting detection
147
+ - Train/test IC comparison
148
+
149
+ - **Preprocessing Utilities** (`jsf.ml.preprocessing`):
150
+ - `MLDataset` - Container for ML-ready data
151
+ - `MultiIndexConverter` - Convert between wide/flat formats
152
+ - `create_target_variable` - Generate forward returns/direction targets
153
+ - `prepare_ml_data` - Prepare features and targets for training
154
+ - `split_train_test` - Time-aware train/test splitting
155
+ - `handle_missing_features` - NaN handling (ffill, mean, drop)
156
+
157
+ #### Configuration
158
+ - Default ensemble weights: RF 30%, XGBoost 40%, LightGBM 30%
159
+ - Default retraining frequency: 63 days (quarterly)
160
+ - Optional dependencies in `pyproject.toml[ml]`
161
+
162
+ #### Examples
163
+ - Created `ml_example.py` with 6 comprehensive examples:
164
+ - Example 1: Feature extraction
165
+ - Example 2: Model training and evaluation
166
+ - Example 3: Ensemble model configuration
167
+ - Example 4: ML strategy execution
168
+ - Example 5: Walk-forward validation
169
+ - Example 6: Backtesting ML strategies
170
+
171
+ #### Testing
172
+ - 33 new tests in `test_ml.py`
173
+ - All ML tests passing
174
+ - Total test count: 509 passed
175
+
176
+ ---
177
+
178
+ ### Phase 11: Parameter Optimization
179
+
180
+ #### Added
181
+ - **Grid search optimization** (`jsf.optimization`):
182
+ - `GridSearchOptimizer` - Systematic parameter search engine
183
+ - `ParameterGrid` - Iterator over parameter combinations
184
+ - `OptimizationResult` - Results container with best params and summary
185
+ - `optimize_strategy` - Convenience function for quick optimization
186
+ - **Optimization features**:
187
+ - Support for multiple parameters simultaneously
188
+ - Customizable optimization metrics (Sharpe, return, Calmar, etc.)
189
+ - Progress tracking with tqdm
190
+ - Summary DataFrame with all tested combinations
191
+ - Sorted results by metric
192
+ - **BacktestResult enhancements**:
193
+ - Added `calmar_ratio` property (CAGR / abs(max_drawdown))
194
+
195
+ #### Examples
196
+ - Created `optimization_example.py` with 4 comprehensive examples
197
+ - Example 1: Single-parameter optimization (lookback period)
198
+ - Example 2: Multi-parameter optimization (lookback + long_only)
199
+ - Example 3: Compare optimized strategies
200
+ - Example 4: Optimize using different metrics
201
+
202
+ #### Testing
203
+ - Tested with momentum strategy optimization
204
+ - Found optimal parameters: lookback=30 (Sharpe 0.735)
205
+ - Multi-parameter: lookback=120, long_only=True (Sharpe 2.00, 95.65% return)
206
+ - Strategy comparison: Momentum beats Mean Reversion after optimization
207
+
208
+ ### Phase 10: Visualization & Reporting
209
+
210
+ #### Added
211
+ - **Comprehensive plotting module** (`jsf.visualization`):
212
+ - `plot_equity_curve` - Portfolio value over time with key statistics
213
+ - `plot_drawdown` - Equity + drawdown chart with max drawdown highlight
214
+ - `plot_returns_distribution` - Histogram + Q-Q plot with normality test
215
+ - `plot_rolling_metrics` - 6-panel dashboard (returns, volatility, Sharpe, max DD, win rate, cumulative)
216
+ - `plot_monthly_returns` - Heatmap of monthly performance by year
217
+ - `plot_performance_summary` - Complete dashboard with all key metrics
218
+ - **Professional styling**:
219
+ - Seaborn-based theme
220
+ - Publication-quality charts (300 DPI)
221
+ - Automatic date formatting
222
+ - Currency formatting
223
+ - Color-coded performance indicators
224
+ - **Export capabilities**:
225
+ - Save to PNG files
226
+ - Configurable titles
227
+ - Optional display control
228
+
229
+ #### Technical Details
230
+ - Uses matplotlib + seaborn for plotting
231
+ - GridSpec layouts for multi-panel dashboards
232
+ - Automatic handling of date indices
233
+ - Statistics boxes on charts
234
+ - Q-Q plots for normality analysis
235
+ - Heatmaps for periodic returns
236
+
237
+ #### Examples
238
+ - Created `visualization_example.py` demonstrating all 6 plot types
239
+ - Updated `complete_backtest_example.py` with visualization
240
+ - All plots tested and verified working
241
+
242
+ ### Phase 9: Backtesting & Simulation Engine
243
+
244
+ #### Added
245
+ - **Backtesting infrastructure**:
246
+ - `BacktestEngine` - Complete simulation engine for strategy backtesting
247
+ - `BacktestConfig` - Configuration for capital, costs, slippage, margin
248
+ - `BacktestResult` - Results container with equity curve, returns, positions, trades
249
+ - **Transaction cost modeling**:
250
+ - Configurable transaction costs (default 10 bps)
251
+ - Slippage modeling (default 5 bps)
252
+ - Realistic execution simulation
253
+ - Position tracking and trade logging
254
+ - **Performance metrics** (20+ metrics):
255
+ - **Return metrics**: Total return, CAGR, mean return
256
+ - **Risk metrics**: Volatility, downside deviation, max drawdown, VaR (95%), CVaR (95%)
257
+ - **Risk-adjusted returns**: Sharpe ratio, Sortino ratio, Calmar ratio
258
+ - **Trading metrics**: Win rate, profit factor, best/worst day, avg win/loss
259
+ - **Distribution**: Skewness, kurtosis
260
+ - **Complete end-to-end examples**:
261
+ - Basic momentum strategy backtest
262
+ - Multi-strategy comparison (4 strategies)
263
+ - Detailed performance metrics analysis
264
+ - Transaction cost impact analysis
265
+
266
+ #### Technical Details
267
+ - Compound returns supported
268
+ - Equity curve generation
269
+ - Daily returns tracking
270
+ - Complete trade history
271
+ - Tested with realistic results: 2-90% returns, 0.3-2.1 Sharpe ratios
272
+ - Full integration with strategy framework
273
+
274
+ #### Testing
275
+ - Verified with 4 complete examples
276
+ - Real execution tests showing:
277
+ - Example 1: 46.58% return, 0.76 Sharpe, -16.70% max drawdown
278
+ - Example 2: 90.48% return, 2.11 Sharpe, -5.75% max drawdown (best)
279
+ - Example 3: Comprehensive metrics demonstration
280
+ - Example 4: Transaction cost impact (21.72% → 3.51% with high costs)
281
+
282
+ ### Phase 8: Strategy Templates
283
+
284
+ #### Added
285
+ - **Base strategy infrastructure**:
286
+ - `Strategy` - Abstract base class for all trading strategies
287
+ - `StrategyType` - Enum for strategy classification (momentum, mean_reversion, trend_following, etc.)
288
+ - `StrategyMetadata` - Metadata container for strategy documentation
289
+ - **Pre-built strategy templates** (3 templates):
290
+ - `MomentumStrategy` - Classic momentum (buy winners, sell/avoid losers)
291
+ - `MeanReversionStrategy` - Mean reversion (buy oversold, sell/avoid overbought)
292
+ - `TrendFollowingStrategy` - Trend following with MA crossover + trend strength
293
+ - **Complete pipeline**:
294
+ - Signal generation → Portfolio construction → Strategy execution
295
+ - Configurable portfolio construction methods
296
+ - Support for long-only and long-short strategies
297
+ - Comprehensive parameter management
298
+
299
+ #### Technical Details
300
+ - All strategies implement run() method for complete execution
301
+ - Strategies combine multiple signals intelligently
302
+ - Full metadata tracking for reproducibility
303
+ - Extensible architecture for custom strategies
304
+
305
+ ### Phase 7: Portfolio Construction
306
+
307
+ #### Added
308
+ - **Base portfolio infrastructure**:
309
+ - `Portfolio` - Container for weights with exposure/turnover tracking
310
+ - `PortfolioConstructor` - Abstract base for portfolio construction
311
+ - `PositionSizer` - Abstract base for position sizing
312
+ - `WeightOptimizer` - Abstract base for weight optimization
313
+ - `Rebalancer` - Abstract base for rebalancing logic
314
+ - `RebalanceFrequency` - Enum for rebalancing schedules
315
+ - **Position sizing methods** (5 methods):
316
+ - `EqualWeightSizer` - Equal weight allocation
317
+ - `SignalWeightedSizer` - Proportional to signal strength
318
+ - `VolatilityScaledSizer` - Inverse volatility weighting (risk parity)
319
+ - `RiskParitySizer` - Equal risk contribution (iterative optimization)
320
+ - `KellyCriterionSizer` - Kelly formula with fractional sizing
321
+ - **Weight optimization methods** (5 optimizers):
322
+ - `MinimumVarianceOptimizer` - Minimize portfolio variance
323
+ - `MaxSharpeOptimizer` - Maximize risk-adjusted returns
324
+ - `MeanVarianceOptimizer` - Balance expected return and risk
325
+ - `RiskParityOptimizer` - Equalize risk contributions
326
+ - `MaxDiversificationOptimizer` - Maximize diversification ratio
327
+ - **Rebalancing strategies** (5 strategies):
328
+ - `PeriodicRebalancer` - Time-based rebalancing (daily/weekly/monthly/etc)
329
+ - `ThresholdRebalancer` - Drift-based rebalancing
330
+ - `VolatilityTargetRebalancer` - Maintain target volatility
331
+ - `BandRebalancer` - Rebalance when outside allowed bands
332
+ - `SmartRebalancer` - Combine multiple triggers intelligently
333
+ - **Portfolio constraints** (6 constraints):
334
+ - `PortfolioConstraints` - Manage multiple constraints
335
+ - `PositionLimitConstraint` - Individual position limits
336
+ - `SectorConstraint` - Sector exposure limits
337
+ - `TurnoverConstraint` - Limit trading turnover
338
+ - `LeverageConstraint` - Gross/net exposure limits
339
+ - `ConcentrationConstraint` - Herfindahl-based concentration limits
340
+ - **Portfolio constructors** (3 types):
341
+ - `SimplePortfolioConstructor` - Basic signal-to-weights conversion
342
+ - `OptimizedPortfolioConstructor` - Optimization-based construction
343
+ - `HybridPortfolioConstructor` - Blend signals and optimization
344
+ - **Complete portfolio workflow**:
345
+ - Signal → Position Sizing → Optimization → Constraints → Rebalancing → Portfolio
346
+ - Support for long-only and long-short portfolios
347
+ - Full exposure and turnover tracking
348
+ - Comprehensive metadata capture
349
+
350
+ #### Technical Details
351
+ - All optimizers use scipy.optimize with SLSQP method
352
+ - Position sizing supports long-only and long-short modes
353
+ - Constraints support both check() and enforce() methods
354
+ - Rebalancing supports full and partial rebalancing
355
+ - Portfolio tracking includes gross/net/long/short exposure
356
+ - Complete end-to-end portfolio construction pipeline
357
+ - **Comprehensive test suite** (44 tests):
358
+ - Base class tests (3 tests)
359
+ - Position sizing tests (10 tests)
360
+ - Optimization tests (8 tests)
361
+ - Rebalancing tests (8 tests)
362
+ - Constraints tests (9 tests)
363
+ - Constructor tests (4 tests)
364
+ - Integration workflow tests (2 tests)
365
+ - Note: Tests reveal some API alignment needed with implementations
366
+ - **Usage examples** (`examples/portfolio_examples.py`):
367
+ - 12 comprehensive examples demonstrating all components
368
+ - Examples 1-3: Position sizing (equal weight, signal-weighted, volatility-scaled)
369
+ - Examples 4-5: Optimization (minimum variance, maximum Sharpe)
370
+ - Examples 6-7: Rebalancing (periodic, threshold-based)
371
+ - Examples 8-10: Constraints (position limits, leverage, multi-constraint)
372
+ - Examples 11-12: Full constructors (simple, optimized)
373
+ - Real-world scenarios with synthetic data
374
+ - **Dependencies updated**:
375
+ - pyarrow version constraint relaxed to >=12.0.0 (no upper bound)
376
+ - pytest-cov added for test coverage analysis
377
+ - All dependencies successfully installed
378
+
379
+ #### Documentation
380
+ - Full docstrings for all 24 portfolio components
381
+ - Type hints throughout codebase
382
+ - Comprehensive inline comments
383
+ - Usage examples showing real-world patterns
384
+
385
+ ### Phase 5-6: Signal Framework Completion
386
+
387
+ #### Added
388
+ - **Fundamental analysis signals** (5 signals):
389
+ - `ValueSignal` - Value investing using P/B ratios or price proxies
390
+ - `QualitySignal` - Stability and quality metrics (Sharpe-like, downside deviation)
391
+ - `GrowthSignal` - Multi-period growth trends (price + volume)
392
+ - `SizeSignal` - Market cap factor (small vs large cap preference)
393
+ - `DividendSignal` - Dividend yield strategies
394
+ - **Sentiment and market regime signals** (6 signals):
395
+ - `MarketRegimeSignal` - Bull/bear/neutral regime detection
396
+ - `BreadthSignal` - Market breadth (advancing vs declining stocks)
397
+ - `RelativeStrengthSignal` - Performance vs benchmark
398
+ - `NewHighLowSignal` - New highs/lows detection
399
+ - `VolumeShockSignal` - Unusual volume spike detection
400
+ - `SeasonalitySignal` - Calendar effects and patterns (monthly, quarterly, day-of-week)
401
+ - **Advanced composite patterns** (5 composite types):
402
+ - `RotationSignal` - Top-N rotation strategies with rebalancing
403
+ - `MultiTimeframeSignal` - Multi-timeframe confirmation
404
+ - `AdaptiveWeightSignal` - Performance-based dynamic weight adjustment
405
+ - `ThresholdFilterSignal` - Signal filtering by threshold (absolute/percentile)
406
+ - `ConsensusSignal` - Require agreement across multiple signals
407
+ - **Signal transformation utilities**:
408
+ - `normalize_signal` - Multiple normalization methods (z-score, min-max, rank, percentile, tanh)
409
+ - `rank_signal` - Cross-sectional, time-series, and hybrid ranking
410
+ - `smooth_signal` - Noise reduction (SMA, EMA, Gaussian)
411
+ - `clip_signal` - Value clipping to ranges
412
+ - `winsorize_signal` - Outlier handling
413
+ - `demean_signal` - Cross-sectional and time-series demeaning
414
+ - `neutralize_signal` - Factor neutralization via regression
415
+ - `apply_decay` - Exponential decay with configurable half-life
416
+ - `combine_signals` - Multiple signal aggregation (average, median, max, min)
417
+ - `score_signals` - Convert signals to portfolio scores (z-score, percentile, exponential)
418
+ - `NormalizationMethod` - Enum for normalization types
419
+ - `RankingMethod` - Enum for ranking methods
420
+ - **Comprehensive test suite** (31 tests):
421
+ - Fundamental signal tests (6 tests)
422
+ - Sentiment signal tests (6 tests)
423
+ - Advanced composite tests (5 tests)
424
+ - Transformation utility tests (14 tests)
425
+ - 100% test pass rate
426
+ - 57% overall coverage (88% fundamental, 86% sentiment, 84% composites, 61% transforms)
427
+ - **Full module exports** in `signals/__init__.py`
428
+
429
+ #### Technical Details
430
+ - All signals follow consistent interface (generate method, get_metadata)
431
+ - Fundamental signals support both actual fundamental data and price-based proxies
432
+ - Sentiment signals work with price/volume data when sentiment data unavailable
433
+ - Advanced composites enable sophisticated multi-signal strategies
434
+ - Transformation utilities provide complete signal preprocessing pipeline
435
+ - Enums provide type safety for normalization and ranking methods
436
+
437
+ ### Phase 4: Signal Framework (Part 1)
438
+
439
+ #### Added
440
+ - **Base signal infrastructure**:
441
+ - `Signal` - Abstract base class for all signals
442
+ - `SignalType` - Enumeration for signal types (technical, statistical, fundamental, sentiment, composite)
443
+ - `SignalDirection` - Signal direction indicators (long, short, neutral)
444
+ - `SignalMetadata` - Dataclass for signal metadata
445
+ - `SignalError` - Custom exception for signal errors
446
+ - `CompositeSignal` - Combine multiple signals with various methods
447
+ - **Signal caching system**:
448
+ - Automatic caching of generated signals
449
+ - Cache enable/disable functionality
450
+ - Cache key generation from inputs
451
+ - **Technical indicator signals** (6 signals):
452
+ - `MomentumSignal` - Rate of change momentum
453
+ - `MovingAverageCrossSignal` - MA crossover strategy
454
+ - `RSISignal` - Relative Strength Index
455
+ - `BollingerBandsSignal` - Price position in bands
456
+ - `MACDSignal` - MACD line crossover
457
+ - `VolumeWeightedSignal` - Volume-confirmed momentum
458
+ - **Statistical signals** (5 signals):
459
+ - `MeanReversionSignal` - Z-score based mean reversion
460
+ - `PairsSignal` - Pairs trading spread
461
+ - `TrendStrengthSignal` - Linear regression trend
462
+ - `VolatilitySignal` - Volatility regime detection
463
+ - `CorrelationSignal` - Rolling correlation signals
464
+ - **Signal composition**:
465
+ - Average combination method
466
+ - Weighted average with custom weights
467
+ - Voting mechanism (majority vote)
468
+ - Max/min signal selection
469
+ - Automatic signal alignment
470
+ - **Comprehensive test suite** (26 tests):
471
+ - Technical signal tests (12 tests)
472
+ - Statistical signal tests (5 tests)
473
+ - Composite signal tests (5 tests)
474
+ - Base functionality tests (4 tests)
475
+ - 100% test pass rate
476
+ - **Full module exports** in `__init__.py`
477
+
478
+ ### Phase 3: Data Loading Infrastructure
479
+
480
+ #### Added
481
+ - **Base data infrastructure**:
482
+ - `DataLoader` - Abstract base class for all loaders
483
+ - `PriceData` - Container class for OHLCV data with rich functionality
484
+ - `DataLoadError` - Custom exception for data loading errors
485
+ - **Multiple data loaders**:
486
+ - `CSVLoader` - Load from CSV files (single file or directory)
487
+ - `ParquetLoader` - Load from Parquet files (efficient binary format)
488
+ - `InMemoryLoader` - Wrap existing DataFrames
489
+ - `SyntheticDataLoader` - Generate test data with geometric Brownian motion
490
+ - `load_data()` - Convenience function for quick loading
491
+ - **Universe management**:
492
+ - `Universe` - Class for defining and manipulating asset universes
493
+ - `UniverseFilter` - Dataclass for filtering criteria
494
+ - `UNIVERSE_CONSTITUENTS` - Predefined universes (S&P 500, NASDAQ 100, DOW 30)
495
+ - `create_universe()` - Factory function for easy universe creation
496
+ - Set operations: intersection, union, difference
497
+ - Sampling and filtering capabilities
498
+ - **Preprocessing utilities** (11 functions):
499
+ - `handle_missing_data()` - ffill, bfill, drop, interpolate methods
500
+ - `resample_data()` - Change frequency with OHLCV aggregation
501
+ - `calculate_returns()` - Simple and log returns
502
+ - `normalize_prices()` - Normalize to base value
503
+ - `calculate_rolling_stats()` - Rolling mean and std
504
+ - `align_data()` - Align multiple DataFrames
505
+ - `remove_outliers()` - IQR and z-score methods
506
+ - `winsorize()` - Cap extreme values
507
+ - `forward_fill_gaps()` - Fill data gaps
508
+ - `ensure_business_days()` - Enforce business day index
509
+ - `calculate_volatility()` - Rolling volatility with annualization
510
+ - **PriceData container features**:
511
+ - `get_symbol_data()` - Extract single symbol
512
+ - `get_close_prices()` - Get close prices in wide format
513
+ - `get_field()` - Get any field in wide format
514
+ - `get_returns()` / `get_log_returns()` - Calculate returns
515
+ - `summary()` - Get summary statistics
516
+ - **Comprehensive test suite** (24 tests):
517
+ - Synthetic data generation tests
518
+ - PriceData container tests
519
+ - Universe operations tests
520
+ - Preprocessing function tests
521
+ - Loader tests (CSV, Parquet, InMemory)
522
+ - Data validation tests
523
+ - **Examples**: data_examples.py with 7 usage patterns
524
+ - **Full module exports** in `__init__.py`
525
+
526
+ ### Phase 2: Core Configuration System
527
+
528
+ #### Added
529
+ - **Pydantic configuration schemas**:
530
+ - `JSFBaseConfig` - Base class with serialization/validation
531
+ - `ExperimentConfig` - Complete experiment specification
532
+ - `StrategyConfig` - Strategy parameters with validation
533
+ - `OptimizationConfig` - Optimization settings
534
+ - `CostConfig` - Transaction cost models
535
+ - `RiskConfig` - Risk management settings
536
+ - `DataConfig` - Data source configuration
537
+ - `DateRangeConfig` - Date range validation
538
+ - **Enumerations** for all config options:
539
+ - StrategyType, UniverseType, FrequencyType
540
+ - RebalanceFrequency, OptimizationMethod
541
+ - CostModel, PositionSizing, RiskMetric, DataSource
542
+ - **Default parameter presets**:
543
+ - Strategy defaults for all 9 strategy types
544
+ - Optimization parameter grids
545
+ - Cost model presets (conservative, moderate, aggressive, zero_cost)
546
+ - Risk model presets (conservative, moderate, aggressive, long_only)
547
+ - **Convenience functions**:
548
+ - `create_experiment_config()` - Quick config builder
549
+ - `quick_config()` - Simplified config with presets
550
+ - `get_default_strategy_config()` - Get strategy defaults
551
+ - `get_cost_preset()` / `get_risk_preset()` - Get presets
552
+ - **Comprehensive validation**:
553
+ - Date format and range validation
554
+ - Parameter JSON-serializability checks
555
+ - Universe validation (non-empty lists)
556
+ - Leverage and position size constraints
557
+ - **Full serialization support**:
558
+ - JSON import/export with file support
559
+ - Dictionary conversion
560
+ - `copy_with()` for creating modified copies
561
+ - **Complete test suite** (70+ tests):
562
+ - Schema validation tests
563
+ - Serialization round-trip tests
564
+ - Preset functionality tests
565
+ - Error handling tests
566
+ - **Examples**: config_examples.py with 7 usage patterns
567
+
568
+ ### Phase 1: Foundation & Project Structure
569
+
570
+ #### Added
571
+ - Initial project structure with modular architecture
572
+ - Core package structure (config, data, signals, strategies, simulation, optimization, evaluation, reporting, utils)
573
+ - Comprehensive pyproject.toml with dependencies and tooling configuration
574
+ - Requirements files for core and development dependencies
575
+ - pytest configuration and test structure with fixtures
576
+ - Utility modules:
577
+ - Logging infrastructure with consistent formatting
578
+ - Time utilities for date parsing and manipulation
579
+ - I/O utilities for JSON, pickle, and DataFrame operations
580
+ - Parallel processing utilities
581
+ - Pre-commit hooks configuration
582
+ - EditorConfig for consistent coding styles
583
+ - Makefile for common development tasks
584
+ - Comprehensive README with project overview
585
+ - MIT License
586
+ - Contributing guidelines
587
+ - This CHANGELOG
588
+
589
+ #### Infrastructure
590
+ - Git repository initialized
591
+ - .gitignore configured
592
+ - Code quality tools configured (Black, Ruff, mypy)
593
+ - Test coverage configuration
594
+ - EditorConfig for consistent formatting
595
+
596
+ ---
597
+
598
+ ## Version History
599
+
600
+ ### [0.2.0-dev] - 2025-11-29
601
+
602
+ **Phase 2 Complete**: Core Configuration System
603
+
604
+ Comprehensive Pydantic-based configuration system with 7 schemas, 8 enums, presets, and 70+ tests.
605
+
606
+ ### [0.1.0-dev] - 2025-11-29
607
+
608
+ **Phase 1 Complete**: Foundation & Project Structure
609
+
610
+ This is the initial development version establishing the project foundation.
611
+
612
+ ---
613
+
614
+ ## Roadmap
615
+
616
+ - ~~**Phase 1**: Foundation & Project Structure~~ [Complete]
617
+ - ~~**Phase 2**: Core Configuration System~~ [Complete]
618
+ - ~~**Phase 3**: Data Loading Infrastructure~~ [Complete]
619
+ - **Phase 4-6**: Signal Framework
620
+ - **Phase 7-9**: Strategy Templates
621
+ - **Phase 10-11**: Backtesting Engine
622
+ - **Phase 12-13**: Evaluation & Robustness
623
+ - **Phase 14-15**: Optimization Framework
624
+ - **Phase 16**: Reporting & Visualization
625
+ - **Phase 17**: High-Level API
626
+ - **Phase 18**: CLI Tool
627
+ - **Phase 19**: SDK Documentation
628
+ - **Phase 20**: Release Preparation
629
+
630
+ [unreleased]: https://github.com/JaiAnshSB26/JBAC-Strategy-Foundry/compare/v0.2.0-dev...HEAD
631
+ [0.2.0-dev]: https://github.com/JaiAnshSB26/JBAC-Strategy-Foundry/compare/v0.1.0-dev...v0.2.0-dev
632
+ [0.1.0-dev]: https://github.com/JaiAnshSB26/JBAC-Strategy-Foundry/releases/tag/v0.1.0-dev