A comprehensive Python implementation for forecasting NIFTY 50 stock prices using multiple Bayesian modeling approaches. This project leverages PyMC for Bayesian inference and includes various model architectures for robust prediction.
- Multiple Bayesian model implementations
- Technical indicator generation
- GPU acceleration support
- Model persistence
- Forecast visualization
- Uncertainty quantification
-
Bayesian Linear Regression
- Multiple technical indicators
- Trend component
- Global parameter estimation
-
AR(1) Model
- Simple autoregressive structure
- Single lag dependency
- Basic time series patterns
-
Hierarchical Model
- Year-level grouping
- Volatility and momentum features
- Temporal clustering support
-
Gaussian Process Regression (GPR)
- Nonlinear relationships
- Sparse approximation
- Matern 3/2 kernel
-
Dynamic Regression
- Time-varying coefficients
- Random walk evolution
- Adaptive trend modeling
- RSI (Relative Strength Index)
- Volatility (14-day rolling)
- Momentum (5-day difference)
- SMA (Simple Moving Average)
- EMA (Exponential Moving Average)
- Automatic feature engineering
- Data normalization
- Missing value handling
- Time series preprocessing
- MCMC sampling with PyMC
- GPU acceleration support
- Proper chain initialization
- Convergence monitoring
- Multi-step ahead predictions
- Uncertainty quantification
- Confidence intervals
- Forecast visualization
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install pymc numpy pandas matplotlib jax
# Load and process data
df = load_nifty_data("data/nifty_data.csv")
# Train models
results = train_and_evaluate_models(df)
# Save trained models
save_trained_models(results)
Models are automatically saved with:
- Model parameters
- MCMC traces
- Scaling parameters
Each model generates:
- Historical vs predicted plots
- Confidence intervals
- Trend analysis
- Forecast evaluation
- Framework: PyMC for Bayesian modeling
- Acceleration: JAX for GPU support
- Visualization: Matplotlib
- Data Processing: Pandas, NumPy
MIT License
Feel free to open issues and pull requests for improvements and bug fixes.