Skip to main content

Institutional-Grade Quantitative Finance Library

Project description

fdequant

The Ultimate Institutional-Grade Quantitative Finance Library

PyPI Version Python Versions Build Status License

FeaturesInstallationQuick StartLicense


👋 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

fdequant-1.0.1.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fdequant-1.0.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file fdequant-1.0.1.tar.gz.

File metadata

  • Download URL: fdequant-1.0.1.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

Hashes for fdequant-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e752ed9fd143b4cefcc9c0e0171cb201dce6cabc357966f25fcff5042b48e1ad
MD5 18c87bbcae0a90c90147a60a3579f1d8
BLAKE2b-256 70e8efd775e86bc71fff65db45c365e0c3c6385ace3442e0c2efecdf515f2ee6

See more details on using hashes here.

File details

Details for the file fdequant-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: fdequant-1.0.1-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

Hashes for fdequant-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bf335937daf55e2b3d9c2088a18a18eb3ba0981c0a834b665f24f56b47cf56f
MD5 f81e66a88fcf73b54242b154fd97fed3
BLAKE2b-256 b66fb3cf59b1ef76ece0f4b40999833a8c6f7674e657958b3cffafb76910792d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page