Adilbai commited on
Commit
38f69fb
ยท
verified ยท
1 Parent(s): 807977e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +194 -134
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
- Dataset Description
181
- This dataset contains comprehensive historical stock market data for S&P 500 companies, spanning the last 5 years with extensive feature engineering and technical analysis indicators. The dataset is designed for time series forecasting, stock price prediction, and financial modeling tasks.
182
-
183
- Dataset Summary
184
- Total Records: 620,095 daily observations
185
- Features: 73 comprehensive features including raw price data, technical indicators, and engineered features
186
- Time Period: Last 5 years of historical data
187
- Data Source: Yahoo Finance API
188
- Companies: S&P 500 constituent stocks
189
- Update Frequency: Daily market data
190
- Features Overview
191
- Basic Market Data (9 features)
192
- Date: Trading date timestamp
193
- Open, High, Low, Close: Standard OHLC price data
194
- Volume: Number of shares traded
195
- Dividends: Dividend payments on the date
196
- Stock Splits: Stock split information
197
- Ticker: Stock symbol identifier
198
- Technical Analysis Indicators (16 features)
199
- Moving Averages
200
- SMA_5, SMA_10, SMA_20, SMA_50: Simple Moving Averages for different periods
201
- EMA_12, EMA_26: Exponential Moving Averages
202
- Momentum Indicators
203
- MACD, MACD_Signal, MACD_Histogram: Moving Average Convergence Divergence indicators
204
- RSI: Relative Strength Index (14-period)
205
- Volatility Indicators
206
- BB_Middle, BB_Upper, BB_Lower: Bollinger Bands components
207
- BB_Width: Bollinger Bands width
208
- BB_Position: Price position within Bollinger Bands
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
- Basic Analysis
286
- python
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"Number of unique tickers: {df['Ticker'].nunique()}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
- # Check target distributions
 
 
 
 
 
 
293
  print(df['Future_Up_1d'].value_counts())
294
- Feature Selection for Modeling
295
- python
 
 
 
296
  # Technical indicators
297
- technical_features = ['SMA_5', 'SMA_10', 'RSI', 'MACD', 'BB_Position', 'Volatility']
 
 
 
298
 
299
  # Lagged features
300
  lag_features = [col for col in df.columns if 'lag' in col]
301
 
302
- # Targets
303
- targets = ['Future_Return_1d', 'Future_Up_1d', 'Future_Category_1d']
304
- Dataset Statistics
305
- Coverage: All S&P 500 constituent companies
306
- Temporal Span: 5 years of daily data
307
- Feature Density: 73 features per observation
308
- Target Variety: 12 different prediction targets
309
- Technical Indicators: 16 professional-grade technical analysis features
310
- Lag Depth: Up to 10-period historical context
311
- Limitations and Considerations
312
- Data Limitations
313
- Survivorship Bias: Only includes current S&P 500 constituents
314
- Market Hours: Only includes regular trading session data
315
- Corporate Actions: Historical adjustments may affect long-term patterns
316
- Usage Considerations
317
- Look-ahead Bias: Ensure proper train/test splits respecting temporal order
318
- Market Regime Changes: Model performance may vary across different market conditions
319
- Feature Correlation: Many technical indicators are derived from the same underlying price data
320
- Citation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- License
332
- This dataset is released under the MIT License. Please note that 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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
 
334
- Disclaimer
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
+ ![Dataset](https://img.shields.io/badge/Dataset-S%26P%20500-blue)
184
+ ![Records](https://img.shields.io/badge/Records-620K+-green)
185
+ ![Features](https://img.shields.io/badge/Features-73-orange)
186
+ ![License](https://img.shields.io/badge/License-MIT-yellow)
187
+ ![Time Period](https://img.shields.io/badge/Time%20Period-5%20Years-purple)
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>