cathyhy Adilbai commited on
Commit
2a89e27
ยท
0 Parent(s):

Duplicate from Adilbai/stock-dataset

Browse files

Co-authored-by: Baidalin Adilzhan <Adilbai@users.noreply.huggingface.co>

Files changed (3) hide show
  1. .gitattributes +59 -0
  2. README.md +395 -0
  3. data/train-00000-of-00001.parquet +3 -0
.gitattributes ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mds filter=lfs diff=lfs merge=lfs -text
13
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
14
+ *.model filter=lfs diff=lfs merge=lfs -text
15
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
16
+ *.npy filter=lfs diff=lfs merge=lfs -text
17
+ *.npz filter=lfs diff=lfs merge=lfs -text
18
+ *.onnx filter=lfs diff=lfs merge=lfs -text
19
+ *.ot filter=lfs diff=lfs merge=lfs -text
20
+ *.parquet filter=lfs diff=lfs merge=lfs -text
21
+ *.pb filter=lfs diff=lfs merge=lfs -text
22
+ *.pickle filter=lfs diff=lfs merge=lfs -text
23
+ *.pkl filter=lfs diff=lfs merge=lfs -text
24
+ *.pt filter=lfs diff=lfs merge=lfs -text
25
+ *.pth filter=lfs diff=lfs merge=lfs -text
26
+ *.rar filter=lfs diff=lfs merge=lfs -text
27
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
28
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar filter=lfs diff=lfs merge=lfs -text
31
+ *.tflite filter=lfs diff=lfs merge=lfs -text
32
+ *.tgz filter=lfs diff=lfs merge=lfs -text
33
+ *.wasm filter=lfs diff=lfs merge=lfs -text
34
+ *.xz filter=lfs diff=lfs merge=lfs -text
35
+ *.zip filter=lfs diff=lfs merge=lfs -text
36
+ *.zst filter=lfs diff=lfs merge=lfs -text
37
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
38
+ # Audio files - uncompressed
39
+ *.pcm filter=lfs diff=lfs merge=lfs -text
40
+ *.sam filter=lfs diff=lfs merge=lfs -text
41
+ *.raw filter=lfs diff=lfs merge=lfs -text
42
+ # Audio files - compressed
43
+ *.aac filter=lfs diff=lfs merge=lfs -text
44
+ *.flac filter=lfs diff=lfs merge=lfs -text
45
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
46
+ *.ogg filter=lfs diff=lfs merge=lfs -text
47
+ *.wav filter=lfs diff=lfs merge=lfs -text
48
+ # Image files - uncompressed
49
+ *.bmp filter=lfs diff=lfs merge=lfs -text
50
+ *.gif filter=lfs diff=lfs merge=lfs -text
51
+ *.png filter=lfs diff=lfs merge=lfs -text
52
+ *.tiff filter=lfs diff=lfs merge=lfs -text
53
+ # Image files - compressed
54
+ *.jpg filter=lfs diff=lfs merge=lfs -text
55
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
56
+ *.webp filter=lfs diff=lfs merge=lfs -text
57
+ # Video files - compressed
58
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
59
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_info:
3
+ features:
4
+ - name: Date
5
+ dtype: string
6
+ - name: Open
7
+ dtype: float64
8
+ - name: High
9
+ dtype: float64
10
+ - name: Low
11
+ dtype: float64
12
+ - name: Close
13
+ dtype: float64
14
+ - name: Volume
15
+ dtype: int64
16
+ - name: Dividends
17
+ dtype: float64
18
+ - name: Stock Splits
19
+ dtype: float64
20
+ - name: Ticker
21
+ dtype: string
22
+ - name: SMA_5
23
+ dtype: float64
24
+ - name: SMA_10
25
+ dtype: float64
26
+ - name: SMA_20
27
+ dtype: float64
28
+ - name: SMA_50
29
+ dtype: float64
30
+ - name: EMA_12
31
+ dtype: float64
32
+ - name: EMA_26
33
+ dtype: float64
34
+ - name: MACD
35
+ dtype: float64
36
+ - name: MACD_Signal
37
+ dtype: float64
38
+ - name: MACD_Histogram
39
+ dtype: float64
40
+ - name: RSI
41
+ dtype: float64
42
+ - name: BB_Middle
43
+ dtype: float64
44
+ - name: BB_Upper
45
+ dtype: float64
46
+ - name: BB_Lower
47
+ dtype: float64
48
+ - name: BB_Width
49
+ dtype: float64
50
+ - name: BB_Position
51
+ dtype: float64
52
+ - name: Volatility
53
+ dtype: float64
54
+ - name: Price_Change
55
+ dtype: float64
56
+ - name: Price_Change_5d
57
+ dtype: float64
58
+ - name: High_Low_Ratio
59
+ dtype: float64
60
+ - name: Open_Close_Ratio
61
+ dtype: float64
62
+ - name: Volume_SMA
63
+ dtype: float64
64
+ - name: Volume_Ratio
65
+ dtype: float64
66
+ - name: Close_lag_1
67
+ dtype: float64
68
+ - name: Close_lag_2
69
+ dtype: float64
70
+ - name: Close_lag_3
71
+ dtype: float64
72
+ - name: Close_lag_5
73
+ dtype: float64
74
+ - name: Close_lag_10
75
+ dtype: float64
76
+ - name: Volume_lag_1
77
+ dtype: float64
78
+ - name: Volume_lag_2
79
+ dtype: float64
80
+ - name: Volume_lag_3
81
+ dtype: float64
82
+ - name: Volume_lag_5
83
+ dtype: float64
84
+ - name: Volume_lag_10
85
+ dtype: float64
86
+ - name: Price_Change_lag_1
87
+ dtype: float64
88
+ - name: Price_Change_lag_2
89
+ dtype: float64
90
+ - name: Price_Change_lag_3
91
+ dtype: float64
92
+ - name: Price_Change_lag_5
93
+ dtype: float64
94
+ - name: Price_Change_lag_10
95
+ dtype: float64
96
+ - name: RSI_lag_1
97
+ dtype: float64
98
+ - name: RSI_lag_2
99
+ dtype: float64
100
+ - name: RSI_lag_3
101
+ dtype: float64
102
+ - name: RSI_lag_5
103
+ dtype: float64
104
+ - name: RSI_lag_10
105
+ dtype: float64
106
+ - name: MACD_lag_1
107
+ dtype: float64
108
+ - name: MACD_lag_2
109
+ dtype: float64
110
+ - name: MACD_lag_3
111
+ dtype: float64
112
+ - name: MACD_lag_5
113
+ dtype: float64
114
+ - name: MACD_lag_10
115
+ dtype: float64
116
+ - name: Volatility_lag_1
117
+ dtype: float64
118
+ - name: Volatility_lag_2
119
+ dtype: float64
120
+ - name: Volatility_lag_3
121
+ dtype: float64
122
+ - name: Volatility_lag_5
123
+ dtype: float64
124
+ - name: Volatility_lag_10
125
+ dtype: float64
126
+ - name: Future_Return_1d
127
+ dtype: float64
128
+ - name: Future_Up_1d
129
+ dtype: int64
130
+ - name: Future_Category_1d
131
+ dtype: float64
132
+ - name: Future_Return_5d
133
+ dtype: float64
134
+ - name: Future_Up_5d
135
+ dtype: int64
136
+ - name: Future_Category_5d
137
+ dtype: float64
138
+ - name: Future_Return_10d
139
+ dtype: float64
140
+ - name: Future_Up_10d
141
+ dtype: int64
142
+ - name: Future_Category_10d
143
+ dtype: float64
144
+ - name: Future_Return_20d
145
+ dtype: float64
146
+ - name: Future_Up_20d
147
+ dtype: int64
148
+ - name: Future_Category_20d
149
+ dtype: float64
150
+ splits:
151
+ - name: train
152
+ num_bytes: 374644429
153
+ num_examples: 620095
154
+ download_size: 335534650
155
+ dataset_size: 374644429
156
+ configs:
157
+ - config_name: default
158
+ data_files:
159
+ - split: train
160
+ path: data/train-*
161
+ license: mit
162
+ task_categories:
163
+ - time-series-forecasting
164
+ - reinforcement-learning
165
+ - tabular-regression
166
+ language:
167
+ - en
168
+ tags:
169
+ - finance
170
+ - time-series
171
+ - stocks
172
+ - technical-analysis
173
+ - yahoo-finance
174
+ - reinforcement-learning
175
+ 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
+ <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},
373
+ year={2024},
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>
data/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f480d8e99e1366a44d1a5045d592aa718893e7482cdd4cacc05bcbc86a90644
3
+ size 335534650