End-to-end pipeline for stock market data analysis in R.
Installation · Examples · Function Reference · User Manual
MISdata provides a complete workflow for retrieving, cleaning,
transforming, and analyzing stock market data. The package fetches
index constituents from Wikipedia and OHLCV history from Yahoo Finance,
then offers utilities for NA handling, time-series format conversion
(via tsbox), period aggregation with OHLCV-aware semantics,
exploratory analysis (line plots, ACF/PACF, STL decomposition), and
ARIMA-based forecasting with multi-level confidence bands.
This package was developed as part of an undergraduate project and follows CRAN-compatible standards.
flowchart LR
A["Choose symbols<br/>get_index_components()<br/>sample_symbols()"]
B["Fetch OHLCV data<br/>get_stock()"]
C["Clean missing values<br/>clean_stock()"]
D["Convert format<br/>convert_stock()"]
E["Aggregate period<br/>change_period()"]
F["Explore data<br/>plot_stock()<br/>get_acf() / get_pacf()<br/>plot_seasonal()"]
G["Forecast series<br/>forecast_stock()"]
A --> B --> C
C --> D
C --> E
D --> F
E --> F
C --> F
F --> G
Install the latest stable version from GitHub:
# install.packages("remotes")
remotes::install_github("MISDataGit/MISdata")The examples below use Apple and Microsoft closing prices from January 1, 2023 through December 31, 2024.
library(MISdata)
symbols <- c("AAPL", "MSFT")
stocks <- get_stock(
symbols = symbols,
start = "2023-01-01",
end = "2024-12-31",
columns = "Close"
)
stocks <- clean_stock(stocks, na_method = "trim")
history_plot <- plot_stock(
stocks,
symbols = symbols,
column = "Close",
title = "Daily Closing Prices: Apple and Microsoft"
)
history_plotapple_forecast <- forecast_stock(
stocks,
symbol = "AAPL",
column = "Close",
horizon = 30,
ci_levels = c(80, 95)
)
summary(apple_forecast$model)
apple_forecast$plotThe forecast chart includes the fitted ARIMA model, a 30-step point forecast, and 80% and 95% confidence intervals.
To regenerate both README images from the package source:
Rscript tools/generate-readme-images.RThe package is organized into six modules:
| Module | Functions | Purpose |
|---|---|---|
fetch.R |
get_index_components(), sample_symbols(), get_stock() |
Retrieve index constituents and OHLCV data |
clean.R |
clean_stock() |
Group-wise NA handling on long data frames |
convert.R |
convert_stock() |
Convert between long df, xts, tsibble, zoo, ts |
period.R |
change_period() |
OHLCV-aware period aggregation |
eda.R |
plot_stock(), get_acf(), get_pacf(), plot_seasonal() |
Visualization and autocorrelation analysis |
forecast.R |
forecast_stock() |
ARIMA forecasting via forecast::auto.arima() |
For complete usage instructions, read the
MISdata User Manual, or install
the package and run ?MISdata or ?<function_name>.
- Batuhan Karaköy
- Enes Türkoğlu
- Metehan Kaygısız
GPL (>= 3). See LICENSE.md for the full text.


