Metadata-Version: 2.4
Name: QuantMission
Version: 0.0.1a1
Summary: Official Python client and B3 derivatives analytics engine for QuantMission.
Author-email: QuantMission <contact@quantmission.com>
License: MIT
Project-URL: Homepage, https://www.quantmission.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Education
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: yfinance
Requires-Dist: pandas
Requires-Dist: requests
Requires-Dist: xlwings
Requires-Dist: xlrd
Dynamic: license-file

# QuantMission

[![PyPI version](https://img.shields.io/pypi/v/QuantMission.svg)](https://pypi.org/project/QuantMission/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

**Official Python client and B3 derivatives analytics engine for QuantMission.**

QuantMission is an institutional-grade financial data platform built for the Brazilian market. This library currently serves as a standalone **B3 Options Calculator**, engineered to handle the unique quirks of Brazilian quantitative finance, including business-day math, local holiday calendars, and automated DI x Pré yield curve parsing.

*Note: This package is currently in Alpha. It serves as an early release of our local analytics engine while the secure QuantMission API and historical data lake are actively under development.*

## Key Features

*   **Automated Yield Curve Parsing:** Automatically downloads, extracts, and parses the daily official `TaxaSwap.txt` (DI x Pré) directly from the B3 exchange to calculate precise forward rates.
*   **Anbima Holiday Integration:** Auto-fetches and caches the official Anbima national holiday calendar to calculate exact business days (`dias úteis`) to maturity.
*   **Bulletproof Volatility Engine:** Calculates standard Yang-Zhang volatility via `yfinance`, featuring a built-in, silent fallback to raw Yahoo Finance REST APIs to bypass library outages and missing data.
*   **Comprehensive Greeks & Valuation:** Calculates Black-Scholes theoretical pricing, Intrinsic Value, Time Value, and first/second-order Greeks (Delta, Gamma, Theta, Vega, Rho).
*   **Excel Ready:** Built from the ground up to integrate seamlessly with `xlwings` for instantaneous spreadsheet-based quant workflows.

## Installation

Install the package directly from PyPI:

```bash
pip install QuantMission
```
## Quick Start (Python)

The calculator abstracts away the complexity of data fetching. Simply initialize it with a B3 ticker, and it will handle the backend routing, holiday caching, and curve interpolation automatically.

```
import datetime
from quantmission import B3OptionsCalculator

# 1. Initialize the engine for a specific B3 ticker
calc = B3OptionsCalculator("PETR4")

# 2. Calculate Theoretical Prices and Greeks
results = calc.calculate_greeks(
    spot=38.50,
    strike=38.00,
    expiry_date=datetime.date(2026, 8, 21),
    n_days=63 # Lookback window for Yang-Zhang volatility
)

# 3. View the outputs
print(f"Theoretical Call Price: R$ {results['call_price']}")
print(f"Call Delta: {results['call_delta']}")
print(f"Interpolated Risk-Free Rate: {results['annual_rate'] * 100:.2f}%")
print(f"Volatility Source Used: {results['vol_source']}")
```

## Excel UDF Setup (xlwings)

This package comes pre-configured with a User Defined Function (UDF) that allows you to spill the entire Greeks array directly into an Excel spreadsheet.

1. Ensure you have the xlwings add-in installed in Excel. (If not, run xlwings addin install in your terminal).

2. In the same folder as your Excel file, create a simple Python script (e.g., bridge.py) to expose the QuantMission UDF:

```
import xlwings as xw
from quantmission.core import B3options
```
3. Open your Excel workbook, navigate to the xlwings ribbon, and:

    * Set the Interpreter path to your Python executable (e.g., C:\Python311\python.exe).

    * Set the UDF Modules box to your script name (e.g., bridge).

4. Click Import Functions.

5. In any cell, type the formula and hit Enter to spill the array:
```
=B3options("PETR4", 38.50, DATE(2026,8,21), 38.00, 63)
```

## The QuantMission Vision (Roadmap)

Currently, this library operates strictly locally, pulling public data to calculate derivatives pricing.

In the future, the QuantMission library will serve as the official Python SDK for the QuantMission Data Platform. Users will be able to authenticate with their API keys to access our proprietary backend, featuring:

* Cleaned, tick-level historical B3 data.

* Institutional-grade market data lakes.

* Advanced, server-side derivatives analytics.

## License

This project is open-sourced under the MIT License.

## Contact & Support

For enterprise inquiries or to learn more about the upcoming data platform, contact us at contact@quantmission.com.
