Skip to content

Champollion - Architecture Overview

Version: 1.5.0 (Sprint 9) Date: Janvier 2026 Status: Production Ready


Table des Matières

  1. Vue d'Ensemble
  2. Stack Technologique
  3. Architecture Globale
  4. Pipeline de Données
  5. Système de Cache
  6. Feature Store (Feast)
  7. Training Pipeline
  8. Inference Pipeline
  9. Orchestration
  10. Structure du Code

1. Vue d'Ensemble

Champollion est un système ML de trading crypto production-ready avec : - Pipeline ETL automatisé pour données de marché - Architecture cache hiérarchique 6 niveaux - Multi-modèle ensemble (XGBoost, LightGBM, CatBoost) - Feature Store Feast pour serving temps réel - Orchestration Apache Airflow

Objectif

Générer des signaux de trading crypto via ML avec : - Gate Model : Décide si une action est opportune (Action vs Neutral) - Direction Model : Prédit la direction (Up vs Down)

Métriques Actuelles

Modèle Algorithme F1-Score
Gate XGBoost 75.8%
Direction LightGBM En développement

2. Stack Technologique

Core ML

Composant Version Usage
Python 3.11 Runtime
XGBoost 3.1.2 Modèle principal
LightGBM 4.6.0 Modèle secondaire
CatBoost 1.2.8 Modèle tertiaire
Optuna 4.6.0 HPO
SHAP - Explainability

MLOps

Composant Version Usage
MLflow 3.3.2 Experiment tracking
Feast 0.58.0 Feature Store
Airflow 3.0.4 Orchestration

Infrastructure

Composant Usage
PostgreSQL MLflow backend + Feast registry
Redis Online feature store
S3 Artifact storage
Docker Containerisation

Data

Composant Usage
pandas Data manipulation
pyarrow Parquet I/O
CCXT Exchange API

3. Architecture Globale

┌─────────────────────────────────────────────────────────────────────┐
│                         ORCHESTRATION (Airflow)                      │
└─────────────────────────────────────────────────────────────────────┘
        ┌───────────────────────────┼───────────────────────────┐
        ▼                           ▼                           ▼
┌───────────────┐           ┌───────────────┐           ┌───────────────┐
│   ETL Pipeline │           │ Training      │           │   Inference   │
│   - Extract    │           │ - HPO         │           │   - Online    │
│   - Enrich     │           │ - Train       │           │   - Batch     │
│   - Label      │           │ - Evaluate    │           │               │
└───────────────┘           └───────────────┘           └───────────────┘
        │                           │                           │
        ▼                           ▼                           ▼
┌─────────────────────────────────────────────────────────────────────┐
│                     CACHE LAYER (6 niveaux)                          │
│  L1:FeatureStore → L2:Labels → L3:FE → L4:Selection → L5:HPO → L6:Model │
└─────────────────────────────────────────────────────────────────────┘
        │                           │                           │
        ▼                           ▼                           ▼
┌───────────────┐           ┌───────────────┐           ┌───────────────┐
│   Feast       │           │   MLflow      │           │   Redis       │
│   (Offline)   │           │   (Registry)  │           │   (Online)    │
└───────────────┘           └───────────────┘           └───────────────┘
        │                           │                           │
        └───────────────────────────┴───────────────────────────┘
                            ┌───────────────┐
                            │  PostgreSQL   │
                            │  + S3         │
                            └───────────────┘

4. Pipeline de Données

4.1 ETL Pipeline

Binance/Kraken API
┌───────────────────┐
│  1. EXTRACT       │  cvntrade_etl_pipeline.py
│  - OHLCV data     │
│  - 36 mois hist.  │
└───────────────────┘
┌───────────────────┐
│  2. ENRICH        │  cvntrade_enrich.py
│  - 250+ features  │
│  - Indicateurs    │
│  - Patterns       │
└───────────────────┘
┌───────────────────┐
│  3. LABEL         │  cvntrade_label.py
│  - Triple barrier │
│  - Stratégies     │
└───────────────────┘
┌───────────────────┐
│  4. EXPORT        │  cvntrade_feast_exporter.py
│  - Parquet files  │
│  - Feast ingest   │
└───────────────────┘

4.2 Features Générées

Catégorie Exemples Count
Momentum RSI, MACD, Stochastic, MFI ~15
Volatility Bollinger, ATR, price_volatility ~15
Trend ADX, SMA, market_regime ~10
Volume volume_ratio, Volume_Delta ~10
Gating opportunity_score, breach signals ~20
Direction divergence, confluence, order_flow ~15
Temporal hour_sin/cos, day_sin/cos 4
Candlestick sentiment_score, pressure ~10
External fear_and_greed 1

Total : 250+ features brutes → 140-150 après sélection


5. Système de Cache

5.1 Architecture 6 Niveaux

