| # SAC Crypto Trading Agent |
|
|
| Agent de trading crypto basé sur **SAC (Soft Actor-Critic)** entraîné avec Stable Baselines 3. |
|
|
| ## Architecture |
|
|
| - **Algo** : SAC (off-policy, maximum entropy actor-critic) |
| - **Env** : Gymnasium personnalisé sur données OHLCV (BTC-USD) |
| - **Observation** : fenêtre 30j de prix OHLCV normalisés + position + P&L |
| - **Action** : continue [-1, 1] → poids du portefeuille (short ↔ long) |
| - **Reward** : log-return du portefeuille + penalty overtrading + bonus holding |
|
|
| ## Hyperparamètres SAC |
|
|
| | Paramètre | Valeur | |
| |-----------|--------| |
| | learning_rate | 3e-4 | |
| | buffer_size | 200000 | |
| | batch_size | 256 | |
| | tau | 0.005 | |
| | gamma | 0.99 | |
| | ent_coef | auto | |
| | use_sde | True | |
| |
| ## Fichiers |
| |
| - `model_v2.zip` : modèle SAC entraîné |
| - `vecnorm_v2.pkl` : normalisation VecNormalize |
|
|
| ## Utilisation |
|
|
| ```python |
| from stable_baselines3 import SAC |
| from stable_baselines3.common.vec_env import DummyVecEnv, VecNormalize |
| from crypto_trading_env import CryptoTradingEnv |
| import pandas as pd |
| |
| # Charger données |
| df = pd.read_csv("btc_usd.csv") # open,high,low,close,volume |
| env = DummyVecEnv([lambda: CryptoTradingEnv(df)]) |
| env = VecNormalize.load("vecnorm_v2.pkl", env) |
| |
| model = SAC.load("model_v2.zip", env=env) |
| obs = env.reset() |
| action, _ = model.predict(obs, deterministic=True) |
| ``` |
|
|
| ## Avertissement |
|
|
| Ceci est un projet de recherche. Les performances passées ne garantissent pas les résultats futurs. Ne pas utiliser en production sans backtesting rigoureux. |
|
|