BBCA Stock Forecasting & News Sentiment Analysis
An end-to-end data pipeline and machine learning system that forecasts BBCA stock prices across multiple time horizons by integrating quantitative historical market data with qualitative Indonesian news sentiment analysis.
The Problem
Stock price prediction in the banking sector is inherently challenging because price movements are influenced not only by past technical indicators and trading volume, but also heavily impacted by public market sentiment and financial news releases.
Conventional forecasting models often rely exclusively on historical numerical sequences (OHLCV). When significant macro-economic announcements or quarterly earnings reports surface, purely numerical models fail to react in time because they lack context from unstructured text data.
My Contribution
I designed, developed, and evaluated the end-to-end data pipeline, NLP sentiment engine, deep learning forecasting model, and interactive dashboard interface.
Data Ingestion Pipeline
NLP Sentiment Engine
Multi-Horizon LSTM
Database & Web Dashboard
Workflow & Data Flow
The data moves sequentially from automated ingestion through NLP sentiment scoring and time-series neural network forecasting into a centralized MySQL database and Flask UI.
The Solution
The final solution is a modular application built in Python and Flask that automates the entire lifecycle of stock price analysis. Instead of relying purely on isolated statistical indicators, the system integrates daily sentiment polarity as an additional time-series dimension alongside conventional price signals (closing prices, moving averages, volume).
By supporting multi-horizon forecasting (H+1, H+3, H+5, H+7), the system provides flexible short-term and medium-term visibility, enabling users to evaluate forecasted trends over different time intervals accompanied by contextual news feeds.
Empirical Validation, Statistical Significance & Ablation Study
Reproducible econometric evaluation across 5 independent random seeds, 300 human-annotated news headlines, Harvey–Leybourne–Newbold Diebold–Mariano significance testing, and sentiment sub-feature ablation:
1. Multi-Horizon Performance Across 5 Independent Seeds ([42, 101, 777, 2024, 99])
| Horizon | Baseline MAPE | Hybrid MAPE | Relative Gain | MAE (Baseline → Hybrid) | RMSE (Baseline → Hybrid) |
|---|---|---|---|---|---|
| H+1 | 2.04 ± 0.12% | 1.50 ± 0.00% | 26.1% | Rp 147.0 → Rp 107.7 | Rp 191.3 → Rp 145.6 |
| H+3 | 2.98 ± 0.04% | 2.45 ± 0.01% | 17.8% | Rp 215.4 → Rp 175.4 | Rp 277.3 → Rp 242.3 |
| H+5 | 3.66 ± 0.11% | 3.01 ± 0.01% | 17.8% | Rp 265.7 → Rp 216.8 | Rp 340.1 → Rp 302.6 |
| H+7 | 4.35 ± 0.27% | 3.58 ± 0.03% | 17.6% | Rp 316.5 → Rp 258.7 | Rp 393.9 → Rp 352.1 |
2. HLN Diebold–Mariano Significance
Finite-sample Harvey–Leybourne–Newbold adjusted Diebold–Mariano test confirming Hybrid error reduction is statistically non-random across every forecasting horizon:
| Horizon | N | d̄ (APE) | DM (Ensemble) | p-Value |
|---|---|---|---|---|
| H+1 | 300 | 0.50% | 6.7763 | < 0.001 |
| H+3 | 299 | 0.52% | 4.0807 | < 0.001 |
| H+5 | 299 | 0.63% | 4.4585 | < 0.001 |
| H+7 | 298 | 0.74% | 3.8348 | < 0.001 |
3. Human Audit & Production Safeguards
κ = 0.7180 (Substantial Agreement, Landis & Koch) across Positive/Neutral/Negative labels.
1,560 clean OHLCV bars and 4,367 news headlines serving out-of-the-box with zero MySQL dependency via automatic SQLite bootstrap.
5/5 unit & Flask integration tests covering feature alignment, Keras/TF-IDF inference shapes, HLN DM math, Cohen's Kappa, and REST API endpoints.
4. Sentiment Feature Ablation Study (H+1 & H+7 Across 5 Seeds)
| Feature Variant | H+1 MAPE (%) | H+1 RMSE (IDR) | H+7 MAPE (%) | H+7 RMSE (IDR) |
|---|---|---|---|---|
| Baseline (Market-Only, 13 Features) | 2.04% ± 0.12% | 191.3 ± 7.5 | 4.17% ± 0.19% | 391.4 ± 6.9 |
| Variant 1 (Sentiment Score Only) | 1.51% ± 0.01% | 146.1 ± 0.4 | 3.59% ± 0.07% | 352.4 ± 4.2 |
| Variant 2 (News Volume & Burst Only) | 1.51% ± 0.01% | 146.8 ± 0.2 | 3.62% ± 0.01% | 355.0 ± 1.7 |
| Variant 3 (Pos/Neg Proportion Only) | 1.50% ± 0.01% | 145.6 ± 0.4 | 3.60% ± 0.01% | 353.9 ± 0.7 |
| Full Hybrid (All 9 Sentiment Features) | 1.50% ± 0.00% | 145.5 ± 0.1 | 3.55% ± 0.02% | 350.0 ± 1.9 |
Project Results
Key deliverables and technical outcomes achieved upon completion of the project:
Unified Multi-Source Pipeline
Successfully automated the pipeline from live news feed scraping and stock API ingestion to persistent database storage without manual steps.
1.50% H+1 MAPE & 92.06% NLP Accuracy
Cut H+1 forecasting error by 26.1% across 5 independent runs (1.50% vs 2.04% Baseline) paired with TF-IDF + Logistic Regression sentiment classification (Kappa 0.7180 on N=300 human audit).
Statistically Verified Multi-Horizon Gains
Proven significant across H+1, H+3, H+5, and H+7 via HLN Diebold–Mariano tests (p < 0.001) and feature ablation isolating sentiment score, volume burst, and ratio impact.
Interactive Dashboard Delivery
Delivered a clean web interface where technical metrics, forecasted trajectory lines, and categorized news sentiment feeds are visualized in one place.
Tech Stack
Project Gallery
Visual overview of the forecasting dashboard, chart interfaces, and sentiment classification results:
BBCA Forecast Studio — Main Web App Dashboard
Interactive Flask web application interface featuring live candlestick charts, multi-horizon filters, background news scraping status (every 30 min), and export buttons.
Daily News Sentiment Score Calculation Modal
Detail modal displaying 27 processed news articles for the trading day, showing exact mathematical aggregation formula (Total Score: +6.8195 / 27 = +0.2526 daily average), polarity badges, and media source links.
Prediction Comparison Table with News Detail Triggers
Daily tabular comparison showing Actual Price vs Baseline LSTM vs Hybrid LSTM + Sentiment, equipped with clickable [Detail Berita] modal triggers per trading day.
Multi-Horizon Model Trajectory Evaluation
Interactive comparison of actual prices vs predictions across H+1, H+3, H+5, and H+7 trading horizons.
MAPE Error Reduction Across All Horizons
Quantified 11.6% to 27.3% forecasting error reduction achieved by combining news sentiment with LSTM.
News Sentiment Classifier Confusion Matrix
3-class confusion matrix evaluating 1,776 financial news headlines classified via TF-IDF + Logistic Regression.
Manual Excel Evaluation: MAPE Formula & Horizons
Authentic spreadsheet (Perhitungan_MAPE.xlsx) verifying mathematical error percentages row-by-row across H+1 to H+7, confirming hybrid model performance (MAPE 1.53% - Sangat Baik).
Python Text Preprocessing Audit in Excel
Spreadsheet audit (Perhitungan_Manual_Berita.xlsx) tracking raw headline ingestion across media sources (CNBC, SINDONews, Ajaib, Kompas) to normalized case-folded tokens.
Daily Sentiment Score & Ratio Time-Series in Excel
Time-series matrix (data_sentimen_harian.xlsx) aggregating daily publication count, composite sentiment scores, and positive/negative/neutral ratio proportions.