File size: 3,454 Bytes
18d2991
 
 
 
ca5100d
56deeae
ca5100d
56deeae
ca5100d
56deeae
ca5100d
 
 
 
 
 
 
 
 
56deeae
ca5100d
 
 
 
 
56deeae
ca5100d
 
 
 
 
 
 
 
 
 
 
 
56deeae
 
ca5100d
56deeae
ca5100d
 
 
56deeae
 
ca5100d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18d2991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
tags:
- ml-intern
---
# 🏦 Crypto Predictive Model β€” ML Ensemble for Crypto Price Prediction

A production-grade machine learning pipeline for cryptocurrency price prediction using **15 years of Yahoo Finance historical data**, engineered for integration with high-frequency trading systems.

## πŸš€ Quick Start

```bash
pip install yfinance pandas numpy scikit-learn lightgbm ta torch pyarrow joblib
git clone https://huggingface.co/AcyLa/crypto-predictive-model
cd crypto-predictive-model
python train.py --ticker BTC-USD
python predict.py --ticker BTC-USD
```

## πŸ— Architecture

```
Data (yfinance) β†’ Features (207 indicators) β†’ Labels (multi-horizon) β†’ Ensemble (LightGBM+LSTM) β†’ Prediction API
                                                          ↑
                                          Walk-Forward Backtester (purged CV)
```

## πŸ“Š Components

| Component | Description |
|-----------|-------------|
| **Data** | Downloads up to 15 years of OHLCV from Yahoo Finance (BTC since 2014) |
| **Features** | 207 causal technical indicators: trend, momentum, volatility, volume, price structure, regime, calendar |
| **Labels** | Multi-horizon (1d, 3d, 7d, 14d, 30d) regression + classification + triple-barrier |
| **Models** | Ensemble of LightGBM (gradient boosting) + LSTM with attention pooling |
| **Backtest** | Walk-forward cross-validation with purging β€” no look-ahead bias |
| **Prediction** | Real-time multi-horizon signals with consensus voting |

## πŸ”§ HFT Integration

```python
from predict import CryptoPredictor

predictor = CryptoPredictor(ticker="BTC-USD")
result = predictor.get_multi_horizon(use_lstm=False)  # sub-ms for HFT
print(f"Consensus: {result['consensus']} ({result['consensus_confidence']:.0%})")
```

See `hft_integration.py` for a complete trading loop with stop-loss, take-profit, and position management.

| Mode | Latency | Use Case |
|------|---------|----------|
| LightGBM only | < 1ms | HFT, tick-level |
| LightGBM + LSTM (CPU) | ~6-50ms | Swing trading |

## πŸ“ Files

```
β”œβ”€β”€ config.py          # All hyperparameters
β”œβ”€β”€ data_loader.py     # Yahoo Finance download
β”œβ”€β”€ features.py        # 207 technical indicators
β”œβ”€β”€ labels.py          # Multi-horizon labels + triple-barrier
β”œβ”€β”€ models.py          # LightGBM + LSTM ensemble
β”œβ”€β”€ backtest.py        # Walk-forward backtesting engine
β”œβ”€β”€ train.py           # Main training pipeline
β”œβ”€β”€ predict.py         # Live prediction API + CLI
β”œβ”€β”€ hft_integration.py # HFT trading loop example
└── models/BTC-USD/    # Trained models
```

## ⚠️ Disclaimer

Research tool, not financial advice. Always backtest with transaction costs and never risk more than you can afford to lose.

<!-- ml-intern-provenance -->
## Generated by ML Intern

This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.

- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "AcyLa/crypto-predictive-model"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
```

For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.