TIME SERIES BASED STOCK MARKET FORECASTING USING PYTHON
DOI:
https://doi.org/10.64751/b3f0qe28Abstract
Stock prices are recorded as a sequence of values over time, and the question of whether their future movement can be forecast has interested investors, economists, and engineers for many decades. Prices are influenced by company performance, economic news, interest rates, global markets, and the collective behaviour of traders, which makes the series noisy and only partly predictable. This paper presents a time series based stock market forecasting system developed in Python that treats daily price data as a signal, applies established statistical and machine learning methods to forecast short-term movement, and evaluates these forecasts honestly against simple baselines. The system collects daily open, high, low, close, and volume data for selected stocks listed on Indian exchanges and for a market index using a publicly available data library. The data is cleaned to handle missing trading days, stock splits, and bonus issues, and is transformed into returns, which are closer to stationary than raw prices. Stationarity is checked using the Augmented Dickey-Fuller test, and autocorrelation and partial autocorrelation functions are examined to guide the choice of model order. Technical indicators such as moving averages, the relative strength index, moving average convergence divergence, Bollinger band width, and rolling volatility are calculated as additional features. Several forecasting approaches are implemented and compared. Classical time series models include ARIMA and exponential smoothing, and volatility is modelled with a GARCH model. Machine learning models include Linear Regression, Random Forest, Support Vector Regression, and XGBoost using lagged returns and indicators as inputs, and deep learning is represented by a Long Short-Term Memory network trained on sliding windows of past values. All models are evaluated using walkforward validation, in which the model is retrained on data up to a given date and tested on the following period, and performance is measured by RMSE, MAE, MAPE, and directional accuracy. The results show that the naive forecast, which assumes tomorrow's price equals today's, is difficult to beat on price-level error, as expected for a financial series. However, the LSTM and XGBoost models achieve directional accuracy moderately above fifty percent on several stocks, and the GARCH model produces useful estimates of expected volatility. A Streamlit dashboard allows the user to select a stock, view historical prices and indicators, compare model forecasts with actual values, see forecast intervals, and review each model's error statistics. The system is intended as an analytical and educational tool that demonstrates the correct use of time series methods on financial data, including stationarity testing, leakage-free validation, and comparison with baselines. It is not a trading recommendation system. Future work includes the use of news sentiment, multivariate models that capture relationships between stocks, and risk-adjusted evaluation using simulated portfolios.
Downloads
Published
Issue
Section
License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.







