Advanced Stock Price Prediction Model

Ensemble machine learning model combining technical indicators and XGBoost for accurate stock price predictions

Data Collection & Processing

Data Sources

  • Yahoo Finance API integration using yfinance
  • Historical price data: Open, High, Low, Close, Volume
  • Maximum available historical data for comprehensive training

Data Preprocessing

  • Outlier removal using IQR method
  • Standard scaling for price features
  • Logarithmic transformation for volume data
  • Forward and backward filling for missing values

Technical Indicators

IndicatorParametersPurpose
SMA15 daysTrend identification
EMA5 daysShort-term momentum
RSI15 daysOverbought/Oversold conditions
Bollinger Bands56 days, 2 stdVolatility measurement
MACDDefaultTrend direction and momentum
ADXDefaultTrend strength
AroonUp/DownTrend identification and strength

XGBoost Model Architecture

Hyperparameter Search Space

n_estimators[5, 10, 20, 25, 30, 35, 40]
max_depth[3, 4, 5]
learning_rate[0.01, 0.1, 0.2]
subsample[0.6, 0.8, 1.0]
colsample_bytree[0.6, 0.8, 1.0]
reg_alpha[0, 0.1, 1]
reg_lambda[1, 10, 100]

Model Features

  • Objective: reg:squarederror
  • 15-fold cross-validation
  • RandomizedSearchCV for optimization
  • R² scoring for parameter selection
  • MSE, RMSE for evaluation