Metadata-Version: 2.4
Name: fdequant
Version: 1.0.1
Summary: Institutional-Grade Quantitative Finance Library
Author: Aayush Mishra
License: Proprietary - All Rights Reserved
Project-URL: Homepage, https://github.com/your-username/fdequant
Project-URL: Repository, https://github.com/your-username/fdequant
Project-URL: Documentation, https://github.com/your-username/fdequant#readme
Project-URL: Issues, https://github.com/your-username/fdequant/issues
Keywords: quantitative-finance,backtesting,technical-analysis,trading,risk-management
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Developers
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Requires-Dist: pandas>=1.3.0
Requires-Dist: yfinance>=0.2.0
Requires-Dist: loguru>=0.6.0
Requires-Dist: scikit-learn>=1.0.0
Requires-Dist: xgboost>=1.5.0
Requires-Dist: openpyxl>=3.0.0
Provides-Extra: pdf
Requires-Dist: weasyprint>=59.0; extra == "pdf"
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Dynamic: license-file


<div align="center">
  <h1>fdequant</h1>
  <p><strong>The Ultimate Institutional-Grade Quantitative Finance Library</strong></p>
  <p>
    <a href="https://pypi.org/project/fdequant/">
      <img src="https://img.shields.io/pypi/v/fdequant.svg" alt="PyPI Version">
    </a>
    <a href="https://pypi.org/project/fdequant/">
      <img src="https://img.shields.io/pypi/pyversions/fdequant.svg" alt="Python Versions">
    </a>
    <a href="https://github.com/your-username/fdequant/actions">
      <img src="https://github.com/your-username/fdequant/actions/workflows/test.yml/badge.svg" alt="Build Status">
    </a>
    <a href="#-license">
      <img src="https://img.shields.io/badge/license-Proprietary-blue.svg" alt="License">
    </a>
  </p>
  <p>
    <a href="#-key-features">Features</a> •
    <a href="#-installation">Installation</a> •
    <a href="#-quick-start">Quick Start</a> •
    <a href="#-license">License</a>
  </p>
</div>

---

## 👋 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:

```bash
git clone https://github.com/your-username/fdequant.git
cd fdequant
```

Install dependencies:

```bash
pip install -r requirements.txt
```

---

## 💡 Quick Start

Let's run a complete example that demonstrates the power of fdequant!

```python
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.

---

<div align="center">
  <p>Built with passion by Aayush Mishra</p>
</div>
