⚡ ULTRON: Sync config.py
Browse files
config.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
⚡ ULTRON Systems // OHLCV Transformer Configuration Matrix
|
| 3 |
+
Central configuration for data streaming, feature extraction, model architecture, and Colab GPU training.
|
| 4 |
+
"""
|
| 5 |
+
from dataclasses import dataclass, field
|
| 6 |
+
from typing import List, Optional
|
| 7 |
+
import os
|
| 8 |
+
import torch
|
| 9 |
+
|
| 10 |
+
@dataclass
|
| 11 |
+
class DatasetConfig:
|
| 12 |
+
repo_id: str = "mito0o852/OHLCV-1m"
|
| 13 |
+
# Choose date ranges to process. Each file is data/ohlcv_YYYY-MM.parquet
|
| 14 |
+
start_year: int = 2020
|
| 15 |
+
end_year: int = 2025
|
| 16 |
+
|
| 17 |
+
# Target top liquid tickers to maximize signal and limit noise (leave empty for all tickers)
|
| 18 |
+
# Default liquid basket: Mega-cap tech, ETFs, high volume liquid equities
|
| 19 |
+
liquid_tickers: List[str] = field(default_factory=lambda: [
|
| 20 |
+
"AAPL", "MSFT", "NVDA", "AMZN", "GOOGL", "META", "TSLA",
|
| 21 |
+
"SPY", "QQQ", "IWM", "AMD", "NFLX", "INTC", "JPM", "BAC"
|
| 22 |
+
])
|
| 23 |
+
|
| 24 |
+
# Sequence length in minutes (e.g., 512 minutes ~ 8.5 trading hours)
|
| 25 |
+
seq_len: int = 512
|
| 26 |
+
|
| 27 |
+
# Overlapping window stride for dataset generation (e.g. step by 16 minutes)
|
| 28 |
+
window_stride: int = 16
|
| 29 |
+
|
| 30 |
+
# Future prediction horizons in minutes: [1m, 3m, 5m, 10m, 15m]
|
| 31 |
+
pred_horizons: List[int] = field(default_factory=lambda: [1, 3, 5, 10, 15])
|
| 32 |
+
|
| 33 |
+
# Local ephemeral storage path for downloading 1 parquet file at a time
|
| 34 |
+
cache_dir: str = "/tmp/ohlcv_cache"
|
| 35 |
+
|
| 36 |
+
@dataclass
|
| 37 |
+
class ModelConfig:
|
| 38 |
+
in_features: int = 8 # Number of stationary features generated per bar
|
| 39 |
+
d_model: int = 128 # Transformer latent dimension
|
| 40 |
+
n_heads: int = 4 # Multi-head attention heads
|
| 41 |
+
n_layers: int = 4 # Number of Conformer/Transformer layers
|
| 42 |
+
d_ff: int = 256 # Feed-forward expansion dimension
|
| 43 |
+
conv_kernels: List[int] = field(default_factory=lambda: [3, 7, 15, 31]) # Multi-scale conv kernels
|
| 44 |
+
patch_stride: int = 4 # Stride of overlapping 1D conv tokenizer
|
| 45 |
+
conv_depthwise_kernel: int = 7 # Conformer depthwise conv kernel
|
| 46 |
+
dropout: float = 0.1
|
| 47 |
+
use_revin: bool = True # Reversible Instance Normalization
|
| 48 |
+
num_horizons: int = 5 # Matching len(DatasetConfig.pred_horizons)
|
| 49 |
+
|
| 50 |
+
@dataclass
|
| 51 |
+
class TrainingConfig:
|
| 52 |
+
batch_size: int = 64 # Physical batch size on GPU
|
| 53 |
+
grad_accum_steps: int = 4 # Effective batch size = 64 * 4 = 256
|
| 54 |
+
learning_rate: float = 3e-4
|
| 55 |
+
min_lr: float = 1e-6
|
| 56 |
+
weight_decay: float = 1e-2
|
| 57 |
+
warmup_steps: int = 300
|
| 58 |
+
max_steps_per_shard: int = 250 # Steps per monthly shard to ensure rapid progression
|
| 59 |
+
max_epochs: int = 5
|
| 60 |
+
fp16: bool = True # Mixed precision (FP16/BF16)
|
| 61 |
+
|
| 62 |
+
# Checkpoint settings
|
| 63 |
+
save_every_steps: int = 200
|
| 64 |
+
checkpoint_dir: str = "/content/drive/MyDrive/ohlcv_checkpoints"
|
| 65 |
+
local_checkpoint_dir: str = "./checkpoints"
|
| 66 |
+
|
| 67 |
+
# Telemetry
|
| 68 |
+
log_interval: int = 25
|
| 69 |
+
device: str = "cuda" if torch.cuda.is_available() else "cpu"
|