Level 6: Trained Model     ← Modèle final + métriques
Level 5: HPO Parameters    ← Hyperparamètres optimisés
Level 4: Feature Selection ← Features sélectionnées (top 150)
Level 3: Feature Engineer. ← Pass-through (FE dans L6)
Level 2: Labels            ← Étiquettes triple-barrier
Level 1: Feature Store     ← Données brutes + indicateurs

5.2 Pattern Cache-or-Generate

def get_entity(level, criteria):
    # 1. Check cache
    cached = cache.get(level, criteria)
    if cached.valid:
        return cached.data

    # 2. Get dependencies (cascade)
    deps = get_entity(level - 1, criteria)

    # 3. Generate
    result = generate(deps)

    # 4. Store
    cache.store(level, criteria, result)

    return result

5.3 Contrôle via Variables d'Environnement

Variables de Training (Configuration Pipeline)

# Paramètres de training principaux
CVN_CRYPTO_SYMBOL=BTCUSDT     # Symbole crypto
CVN_TIMEFRAME=15m             # Timeframe (1m, 5m, 15m, 30m, 1h, 4h)
CVN_STRATEGY=SL0.5_TP0.5_H1.5 # Stratégie (SL{x}_TP{y}_H{z})
CVN_MODEL_TYPE=xgboost        # Modèle (xgboost, lightgbm, catboost)
CVN_HISTORY_MONTHS=36         # Profondeur historique en mois
CVN_INFER_WIN=6               # Fenêtre d'inférence en HEURES
CVN_GATE_ACTION_RATE=0.15     # Taux d'action max (15%)

Variables de Cache (Force Flags)

FORCE_FEATURE_STORE=0      # Force reload données brutes
FORCE_LABELS=0             # Force recalcul labels
FORCE_FEATURE_ENGINEERING=0
FORCE_FEATURE_SELECTION=0
FORCE_HPO=0                # Force HPO
FORCE_RETRAIN=0            # Force réentraînement

CACHE_STRATEGY=flexible    # exact|flexible|best_available
CACHE_TTL_DAYS=7

Variables Feast (Feature Store Phase 2)

CACHE_USE_FEAST_L1=1              # Feast comme source primaire L1
CACHE_FEAST_AUTO_MATERIALIZE=1    # Matérialisation auto vers Redis
FEAST_REPO_PATH=feature_repo
FEAST_REGISTRY_PATH=postgresql+psycopg2://mlflow:mlflow@localhost:5432/champollion
FEAST_CACHE_TTL_SECONDS=60

6. Feature Store (Feast)

6.1 Configuration

# feature_repo/feature_store.yaml
project: champollion
provider: local

registry:
  registry_type: sql
  path: postgresql+psycopg2://mlflow:mlflow@localhost:5432/champollion

offline_store:
  type: dask

online_store:
  type: redis
  connection_string: localhost:6379

6.2 Feature Views

Feature View Features TTL Usage
raw_ohlcv 5 7d OHLCV brut
momentum_indicators 11 7d RSI, MACD, etc.
volatility_indicators 11 7d BB, ATR
trend_regime 9 7d ADX, SMA
volume_indicators 7 7d Volume ratios
gating_features 14 7d Gate model
direction_features 10 7d Direction model
temporal_features 4 7d Cyclical
external_features 1 1d Fear & Greed
candlestick_features 4 7d Patterns

6.3 Usage

# Export depuis ETL
from ETL.cvntrade_feast_exporter import export_from_etl_pipeline
export_from_etl_pipeline("BTCUSDT", materialize=True)

# Inference temps réel
from inference.cvntrade_feast_inference import get_inference_pipeline
pipeline = get_inference_pipeline()
result = pipeline.predict("BTCUSDT", model_type="gate")

7. Training Pipeline

7.1 Flux

┌─────────────────┐
│ Orchestrator    │  cvntrade_autonomous_orchestrator.py
└────────┬────────┘
    ┌────┴────┐
    ▼         ▼
┌───────┐ ┌───────┐
│XGBoost│ │LightGB│ │CatBoost│  Trainers autonomes
└───┬───┘ └───┬───┘ └───┬────┘
    │         │         │
    ▼         ▼         ▼
┌─────────────────────────────┐
│   Feature Selection         │  Smart selector
│   (top 150 features)        │
└─────────────────────────────┘
┌─────────────────────────────┐
│   HPO (Optuna)              │  Optimisation
│   - 100 trials              │
│   - Cross-validation        │
└─────────────────────────────┘
┌─────────────────────────────┐
│   Training                  │
│   - FE pipeline intégré     │
│   - Calibration             │
└─────────────────────────────┘
┌─────────────────────────────┐
│   MLflow                    │
│   - Log metrics             │
│   - Register model          │
│   - Store artifacts (S3)    │
└─────────────────────────────┘

