Institutional-Grade Quantitative Finance Library
Project description
fdequant
The Ultimate Institutional-Grade Quantitative Finance Library
👋 Why fdequant?
Hi, I'm Aayush Mishra, and I built fdequant to solve the pain points I saw firsthand in quantitative finance:
- Fragmented tools: Traders and analysts waste hours stitching together libraries.
- Limited strategy testing: Backtesting is often oversimplified or too slow.
- No all-in-one solution: Risk management, technical analysis, reporting, and screening are siloed.
fdequant changes that by being a single, production-grade library that handles everything from backtesting to reporting—so you can focus on what matters: building winning strategies.
🚀 Key Features
fdequant is packed with institutional-grade capabilities:
1. Institutional Strategy Backtesting Engine
- Ready-to-use strategies: SMA, EMA, RSI, MACD, Bollinger Bands, Moving Average Cross
- Custom strategy support: Build your own with a clean, modular API
- Comprehensive metrics: CAGR, Sharpe Ratio, Sortino Ratio, Calmar Ratio, Max Drawdown, Win Rate, and more
- Transaction costs: Commission and slippage modeling for realistic backtests
- Trade history: Detailed tracking of every entry/exit with timestamps and prices
2. Professional Stock Screener
- 20+ technical filters: RSI, EMA, SMA, MACD, ADX, SuperTrend, Bollinger Bands, Volume Spikes, Breakouts, Gaps, New Highs/Lows, and more
- Fundamental filters: Market cap, PE, PB, dividend yield
- Ranking system: Sort results by any metric
- CSV export: Seamlessly integrate with spreadsheets or other tools
3. Monte Carlo Portfolio Simulation
- Scalable simulations: 10k+, 50k+, 100k+ runs
- Risk analytics: VaR (95%/99%), CVaR (95%/99%), probability of profit/loss
- Scenario analysis: Best case, worst case, median, mean, and confidence intervals
- Asset & portfolio support: Simulate individual assets or weighted portfolios
4. Technical Indicator Engine
- 20+ indicators: SMA, EMA, WMA, MACD, RSI, Bollinger Bands, Keltner Channel, Donchian Channel, ATR, ADX, CCI, OBV, CMF, ROC, Momentum, SuperTrend, Ichimoku, Stochastic RSI, Williams %R, Parabolic SAR, VWAP
- Clean output: All indicators return pandas Series/DataFrames for easy analysis
5. Professional Report Generator
- Multiple formats: Excel (.xlsx), HTML, and PDF (optional weasyprint dependency)
- Comprehensive content: Portfolio summary, performance metrics, trade history, Monte Carlo results, technical indicators
- Production-ready: Perfect for client reports or internal reviews
6. Strategy Builder DSL
- Fluent, intuitive interface: Build strategies with
Strategy().buy_when(...).sell_when(...).stoploss(...).takeprofit(...).backtest(...) - Risk management built-in: Stop loss and take profit rules with minimal code
- Seamless backtesting: Plug directly into the backtesting engine for instant validation
7. Original Risk Management Capabilities
- AdvancedRealTimeRiskAssessment: XGBoost-based risk prediction with continuous training
- Real-time data integration: yfinance integration for up-to-date market data
- Custom risk metrics: Build your own risk indicators
📦 Installation
First, clone the repository:
git clone https://github.com/your-username/fdequant.git
cd fdequant
Install dependencies:
pip install -r requirements.txt
💡 Quick Start
Let's run a complete example that demonstrates the power of fdequant!
import yfinance as yf
from fdequant import (
Backtester,
SMAStrategy,
Strategy,
StockScreener,
MonteCarloSimulation,
ReportGenerator
)
# 1. Backtest an SMA Crossover Strategy
data = yf.Ticker("AAPL").history(period="5y")
strategy = SMAStrategy(short_window=20, long_window=50)
backtester = Backtester(initial_capital=100000)
backtest_results = backtester.run(strategy, data)
print("Backtest Complete!")
print(f"Total Return: {backtest_results.total_return:.2%}")
# 2. Build a Custom Strategy with the DSL
def buy_condition(df):
from fdequant import sma
return sma(df['Close'], 20) > sma(df['Close'], 50)
def sell_condition(df):
from fdequant import sma
return sma(df['Close'], 20) < sma(df['Close'], 50)
custom_strategy = (
Strategy()
.buy_when(buy_condition)
.sell_when(sell_condition)
.stoploss(0.02) # 2% stop loss
.takeprofit(0.05) # 5% take profit
)
dsl_results = custom_strategy.backtest(data, initial_capital=100000)
# 3. Screen for Promising Stocks
screener = (
StockScreener(tickers=["AAPL", "MSFT", "GOOGL", "AMZN", "META"])
.rsi_filter(min_val=30, max_val=70)
.sma_filter(window=50, price_above=True)
.load_data(period="1y")
)
screened_stocks = screener.run()
print("Screened Stocks:")
print(screened_stocks)
# 4. Run Monte Carlo Simulation
tickers = ["AAPL", "MSFT", "GOOGL"]
portfolio_data = yf.download(tickers, period="5y")['Close']
returns = portfolio_data.pct_change().dropna()
simulator = MonteCarloSimulation(initial_investment=10000, time_horizon=252)
mc_results = simulator.simulate(returns, num_simulations=10000)
print("\nMonte Carlo Results:")
print(f"Probability of Profit: {mc_results.probability_of_profit:.2%}")
print(f"VaR (95%): {mc_results.var_95:.2%}")
# 5. Generate a Professional Report
generator = ReportGenerator(title="fdequant Analysis Report")
generator.generate_excel(
"fdequant_report.xlsx",
performance=backtest_results,
monte_carlo=mc_results,
portfolio_data=screened_stocks
)
generator.generate_html(
"fdequant_report.html",
performance=backtest_results,
monte_carlo=mc_results,
portfolio_data=screened_stocks
)
print("\nReports generated: fdequant_report.xlsx and fdequant_report.html")
For more examples, check out advanced_example.py and example.py.
📊 Project Structure
fdequant/
├── fdequant/ # Main library package
│ ├── indicators/ # Technical indicators
│ ├── backtesting/ # Backtesting engine & strategies
│ ├── screener/ # Stock screener
│ ├── monte_carlo/ # Monte Carlo simulation
│ ├── reports/ # Report generator
│ ├── strategy_dsl/ # Strategy builder DSL
│ ├── main.py # Original risk management features
│ └── oa_v2.py # Ensemble risk assessment
├── advanced_example.py # Advanced usage examples
├── example.py # Original risk management example
├── requirements.txt # Dependencies
├── LICENSE # License (all rights reserved to Aayush Mishra)
└── README.md # This file!
🛠️ Tech Stack
- Core: Python 3.8+
- Data: pandas, numpy, yfinance
- Machine Learning: scikit-learn, XGBoost
- Visualization/Reports: openpyxl (Excel), weasyprint (optional PDF)
- Logging: loguru
🔒 License
All Rights Reserved. Aayush Mishra.
This software is the exclusive property of Aayush Mishra. No part of this library may be reproduced, modified, distributed, or used in any form without explicit written permission. Editing or altering the code is strictly prohibited.
For inquiries, contact Aayush Mishra.
🤝 About the Developer
Aayush Mishra built fdequant to bring institutional-grade quantitative finance tools to everyone. With deep expertise in machine learning, risk management, and financial markets, Aayush is passionate about building practical, production-ready solutions.
Built with passion by Aayush Mishra
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fdequant-1.0.0.tar.gz.
File metadata
- Download URL: fdequant-1.0.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7ca3e2ef667f112b1be8c03d462d80775759154d0f6f7031a9a5086f839ffec
|
|
| MD5 |
7e9177ebc76504d01c2b57d11070d49d
|
|
| BLAKE2b-256 |
f608b2617c1eb9c7d24bb80b0da6b6f1c5536a3dab3ffe4a63588600d45f9960
|
File details
Details for the file fdequant-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fdequant-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15ca394887271fbed1dd774e9a11e00212114f97be52ec07878c5b39b901d6ed
|
|
| MD5 |
40ee3c0980bd989272722ab752278144
|
|
| BLAKE2b-256 |
067467022caeac152b9d49e3cc6d5d6c14a2c9ab104ab5c11d988a241924fb65
|