quantfinance 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. quantfinance-0.1.0/LICENSE +21 -0
  2. quantfinance-0.1.0/PKG-INFO +303 -0
  3. quantfinance-0.1.0/README.md +243 -0
  4. quantfinance-0.1.0/pyproject.toml +236 -0
  5. quantfinance-0.1.0/quantfinance/__init__.py +94 -0
  6. quantfinance-0.1.0/quantfinance/portfolio/__init__.py +14 -0
  7. quantfinance-0.1.0/quantfinance/portfolio/allocation.py +253 -0
  8. quantfinance-0.1.0/quantfinance/portfolio/backtesting.py +332 -0
  9. quantfinance-0.1.0/quantfinance/portfolio/optimization.py +482 -0
  10. quantfinance-0.1.0/quantfinance/portfolio/rebalancing.py +217 -0
  11. quantfinance-0.1.0/quantfinance/pricing/__init__.py +0 -0
  12. quantfinance-0.1.0/quantfinance/pricing/bonds.py +784 -0
  13. quantfinance-0.1.0/quantfinance/pricing/options.py +674 -0
  14. quantfinance-0.1.0/quantfinance/risk/__init__.py +19 -0
  15. quantfinance-0.1.0/quantfinance/risk/metrics.py +812 -0
  16. quantfinance-0.1.0/quantfinance/risk/var.py +533 -0
  17. quantfinance-0.1.0/quantfinance/utils/__init__.py +49 -0
  18. quantfinance-0.1.0/quantfinance/utils/data.py +683 -0
  19. quantfinance-0.1.0/quantfinance/utils/helpers.py +137 -0
  20. quantfinance-0.1.0/quantfinance/utils/plotting.py +640 -0
  21. quantfinance-0.1.0/quantfinance.egg-info/PKG-INFO +303 -0
  22. quantfinance-0.1.0/quantfinance.egg-info/SOURCES.txt +45 -0
  23. quantfinance-0.1.0/quantfinance.egg-info/dependency_links.txt +1 -0
  24. quantfinance-0.1.0/quantfinance.egg-info/entry_points.txt +2 -0
  25. quantfinance-0.1.0/quantfinance.egg-info/requires.txt +37 -0
  26. quantfinance-0.1.0/quantfinance.egg-info/top_level.txt +1 -0
  27. quantfinance-0.1.0/setup.cfg +4 -0
  28. quantfinance-0.1.0/tests/test_portfolio.py +237 -0
  29. quantfinance-0.1.0/tests/test_pricing.py +445 -0
  30. quantfinance-0.1.0/tests/test_risk.py +310 -0
  31. quantfinance-0.1.0/tests/test_utils.py +190 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Marcel ALOEKPO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,303 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantfinance
3
+ Version: 0.1.0
4
+ Summary: Package Python complet pour la finance quantitative
5
+ Author-email: Marcel ALOEKPO <marcelaloekpo@gmail.com>
6
+ Maintainer-email: Marcel ALOEKPO <marcelaloekpo@gmail.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/votre-username/quantfinance
9
+ Project-URL: Documentation, https://quantfinance.readthedocs.io
10
+ Project-URL: Repository, https://github.com/votre-username/quantfinance
11
+ Project-URL: Bug Tracker, https://github.com/votre-username/quantfinance/issues
12
+ Project-URL: Changelog, https://github.com/votre-username/quantfinance/blob/main/CHANGELOG.md
13
+ Keywords: finance,quantitative finance,portfolio optimization,risk management,options pricing,derivatives,black-scholes,var,backtesting
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Topic :: Office/Business :: Financial :: Investment
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: numpy>=1.21.0
29
+ Requires-Dist: pandas>=1.3.0
30
+ Requires-Dist: scipy>=1.7.0
31
+ Requires-Dist: matplotlib>=3.4.0
32
+ Requires-Dist: seaborn>=0.11.0
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
36
+ Requires-Dist: pytest-xdist>=2.5.0; extra == "dev"
37
+ Requires-Dist: black>=22.0.0; extra == "dev"
38
+ Requires-Dist: flake8>=4.0.0; extra == "dev"
39
+ Requires-Dist: mypy>=0.950; extra == "dev"
40
+ Requires-Dist: pylint>=2.13.0; extra == "dev"
41
+ Requires-Dist: isort>=5.10.0; extra == "dev"
42
+ Requires-Dist: pre-commit>=2.17.0; extra == "dev"
43
+ Provides-Extra: docs
44
+ Requires-Dist: sphinx>=4.5.0; extra == "docs"
45
+ Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
46
+ Requires-Dist: sphinx-autodoc-typehints>=1.18.0; extra == "docs"
47
+ Requires-Dist: myst-parser>=0.17.0; extra == "docs"
48
+ Provides-Extra: data
49
+ Requires-Dist: yfinance>=0.2.0; extra == "data"
50
+ Requires-Dist: pandas-datareader>=0.10.0; extra == "data"
51
+ Provides-Extra: viz
52
+ Requires-Dist: plotly>=5.0.0; extra == "viz"
53
+ Requires-Dist: mplfinance>=0.12.0; extra == "viz"
54
+ Provides-Extra: ml
55
+ Requires-Dist: scikit-learn>=1.0.0; extra == "ml"
56
+ Requires-Dist: tensorflow>=2.8.0; extra == "ml"
57
+ Provides-Extra: all
58
+ Requires-Dist: quantfinance[data,dev,docs,ml,viz]; extra == "all"
59
+ Dynamic: license-file
60
+
61
+ # QuantFinance 📊
62
+
63
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
64
+ [![PyPI version](https://badge.fury.io/py/quantfinance.svg)](https://badge.fury.io/py/quantfinance)
65
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66
+ [![Build Status](https://github.com/Mafoya1er/quantfinance/workflows/CI/badge.svg)](https://github.com/Mafoya1er/quantfinance/actions)
67
+ [![codecov](https://codecov.io/gh/Mafoya1er/quantfinance/branch/main/graph/badge.svg)](https://codecov.io/gh/Mafoya1er/quantfinance)
68
+ [![Documentation Status](https://readthedocs.org/projects/quantfinance/badge/?version=latest)](https://quantfinance.readthedocs.io/en/latest/?badge=latest)
69
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
70
+
71
+ > Package Python professionnel pour la finance quantitative
72
+
73
+ [Documentation](https://quantfinance.readthedocs.io) | [PyPI](https://pypi.org/project/quantfinance/) | [GitHub](https://github.com/Mafoya1er/quantfinance)
74
+
75
+ ## ✨ Fonctionnalités
76
+
77
+ ### 📈 Pricing d'Instruments Financiers
78
+ - **Options** : Black-Scholes, Binomial Tree, Monte Carlo
79
+ - **Grecques** : Delta, Gamma, Vega, Theta, Rho
80
+ - **Volatilité Implicite** : Méthode de Newton-Raphson
81
+ - **Options Exotiques** : Asiatiques, Barrières
82
+ - **Obligations** : Pricing, YTM, Duration, Convexité
83
+
84
+ ### ⚠️ Gestion des Risques
85
+ - **Value at Risk (VaR)** : Historique, Paramétrique, EWMA, Monte Carlo
86
+ - **Expected Shortfall (CVaR)**
87
+ - **Métriques** : Sharpe, Sortino, Calmar, Omega, Information Ratio
88
+ - **Drawdown** : Maximum, Duration, Série temporelle
89
+ - **Stress Testing** : Scénarios, Analyse historique, Simulation
90
+
91
+ ### 📊 Optimisation de Portefeuille
92
+ - **Markowitz** : Variance minimale, Sharpe maximum, Frontière efficiente
93
+ - **Risk Parity** : Contribution égale au risque
94
+ - **Black-Litterman** : Intégration de vues d'investissement
95
+ - **Hierarchical Risk Parity (HRP)**
96
+ - **Maximum Diversification**
97
+ - **Rééquilibrage** : Périodique, Seuils, Bandes de tolérance
98
+
99
+ ### 🔄 Backtesting
100
+ - Framework de backtesting flexible
101
+ - Stratégies prédéfinies (MA Crossover, Momentum, etc.)
102
+ - Prise en compte des coûts de transaction
103
+ - Analyse de performance détaillée
104
+
105
+ ### 🛠️ Utilitaires
106
+ - Chargement de données (CSV, Yahoo Finance, API)
107
+ - Génération de données synthétiques
108
+ - Nettoyage et préparation de données
109
+ - Indicateurs techniques (SMA, EMA, RSI, MACD, Bollinger Bands)
110
+ - Visualisations avancées
111
+
112
+ ## 🚀 Installation
113
+
114
+ ### Via pip (recommandé)
115
+
116
+ ```bash
117
+ pip install quantfinance
118
+ ```
119
+
120
+ ### Depuis les sources
121
+
122
+ ```bash
123
+ git clone https://github.com/Mafoya1er/quantfinance.git
124
+ cd quantfinance
125
+ pip install -e .
126
+ ```
127
+
128
+ ### Avec dépendances optionnelles
129
+
130
+ ```bash
131
+ # Pour l'analyse de données
132
+ pip install quantfinance[data]
133
+
134
+ # Pour le développement
135
+ pip install quantfinance[dev]
136
+
137
+ # Tout installer
138
+ pip install quantfinance[all]
139
+ ```
140
+
141
+ ## 📚 Démarrage Rapide
142
+
143
+ ### Pricing d'Options
144
+
145
+ ```python
146
+ from quantfinance.pricing.options import BlackScholes
147
+
148
+ # Option call européenne
149
+ bs = BlackScholes(S=100, K=105, T=1, r=0.05, sigma=0.25, option_type='call')
150
+
151
+ print(f"Prix: {bs.price():.2f}")
152
+ print(f"Delta: {bs.delta():.4f}")
153
+ print(f"Gamma: {bs.gamma():.6f}")
154
+ print(f"Vega: {bs.vega():.4f}")
155
+
156
+ # Volatilité implicite
157
+ market_price = 8.50
158
+ implied_vol = bs.implied_volatility(market_price)
159
+ print(f"Vol implicite: {implied_vol:.2%}")
160
+ ```
161
+
162
+ ### Optimisation de Portefeuille
163
+
164
+ ```python
165
+ from quantfinance.portfolio.optimization import PortfolioOptimizer, EfficientFrontier
166
+ from quantfinance.utils.data import DataLoader
167
+
168
+ # Charger des données
169
+ prices = DataLoader.generate_synthetic_prices(n_assets=5, n_days=252*3)
170
+ returns = prices.pct_change().dropna()
171
+
172
+ # Optimiser
173
+ optimizer = PortfolioOptimizer(returns, risk_free_rate=0.02)
174
+
175
+ # Sharpe maximum
176
+ max_sharpe = optimizer.maximize_sharpe()
177
+ print(f"Rendement: {max_sharpe['return']:.2%}")
178
+ print(f"Sharpe: {max_sharpe['sharpe_ratio']:.3f}")
179
+ print("\nPoids:")
180
+ print(max_sharpe['weights'])
181
+
182
+ # Frontière efficiente
183
+ frontier = EfficientFrontier(optimizer)
184
+ frontier.plot_frontier()
185
+ ```
186
+
187
+ ### Analyse de Risque
188
+
189
+ ```python
190
+ from quantfinance.risk.var import VaRCalculator
191
+ from quantfinance.risk.metrics import RiskMetrics, PerformanceAnalyzer
192
+
193
+ # VaR et CVaR
194
+ var_95 = VaRCalculator.historical_var(returns.iloc[:, 0], 0.95)
195
+ es_95 = VaRCalculator.expected_shortfall(returns.iloc[:, 0], 0.95)
196
+
197
+ print(f"VaR 95%: {var_95:.2%}")
198
+ print(f"CVaR 95%: {es_95:.2%}")
199
+
200
+ # Analyse complète
201
+ analyzer = PerformanceAnalyzer(returns.iloc[:, 0], risk_free_rate=0.02)
202
+ summary = analyzer.summary_statistics()
203
+ print(summary)
204
+ ```
205
+
206
+ ### Backtesting
207
+
208
+ ```python
209
+ from quantfinance.portfolio.backtesting import Backtester, MovingAverageCrossover
210
+ from quantfinance.utils.data import DataLoader
211
+
212
+ # Données OHLCV
213
+ data = DataLoader.generate_ohlcv_data(n_days=500)
214
+
215
+ # Stratégie
216
+ strategy = MovingAverageCrossover(short_window=20, long_window=50)
217
+
218
+ # Backtest
219
+ backtester = Backtester(data, strategy, initial_capital=100000)
220
+ results = backtester.run()
221
+
222
+ print(f"Rendement: {results['Total Return']:.2%}")
223
+ print(f"Sharpe: {results['Sharpe Ratio']:.3f}")
224
+ print(f"Max DD: {results['Max Drawdown']:.2%}")
225
+
226
+ # Visualisation
227
+ backtester.plot()
228
+ ```
229
+
230
+ ## 📖 Documentation
231
+
232
+ Documentation complète disponible sur [ReadTheDocs](https://quantfinance.readthedocs.io).
233
+
234
+ ### Guides
235
+
236
+ - [Installation](https://quantfinance.readthedocs.io/en/latest/user_guide/installation.html)
237
+ - [Démarrage Rapide](https://quantfinance.readthedocs.io/en/latest/user_guide/quickstart.html)
238
+ - [Tutoriels](https://quantfinance.readthedocs.io/en/latest/user_guide/tutorials.html)
239
+ - [Exemples](https://quantfinance.readthedocs.io/en/latest/user_guide/examples.html)
240
+
241
+ ### Référence API
242
+
243
+ - [Pricing](https://quantfinance.readthedocs.io/en/latest/api/pricing.html)
244
+ - [Risk](https://quantfinance.readthedocs.io/en/latest/api/risk.html)
245
+ - [Portfolio](https://quantfinance.readthedocs.io/en/latest/api/portfolio.html)
246
+ - [Utils](https://quantfinance.readthedocs.io/en/latest/api/utils.html)
247
+
248
+ ## 🧪 Tests
249
+
250
+ ```bash
251
+ # Lancer tous les tests
252
+ pytest
253
+
254
+ # Avec couverture
255
+ pytest --cov=quantfinance --cov-report=html
256
+
257
+ # Tests rapides seulement
258
+ pytest -m "not slow"
259
+ ```
260
+
261
+ ## 🤝 Contribution
262
+
263
+ Les contributions sont les bienvenues ! Consultez [CONTRIBUTING.md](CONTRIBUTING.md).
264
+
265
+ 1. Fork le projet
266
+ 2. Créez une branche (`git checkout -b feature/AmazingFeature`)
267
+ 3. Committez (`git commit -m 'feat: Add AmazingFeature'`)
268
+ 4. Push (`git push origin feature/AmazingFeature`)
269
+ 5. Ouvrez une Pull Request
270
+
271
+ ## 📝 Licence
272
+
273
+ Ce projet est sous licence MIT. Voir [LICENSE](LICENSE) pour plus de détails.
274
+
275
+ ## 🙏 Remerciements
276
+
277
+ - [NumPy](https://numpy.org/) - Calculs numériques
278
+ - [Pandas](https://pandas.pydata.org/) - Manipulation de données
279
+ - [SciPy](https://scipy.org/) - Outils scientifiques
280
+ - [Matplotlib](https://matplotlib.org/) - Visualisations
281
+
282
+ ## 📧 Contact
283
+
284
+ Marcel ALOEKPO - [LinkedIn](https://www.linkedin.com/in/marcel-aloekpo-21b42619a) -marcelaloekpo@gmail.com
285
+
286
+ Projet: [https://github.com/Mafoya1er/quantfinance](https://github.com/Mafoya1er/quantfinance)
287
+
288
+ ## ⭐ Support
289
+
290
+ Si vous trouvez ce projet utile, n'hésitez pas à lui donner une étoile ⭐ sur [GitHub](https://github.com/Mafoya1er/quantfinance) !
291
+
292
+ ## 📊 Statistiques
293
+
294
+ ![GitHub stars](https://img.shields.io/github/stars/Mafoya1er/quantfinance?style=social)
295
+ ![GitHub forks](https://img.shields.io/github/forks/Mafoya1er/quantfinance?style=social)
296
+ ![GitHub watchers](https://img.shields.io/github/watchers/Mafoya1er/quantfinance?style=social)
297
+ ![GitHub contributors](https://img.shields.io/github/contributors/Mafoya1er/quantfinance)
298
+ ![GitHub issues](https://img.shields.io/github/issues/Mafoya1er/quantfinance)
299
+ ![GitHub pull requests](https://img.shields.io/github/issues-pr/Mafoya1er/quantfinance)
300
+
301
+ ---
302
+
303
+ **Made with ❤️ for quantitative finance**
@@ -0,0 +1,243 @@
1
+ # QuantFinance 📊
2
+
3
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
4
+ [![PyPI version](https://badge.fury.io/py/quantfinance.svg)](https://badge.fury.io/py/quantfinance)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Build Status](https://github.com/Mafoya1er/quantfinance/workflows/CI/badge.svg)](https://github.com/Mafoya1er/quantfinance/actions)
7
+ [![codecov](https://codecov.io/gh/Mafoya1er/quantfinance/branch/main/graph/badge.svg)](https://codecov.io/gh/Mafoya1er/quantfinance)
8
+ [![Documentation Status](https://readthedocs.org/projects/quantfinance/badge/?version=latest)](https://quantfinance.readthedocs.io/en/latest/?badge=latest)
9
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
10
+
11
+ > Package Python professionnel pour la finance quantitative
12
+
13
+ [Documentation](https://quantfinance.readthedocs.io) | [PyPI](https://pypi.org/project/quantfinance/) | [GitHub](https://github.com/Mafoya1er/quantfinance)
14
+
15
+ ## ✨ Fonctionnalités
16
+
17
+ ### 📈 Pricing d'Instruments Financiers
18
+ - **Options** : Black-Scholes, Binomial Tree, Monte Carlo
19
+ - **Grecques** : Delta, Gamma, Vega, Theta, Rho
20
+ - **Volatilité Implicite** : Méthode de Newton-Raphson
21
+ - **Options Exotiques** : Asiatiques, Barrières
22
+ - **Obligations** : Pricing, YTM, Duration, Convexité
23
+
24
+ ### ⚠️ Gestion des Risques
25
+ - **Value at Risk (VaR)** : Historique, Paramétrique, EWMA, Monte Carlo
26
+ - **Expected Shortfall (CVaR)**
27
+ - **Métriques** : Sharpe, Sortino, Calmar, Omega, Information Ratio
28
+ - **Drawdown** : Maximum, Duration, Série temporelle
29
+ - **Stress Testing** : Scénarios, Analyse historique, Simulation
30
+
31
+ ### 📊 Optimisation de Portefeuille
32
+ - **Markowitz** : Variance minimale, Sharpe maximum, Frontière efficiente
33
+ - **Risk Parity** : Contribution égale au risque
34
+ - **Black-Litterman** : Intégration de vues d'investissement
35
+ - **Hierarchical Risk Parity (HRP)**
36
+ - **Maximum Diversification**
37
+ - **Rééquilibrage** : Périodique, Seuils, Bandes de tolérance
38
+
39
+ ### 🔄 Backtesting
40
+ - Framework de backtesting flexible
41
+ - Stratégies prédéfinies (MA Crossover, Momentum, etc.)
42
+ - Prise en compte des coûts de transaction
43
+ - Analyse de performance détaillée
44
+
45
+ ### 🛠️ Utilitaires
46
+ - Chargement de données (CSV, Yahoo Finance, API)
47
+ - Génération de données synthétiques
48
+ - Nettoyage et préparation de données
49
+ - Indicateurs techniques (SMA, EMA, RSI, MACD, Bollinger Bands)
50
+ - Visualisations avancées
51
+
52
+ ## 🚀 Installation
53
+
54
+ ### Via pip (recommandé)
55
+
56
+ ```bash
57
+ pip install quantfinance
58
+ ```
59
+
60
+ ### Depuis les sources
61
+
62
+ ```bash
63
+ git clone https://github.com/Mafoya1er/quantfinance.git
64
+ cd quantfinance
65
+ pip install -e .
66
+ ```
67
+
68
+ ### Avec dépendances optionnelles
69
+
70
+ ```bash
71
+ # Pour l'analyse de données
72
+ pip install quantfinance[data]
73
+
74
+ # Pour le développement
75
+ pip install quantfinance[dev]
76
+
77
+ # Tout installer
78
+ pip install quantfinance[all]
79
+ ```
80
+
81
+ ## 📚 Démarrage Rapide
82
+
83
+ ### Pricing d'Options
84
+
85
+ ```python
86
+ from quantfinance.pricing.options import BlackScholes
87
+
88
+ # Option call européenne
89
+ bs = BlackScholes(S=100, K=105, T=1, r=0.05, sigma=0.25, option_type='call')
90
+
91
+ print(f"Prix: {bs.price():.2f}")
92
+ print(f"Delta: {bs.delta():.4f}")
93
+ print(f"Gamma: {bs.gamma():.6f}")
94
+ print(f"Vega: {bs.vega():.4f}")
95
+
96
+ # Volatilité implicite
97
+ market_price = 8.50
98
+ implied_vol = bs.implied_volatility(market_price)
99
+ print(f"Vol implicite: {implied_vol:.2%}")
100
+ ```
101
+
102
+ ### Optimisation de Portefeuille
103
+
104
+ ```python
105
+ from quantfinance.portfolio.optimization import PortfolioOptimizer, EfficientFrontier
106
+ from quantfinance.utils.data import DataLoader
107
+
108
+ # Charger des données
109
+ prices = DataLoader.generate_synthetic_prices(n_assets=5, n_days=252*3)
110
+ returns = prices.pct_change().dropna()
111
+
112
+ # Optimiser
113
+ optimizer = PortfolioOptimizer(returns, risk_free_rate=0.02)
114
+
115
+ # Sharpe maximum
116
+ max_sharpe = optimizer.maximize_sharpe()
117
+ print(f"Rendement: {max_sharpe['return']:.2%}")
118
+ print(f"Sharpe: {max_sharpe['sharpe_ratio']:.3f}")
119
+ print("\nPoids:")
120
+ print(max_sharpe['weights'])
121
+
122
+ # Frontière efficiente
123
+ frontier = EfficientFrontier(optimizer)
124
+ frontier.plot_frontier()
125
+ ```
126
+
127
+ ### Analyse de Risque
128
+
129
+ ```python
130
+ from quantfinance.risk.var import VaRCalculator
131
+ from quantfinance.risk.metrics import RiskMetrics, PerformanceAnalyzer
132
+
133
+ # VaR et CVaR
134
+ var_95 = VaRCalculator.historical_var(returns.iloc[:, 0], 0.95)
135
+ es_95 = VaRCalculator.expected_shortfall(returns.iloc[:, 0], 0.95)
136
+
137
+ print(f"VaR 95%: {var_95:.2%}")
138
+ print(f"CVaR 95%: {es_95:.2%}")
139
+
140
+ # Analyse complète
141
+ analyzer = PerformanceAnalyzer(returns.iloc[:, 0], risk_free_rate=0.02)
142
+ summary = analyzer.summary_statistics()
143
+ print(summary)
144
+ ```
145
+
146
+ ### Backtesting
147
+
148
+ ```python
149
+ from quantfinance.portfolio.backtesting import Backtester, MovingAverageCrossover
150
+ from quantfinance.utils.data import DataLoader
151
+
152
+ # Données OHLCV
153
+ data = DataLoader.generate_ohlcv_data(n_days=500)
154
+
155
+ # Stratégie
156
+ strategy = MovingAverageCrossover(short_window=20, long_window=50)
157
+
158
+ # Backtest
159
+ backtester = Backtester(data, strategy, initial_capital=100000)
160
+ results = backtester.run()
161
+
162
+ print(f"Rendement: {results['Total Return']:.2%}")
163
+ print(f"Sharpe: {results['Sharpe Ratio']:.3f}")
164
+ print(f"Max DD: {results['Max Drawdown']:.2%}")
165
+
166
+ # Visualisation
167
+ backtester.plot()
168
+ ```
169
+
170
+ ## 📖 Documentation
171
+
172
+ Documentation complète disponible sur [ReadTheDocs](https://quantfinance.readthedocs.io).
173
+
174
+ ### Guides
175
+
176
+ - [Installation](https://quantfinance.readthedocs.io/en/latest/user_guide/installation.html)
177
+ - [Démarrage Rapide](https://quantfinance.readthedocs.io/en/latest/user_guide/quickstart.html)
178
+ - [Tutoriels](https://quantfinance.readthedocs.io/en/latest/user_guide/tutorials.html)
179
+ - [Exemples](https://quantfinance.readthedocs.io/en/latest/user_guide/examples.html)
180
+
181
+ ### Référence API
182
+
183
+ - [Pricing](https://quantfinance.readthedocs.io/en/latest/api/pricing.html)
184
+ - [Risk](https://quantfinance.readthedocs.io/en/latest/api/risk.html)
185
+ - [Portfolio](https://quantfinance.readthedocs.io/en/latest/api/portfolio.html)
186
+ - [Utils](https://quantfinance.readthedocs.io/en/latest/api/utils.html)
187
+
188
+ ## 🧪 Tests
189
+
190
+ ```bash
191
+ # Lancer tous les tests
192
+ pytest
193
+
194
+ # Avec couverture
195
+ pytest --cov=quantfinance --cov-report=html
196
+
197
+ # Tests rapides seulement
198
+ pytest -m "not slow"
199
+ ```
200
+
201
+ ## 🤝 Contribution
202
+
203
+ Les contributions sont les bienvenues ! Consultez [CONTRIBUTING.md](CONTRIBUTING.md).
204
+
205
+ 1. Fork le projet
206
+ 2. Créez une branche (`git checkout -b feature/AmazingFeature`)
207
+ 3. Committez (`git commit -m 'feat: Add AmazingFeature'`)
208
+ 4. Push (`git push origin feature/AmazingFeature`)
209
+ 5. Ouvrez une Pull Request
210
+
211
+ ## 📝 Licence
212
+
213
+ Ce projet est sous licence MIT. Voir [LICENSE](LICENSE) pour plus de détails.
214
+
215
+ ## 🙏 Remerciements
216
+
217
+ - [NumPy](https://numpy.org/) - Calculs numériques
218
+ - [Pandas](https://pandas.pydata.org/) - Manipulation de données
219
+ - [SciPy](https://scipy.org/) - Outils scientifiques
220
+ - [Matplotlib](https://matplotlib.org/) - Visualisations
221
+
222
+ ## 📧 Contact
223
+
224
+ Marcel ALOEKPO - [LinkedIn](https://www.linkedin.com/in/marcel-aloekpo-21b42619a) -marcelaloekpo@gmail.com
225
+
226
+ Projet: [https://github.com/Mafoya1er/quantfinance](https://github.com/Mafoya1er/quantfinance)
227
+
228
+ ## ⭐ Support
229
+
230
+ Si vous trouvez ce projet utile, n'hésitez pas à lui donner une étoile ⭐ sur [GitHub](https://github.com/Mafoya1er/quantfinance) !
231
+
232
+ ## 📊 Statistiques
233
+
234
+ ![GitHub stars](https://img.shields.io/github/stars/Mafoya1er/quantfinance?style=social)
235
+ ![GitHub forks](https://img.shields.io/github/forks/Mafoya1er/quantfinance?style=social)
236
+ ![GitHub watchers](https://img.shields.io/github/watchers/Mafoya1er/quantfinance?style=social)
237
+ ![GitHub contributors](https://img.shields.io/github/contributors/Mafoya1er/quantfinance)
238
+ ![GitHub issues](https://img.shields.io/github/issues/Mafoya1er/quantfinance)
239
+ ![GitHub pull requests](https://img.shields.io/github/issues-pr/Mafoya1er/quantfinance)
240
+
241
+ ---
242
+
243
+ **Made with ❤️ for quantitative finance**