7.2 Trainers Autonomes

Chaque trainer implémente : - Validation des dépendances cache - Feature selection consistante - HPO intégré - Calibration de probabilités - Logging MLflow automatique


8. Inference Pipeline

8.1 Online Inference

# Via Feast (recommandé)
from inference.cvntrade_feast_inference import CVNTrade_FeastInference

inference = CVNTrade_FeastInference()
result = inference.predict("BTCUSDT", model_type="gate")
# {
#   "symbol": "BTCUSDT",
#   "prediction": 1,
#   "probability": 0.82,
#   "latency_ms": 12.5
# }

8.2 Batch Inference

results = inference.predict_batch(
    symbols=["BTCUSDT", "ETHUSDT", "SOLUSDT"],
    model_type="gate"
)

9. Orchestration

9.1 DAGs Airflow

DAG Schedule Description
dag_etl_pipeline @hourly ETL + enrichissement
dag_training_inference @daily Training + inference

9.2 Docker Compose

cd airflow_docker
docker-compose up -d

Services : webserver, scheduler, worker, postgres, redis


10. Structure du Code

champollion/
├── src/
│   ├── commun/                    # Infrastructure partagée
│   │   ├── cache/                 # Système cache 6 niveaux
│   │   │   ├── cvntrade_cache_interface.py
│   │   │   ├── cvntrade_cache_manager.py
│   │   │   └── components/        # Composants autonomes
│   │   ├── mlflow/                # MLflow manager
│   │   ├── logs/                  # Logging
│   │   └── s3/                    # S3 storage
│   │
│   ├── ETL/                       # Pipeline ETL
│   │   ├── cvntrade_etl_pipeline.py
│   │   ├── cvntrade_enrich.py
│   │   ├── cvntrade_label.py
│   │   └── cvntrade_feast_exporter.py
│   │
│   ├── dataprep/                  # Feature Engineering
│   │   ├── cvntrade_multimodel_fe_pipeline.py
│   │   └── FE_composants/         # 13 composants FE
│   │
│   ├── training/                  # Training pipelines
│   │   ├── cvntrade_autonomous_orchestrator.py
│   │   ├── XGBoost/
│   │   ├── LightGBM/
│   │   └── CatBoost/
│   │
│   └── inference/                 # Inference
│       └── cvntrade_feast_inference.py
├── feature_repo/                  # Feast definitions
│   ├── feature_store.yaml
│   ├── entities.py
│   └── features.py
├── dags/                          # Airflow DAGs
├── tests/                         # Tests (34 fichiers)
├── notebooks/                     # Analyse (12 notebooks)
├── config/                        # Configuration
└── documentation/                 # Cette documentation


11. Backtesting (Roadmap)

11.1 Architecture Prévue

┌─────────────────────────────────────────────────────────────────┐
│                    CHAMPOLLION BACKTEST ENGINE                  │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  ┌──────────────┐    ┌──────────────┐    ┌──────────────┐      │
│  │   MLflow     │───▶│   Model      │───▶│   Signal     │      │
│  │   Registry   │    │   Loader     │    │   Generator  │      │
│  └──────────────┘    └──────────────┘    └──────────────┘      │
│                                                 │               │
│                                                 ▼               │
│  ┌──────────────┐    ┌──────────────┐    ┌──────────────┐      │
│  │   Feast      │───▶│   Feature    │───▶│   VectorBT   │      │
│  │   Store      │    │   Pipeline   │    │   Engine     │      │
│  └──────────────┘    └──────────────┘    └──────────────┘      │
│                                                 │               │
│                                                 ▼               │
│                                          ┌──────────────┐      │
│                                          │  QuantStats  │      │
│                                          │   Reports    │      │
│                                          └──────────────┘      │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

11.2 Stack Technologique

Bibliothèque Usage Phase
VectorBT Backtesting vectorisé Phase 1 (MVP)
QuantStats Rapports performance Phase 1
PyPortfolioOpt Optimisation portefeuille Phase 2
DEAP Algorithmes génétiques Phase 3

11.3 Roadmap

Phase Description Fonctionnalités
Phase 1 MVP Single Asset VectorBT, QuantStats, métriques de base
Phase 2 Multi-Crypto (15+) Portefeuille, corrélation, rebalancing
Phase 3 Genetic Optimization DEAP, walk-forward, Monte Carlo
Phase 4 Production API REST, dashboard, paper trading

11.4 Prévention Fuite de Données

Source Risque Solution
Look-ahead bias Features utilisant valeurs futures Vérifier shift(1) minimum
Fit sur données futures Scaler/Imputer fitted sur tout Fit uniquement sur train
Target leakage Corrélation target-feature Exclure prix de la période label
Temporal overlap Fenêtres chevauchantes Gap = horizon (H) candles

Références


Dernière mise à jour : 16 janvier 2026