Update README.md
Browse files
README.md
CHANGED
|
@@ -176,151 +176,197 @@ pretty_name: S&P 500 Comprehensive Stock Market Dataset
|
|
| 176 |
size_categories:
|
| 177 |
- 100K<n<1M
|
| 178 |
---
|
| 179 |
-
S&P 500 Comprehensive Stock Market Dataset
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
Dataset
|
| 184 |
-
|
| 185 |
-
Features:
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
Volatility: Historical volatility measure
|
| 210 |
-
Engineered Features (16 features)
|
| 211 |
-
Price_Change: Daily price change
|
| 212 |
-
Price_Change_5d: 5-day price change
|
| 213 |
-
High_Low_Ratio: Ratio of high to low prices
|
| 214 |
-
Open_Close_Ratio: Ratio of open to close prices
|
| 215 |
-
Volume_SMA: Volume simple moving average
|
| 216 |
-
Volume_Ratio: Current volume to average volume ratio
|
| 217 |
-
Lagged Features (32 features)
|
| 218 |
-
The dataset includes lagged versions of key features for time series modeling:
|
| 219 |
-
|
| 220 |
-
Price Lags (5 features)
|
| 221 |
-
Close_lag_1 to Close_lag_10: Historical closing prices
|
| 222 |
-
Volume Lags (5 features)
|
| 223 |
-
Volume_lag_1 to Volume_lag_10: Historical volume data
|
| 224 |
-
Price Change Lags (5 features)
|
| 225 |
-
Price_Change_lag_1 to Price_Change_lag_10: Historical price changes
|
| 226 |
-
RSI Lags (5 features)
|
| 227 |
-
RSI_lag_1 to RSI_lag_10: Historical RSI values
|
| 228 |
-
MACD Lags (5 features)
|
| 229 |
-
MACD_lag_1 to MACD_lag_10: Historical MACD values
|
| 230 |
-
Volatility Lags (5 features)
|
| 231 |
-
Volatility_lag_1 to Volatility_lag_10: Historical volatility measures
|
| 232 |
-
Target Variables (12 features)
|
| 233 |
-
The dataset includes multiple prediction targets for different time horizons:
|
| 234 |
-
|
| 235 |
-
1-Day Predictions
|
| 236 |
-
Future_Return_1d: Next day return percentage
|
| 237 |
-
Future_Up_1d: Binary indicator for price increase
|
| 238 |
-
Future_Category_1d: Categorical classification of price movement
|
| 239 |
-
5-Day Predictions
|
| 240 |
-
Future_Return_5d: 5-day forward return
|
| 241 |
-
Future_Up_5d: 5-day binary direction
|
| 242 |
-
Future_Category_5d: 5-day categorical movement
|
| 243 |
-
10-Day Predictions
|
| 244 |
-
Future_Return_10d: 10-day forward return
|
| 245 |
-
Future_Up_10d: 10-day binary direction
|
| 246 |
-
Future_Category_10d: 10-day categorical movement
|
| 247 |
-
20-Day Predictions
|
| 248 |
-
Future_Return_20d: 20-day forward return
|
| 249 |
-
Future_Up_20d: 20-day binary direction
|
| 250 |
-
Future_Category_20d: 20-day categorical movement
|
| 251 |
-
Use Cases
|
| 252 |
-
Primary Applications
|
| 253 |
-
Stock Price Prediction: Forecast future stock prices using technical indicators and historical patterns
|
| 254 |
-
Direction Classification: Predict whether stock prices will go up or down
|
| 255 |
-
Risk Assessment: Analyze volatility patterns and market risk
|
| 256 |
-
Trading Strategy Development: Backtest and develop algorithmic trading strategies
|
| 257 |
-
Financial Research: Academic research in computational finance and market efficiency
|
| 258 |
-
Machine Learning Tasks
|
| 259 |
-
Regression: Predict continuous returns (Future_Return_*)
|
| 260 |
-
Binary Classification: Predict price direction (Future_Up_*)
|
| 261 |
-
Multi-class Classification: Predict categorical movements (Future_Category_*)
|
| 262 |
-
Time Series Forecasting: Leverage lagged features for temporal modeling
|
| 263 |
-
Anomaly Detection: Identify unusual market patterns
|
| 264 |
-
Data Quality and Processing
|
| 265 |
-
Feature Engineering Quality
|
| 266 |
-
Technical Indicators: Industry-standard calculations for all technical analysis features
|
| 267 |
-
Lag Features: Comprehensive historical context with multiple time horizons
|
| 268 |
-
Target Engineering: Multiple prediction horizons for flexible modeling approaches
|
| 269 |
-
Data Validation: Processed through robust data validation pipelines
|
| 270 |
-
Missing Data Handling
|
| 271 |
-
Forward-fill methodology for missing price data
|
| 272 |
-
Proper handling of weekends and market holidays
|
| 273 |
-
Corporate action adjustments included
|
| 274 |
-
Data Integrity
|
| 275 |
-
All features computed using vectorized operations for consistency
|
| 276 |
-
Proper handling of stock splits and dividend adjustments
|
| 277 |
-
No look-ahead bias in feature construction
|
| 278 |
-
Usage Examples
|
| 279 |
-
Loading the Dataset
|
| 280 |
-
python
|
| 281 |
from datasets import load_dataset
|
| 282 |
|
|
|
|
| 283 |
dataset = load_dataset("Adilbai/stock-dataset")
|
| 284 |
df = dataset["train"].to_pandas()
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
# View dataset structure
|
| 288 |
print(f"Dataset shape: {df.shape}")
|
| 289 |
print(f"Date range: {df['Date'].min()} to {df['Date'].max()}")
|
| 290 |
-
print(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
|
| 292 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
print(df['Future_Up_1d'].value_counts())
|
| 294 |
-
|
| 295 |
-
|
|
|
|
|
|
|
|
|
|
| 296 |
# Technical indicators
|
| 297 |
-
technical_features = [
|
|
|
|
|
|
|
|
|
|
| 298 |
|
| 299 |
# Lagged features
|
| 300 |
lag_features = [col for col in df.columns if 'lag' in col]
|
| 301 |
|
| 302 |
-
#
|
| 303 |
-
targets = [
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
If you use this dataset in your research, please cite:
|
| 322 |
|
| 323 |
-
bibtex
|
| 324 |
@dataset{adilbai_sp500_dataset,
|
| 325 |
title={S&P 500 Comprehensive Stock Market Dataset},
|
| 326 |
author={Adilbai},
|
|
@@ -328,8 +374,22 @@ bibtex
|
|
| 328 |
publisher={Hugging Face},
|
| 329 |
url={https://huggingface.co/datasets/Adilbai/stock-dataset}
|
| 330 |
}
|
| 331 |
-
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
|
| 334 |
-
|
| 335 |
-
This dataset is provided for educational and research purposes only. It should not be used as the sole basis for investment decisions. Past performance does not guarantee future results. Users should conduct their own research and consider consulting with financial advisors before making investment decisions.
|
|
|
|
| 176 |
size_categories:
|
| 177 |
- 100K<n<1M
|
| 178 |
---
|
| 179 |
+
# ๐ S&P 500 Comprehensive Stock Market Dataset
|
| 180 |
+
|
| 181 |
+
<div align="center">
|
| 182 |
+
|
| 183 |
+

|
| 184 |
+

|
| 185 |
+

|
| 186 |
+

|
| 187 |
+

|
| 188 |
+
|
| 189 |
+
</div>
|
| 190 |
+
|
| 191 |
+
## ๐ฏ Dataset Overview
|
| 192 |
+
|
| 193 |
+
This comprehensive dataset contains **620,095 daily observations** of S&P 500 companies with **73 meticulously engineered features** spanning the last 5 years. Designed specifically for time series forecasting, stock price prediction, and advanced financial modeling tasks.
|
| 194 |
+
|
| 195 |
+
### ๐ Key Statistics
|
| 196 |
+
|
| 197 |
+
| Metric | Value |
|
| 198 |
+
|--------|-------|
|
| 199 |
+
| **Total Records** | 620,095 daily observations |
|
| 200 |
+
| **Features** | 73 comprehensive features |
|
| 201 |
+
| **Time Period** | Last 5 years |
|
| 202 |
+
| **Companies** | S&P 500 constituents |
|
| 203 |
+
| **Data Source** | Yahoo Finance API |
|
| 204 |
+
| **Update Frequency** | Daily market data |
|
| 205 |
+
|
| 206 |
+
## ๐ Quick Start
|
| 207 |
+
|
| 208 |
+
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
from datasets import load_dataset
|
| 210 |
|
| 211 |
+
# Load the dataset
|
| 212 |
dataset = load_dataset("Adilbai/stock-dataset")
|
| 213 |
df = dataset["train"].to_pandas()
|
| 214 |
+
|
| 215 |
+
# Basic info
|
|
|
|
| 216 |
print(f"Dataset shape: {df.shape}")
|
| 217 |
print(f"Date range: {df['Date'].min()} to {df['Date'].max()}")
|
| 218 |
+
print(f"Unique tickers: {df['Ticker'].nunique()}")
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
## ๐ง Feature Categories
|
| 222 |
+
|
| 223 |
+
### ๐ Basic Market Data (9 features)
|
| 224 |
+
- **Date**: Trading date timestamp
|
| 225 |
+
- **OHLC Data**: Open, High, Low, Close prices
|
| 226 |
+
- **Volume**: Number of shares traded
|
| 227 |
+
- **Corporate Actions**: Dividends, Stock Splits
|
| 228 |
+
- **Ticker**: Stock symbol identifier
|
| 229 |
+
|
| 230 |
+
### ๐ Technical Analysis Indicators (16 features)
|
| 231 |
+
|
| 232 |
+
#### Moving Averages
|
| 233 |
+
- `SMA_5`, `SMA_10`, `SMA_20`, `SMA_50`: Simple Moving Averages
|
| 234 |
+
- `EMA_12`, `EMA_26`: Exponential Moving Averages
|
| 235 |
+
|
| 236 |
+
#### Momentum Indicators
|
| 237 |
+
- `MACD`, `MACD_Signal`, `MACD_Histogram`: MACD components
|
| 238 |
+
- `RSI`: Relative Strength Index (14-period)
|
| 239 |
+
|
| 240 |
+
#### Volatility Indicators
|
| 241 |
+
- `BB_Middle`, `BB_Upper`, `BB_Lower`: Bollinger Bands
|
| 242 |
+
- `BB_Width`, `BB_Position`: Bollinger Bands metrics
|
| 243 |
+
- `Volatility`: Historical volatility measure
|
| 244 |
+
|
| 245 |
+
### โ๏ธ Engineered Features (16 features)
|
| 246 |
+
- `Price_Change`: Daily price change
|
| 247 |
+
- `Price_Change_5d`: 5-day price change
|
| 248 |
+
- `High_Low_Ratio`: High to low price ratio
|
| 249 |
+
- `Open_Close_Ratio`: Open to close price ratio
|
| 250 |
+
- `Volume_SMA`: Volume moving average
|
| 251 |
+
- `Volume_Ratio`: Volume to average ratio
|
| 252 |
+
|
| 253 |
+
### โณ Lagged Features (32 features)
|
| 254 |
+
Historical context with 10-period lags for:
|
| 255 |
+
- **Price Lags**: `Close_lag_1` to `Close_lag_10`
|
| 256 |
+
- **Volume Lags**: `Volume_lag_1` to `Volume_lag_10`
|
| 257 |
+
- **Price Change Lags**: `Price_Change_lag_1` to `Price_Change_lag_10`
|
| 258 |
+
- **RSI Lags**: `RSI_lag_1` to `RSI_lag_10`
|
| 259 |
+
- **MACD Lags**: `MACD_lag_1` to `MACD_lag_10`
|
| 260 |
+
- **Volatility Lags**: `Volatility_lag_1` to `Volatility_lag_10`
|
| 261 |
+
|
| 262 |
+
### ๐ฏ Target Variables (12 features)
|
| 263 |
+
|
| 264 |
+
| Time Horizon | Return | Direction | Category |
|
| 265 |
+
|--------------|--------|-----------|----------|
|
| 266 |
+
| **1-Day** | `Future_Return_1d` | `Future_Up_1d` | `Future_Category_1d` |
|
| 267 |
+
| **5-Day** | `Future_Return_5d` | `Future_Up_5d` | `Future_Category_5d` |
|
| 268 |
+
| **10-Day** | `Future_Return_10d` | `Future_Up_10d` | `Future_Category_10d` |
|
| 269 |
+
| **20-Day** | `Future_Return_20d` | `Future_Up_20d` | `Future_Category_20d` |
|
| 270 |
+
|
| 271 |
+
## ๐ฏ Use Cases
|
| 272 |
+
|
| 273 |
+
### ๐ฎ Primary Applications
|
| 274 |
+
- **Stock Price Prediction**: Forecast future prices using technical indicators
|
| 275 |
+
- **Direction Classification**: Predict price movement direction
|
| 276 |
+
- **Risk Assessment**: Analyze volatility and market risk patterns
|
| 277 |
+
- **Trading Strategy Development**: Backtest algorithmic strategies
|
| 278 |
+
- **Financial Research**: Academic computational finance research
|
| 279 |
+
|
| 280 |
+
### ๐ค Machine Learning Tasks
|
| 281 |
+
- **Regression**: Predict continuous returns (`Future_Return_*`)
|
| 282 |
+
- **Binary Classification**: Predict direction (`Future_Up_*`)
|
| 283 |
+
- **Multi-class Classification**: Predict movements (`Future_Category_*`)
|
| 284 |
+
- **Time Series Forecasting**: Leverage lagged features
|
| 285 |
+
- **Anomaly Detection**: Identify unusual market patterns
|
| 286 |
+
|
| 287 |
+
## ๐ Example Usage
|
| 288 |
|
| 289 |
+
### Data Exploration
|
| 290 |
+
```python
|
| 291 |
+
# View dataset structure
|
| 292 |
+
print(f"Dataset shape: {df.shape}")
|
| 293 |
+
print(f"Features: {df.columns.tolist()}")
|
| 294 |
+
|
| 295 |
+
# Target distribution
|
| 296 |
print(df['Future_Up_1d'].value_counts())
|
| 297 |
+
print(df['Future_Category_1d'].value_counts())
|
| 298 |
+
```
|
| 299 |
+
|
| 300 |
+
### Feature Selection
|
| 301 |
+
```python
|
| 302 |
# Technical indicators
|
| 303 |
+
technical_features = [
|
| 304 |
+
'SMA_5', 'SMA_10', 'RSI', 'MACD',
|
| 305 |
+
'BB_Position', 'Volatility'
|
| 306 |
+
]
|
| 307 |
|
| 308 |
# Lagged features
|
| 309 |
lag_features = [col for col in df.columns if 'lag' in col]
|
| 310 |
|
| 311 |
+
# All targets
|
| 312 |
+
targets = [col for col in df.columns if 'Future_' in col]
|
| 313 |
+
```
|
| 314 |
+
|
| 315 |
+
### Model Training Example
|
| 316 |
+
```python
|
| 317 |
+
from sklearn.ensemble import RandomForestRegressor
|
| 318 |
+
from sklearn.model_selection import TimeSeriesSplit
|
| 319 |
+
|
| 320 |
+
# Prepare features and target
|
| 321 |
+
features = technical_features + lag_features
|
| 322 |
+
X = df[features].fillna(method='ffill')
|
| 323 |
+
y = df['Future_Return_1d']
|
| 324 |
+
|
| 325 |
+
# Time series split
|
| 326 |
+
tscv = TimeSeriesSplit(n_splits=5)
|
| 327 |
+
model = RandomForestRegressor(n_estimators=100)
|
| 328 |
+
|
| 329 |
+
# Train model
|
| 330 |
+
for train_idx, test_idx in tscv.split(X):
|
| 331 |
+
X_train, X_test = X.iloc[train_idx], X.iloc[test_idx]
|
| 332 |
+
y_train, y_test = y.iloc[train_idx], y.iloc[test_idx]
|
| 333 |
+
|
| 334 |
+
model.fit(X_train, y_train)
|
| 335 |
+
predictions = model.predict(X_test)
|
| 336 |
+
```
|
| 337 |
+
|
| 338 |
+
## โ ๏ธ Important Considerations
|
| 339 |
+
|
| 340 |
+
### ๐ด Data Limitations
|
| 341 |
+
- **Survivorship Bias**: Only current S&P 500 constituents included
|
| 342 |
+
- **Market Hours**: Regular trading session data only
|
| 343 |
+
- **Corporate Actions**: Historical adjustments may affect patterns
|
| 344 |
+
|
| 345 |
+
### โก Usage Guidelines
|
| 346 |
+
- **Temporal Order**: Maintain chronological order in train/test splits
|
| 347 |
+
- **Look-ahead Bias**: Avoid using future information in features
|
| 348 |
+
- **Market Regimes**: Performance may vary across market conditions
|
| 349 |
+
- **Feature Correlation**: Technical indicators share underlying price data
|
| 350 |
+
|
| 351 |
+
## ๐ Data Quality
|
| 352 |
+
|
| 353 |
+
### โ
Quality Assurance
|
| 354 |
+
- **Industry-standard** technical indicator calculations
|
| 355 |
+
- **Comprehensive** historical context with multiple time horizons
|
| 356 |
+
- **Robust** data validation pipelines
|
| 357 |
+
- **Proper handling** of corporate actions and market holidays
|
| 358 |
+
|
| 359 |
+
### ๐ง Data Processing
|
| 360 |
+
- **Forward-fill** methodology for missing data
|
| 361 |
+
- **Vectorized operations** for consistency
|
| 362 |
+
- **No look-ahead bias** in feature construction
|
| 363 |
+
- **Dividend and split** adjustments included
|
| 364 |
+
|
| 365 |
+
## ๐ Citation
|
| 366 |
+
|
| 367 |
If you use this dataset in your research, please cite:
|
| 368 |
|
| 369 |
+
```bibtex
|
| 370 |
@dataset{adilbai_sp500_dataset,
|
| 371 |
title={S&P 500 Comprehensive Stock Market Dataset},
|
| 372 |
author={Adilbai},
|
|
|
|
| 374 |
publisher={Hugging Face},
|
| 375 |
url={https://huggingface.co/datasets/Adilbai/stock-dataset}
|
| 376 |
}
|
| 377 |
+
```
|
| 378 |
+
|
| 379 |
+
## ๐ License
|
| 380 |
+
|
| 381 |
+
This dataset is released under the **MIT License**. While the dataset compilation and feature engineering are provided under MIT license, users should be aware of Yahoo Finance's terms of service for the underlying data.
|
| 382 |
+
|
| 383 |
+
## โ ๏ธ Disclaimer
|
| 384 |
+
|
| 385 |
+
> **Important**: This dataset is provided for educational and research purposes only. It should not be used as the sole basis for investment decisions. Past performance does not guarantee future results. Users should conduct their own research and consider consulting with financial advisors before making investment decisions.
|
| 386 |
+
|
| 387 |
+
---
|
| 388 |
+
|
| 389 |
+
<div align="center">
|
| 390 |
+
|
| 391 |
+
**Built with โค๏ธ for the financial ML community**
|
| 392 |
+
|
| 393 |
+
[๐ค Hugging Face](https://huggingface.co/datasets/Adilbai/stock-dataset) โข [๐ Dataset](https://huggingface.co/datasets/Adilbai/stock-dataset) โข [๐ Issues](https://huggingface.co/datasets/Adilbai/stock-dataset/discussions)
|
| 394 |
|
| 395 |
+
</div>
|
|
|