A comprehensive Python library for Fixed Income, Currency, and Commodities (FICC) derivatives pricing and risk management. MCP provides professional-grade tools for financial institutions, trading desks, and quantitative analysts, with seamless Excel integration that allows users to create complex financial models and templates directly within Excel spreadsheets.
- Comprehensive FICC Coverage: Support for FX, Interest Rate, Bond, and Volatility products
- Professional Pricing Models: Black-Scholes, Heston, Bachelier, and advanced volatility models
- Real-time & Historical Data: Integration with market data providers
- Excel Integration: Seamless Excel add-in functionality via PyXLL
- High Performance: Optimized C++ core with Python wrapper
- Production Ready: Used by major financial institutions
- Vanilla Options
- Call/Put Options
- American Style Options
- Asian Options (Average rate/strike)
- Exotic Options
- Barrier Options (Knock-in, Knock-out)
- Touch Options (One-Touch, No-Touch)
- Digital Options (Cash/Asset-or-Nothing)
- Forward Products
- Outright Forward
- Range Forward (Spread Forward)
- Floor Forward (Protected Forward)
- Cap Forward (Capped Forward)
- Cap & Floor Forward (Cylinder)
- Ratio Forward
- Dual Currency Forward
- Target Forward
- Bonds
- Bullet Bonds (One-time maturity payment)
- Callable Bonds (Embedded options)
- Coupon Bonds (Regular interest payments)
- Perpetual Bonds
- Floating Rate Notes (FRN)
- Interest Rate Swaps
- Standard IRS (FR007, SOFR, etc.)
- Float/Float Swaps
- Float/Fixed Swaps
- Fixed/Float Swaps
- Interest Rate Derivatives
- Bond Forwards
- Bond Options
- Swaptions (Interest Rate Swap Options)
- Caps & Floors
- Forward Rate Agreements (FRA)
- Curve Models
- Forward Curves
- Yield Curves
- Volatility Surfaces
- Local Volatility Models
- Interest Rate Curves
- Deposit Curves
- Bond Curves
- Swap Curves
- Parametric Curves
- Interest Rate Surfaces
- Cap/Floor Volatility Surfaces
- IRO Volatility Cubes
Customized structured options linked to interest rates, FX rates, commodities, and equity indices:
- Double No Touch (Bilateral barrier)
- Triple Ranges Put (Three-level put structure)
- Range Accrual (Accumulative range)
- Digital Call (Binary call option)
- Autocallables (Monthly observation auto-call)
- Triple Ranges Call (Three-level call structure)
- Cash Delivery Forward (Subsidized delivery structured forward)
- Double Ranges (Dual-level structure)
- Digital Put (Binary put option)
- Single Touch (One-sided barrier)
- Call Put Spread (Spread structure)
- Auto Call (Callable structure)
- Shark Fin (Dual shark fin)
- Dual Shark Fin (Bidirectional shark fin)
- Discrete Double No Touch (Daily observation EUR/USD)
- Discrete One Touch Downside (Downward one-touch)
- Discrete One Touch Upside (Upward one-touch)
- Discrete Ping Pong Option (Discrete ping-pong option)
- Single Range Accrual Call (One-sided call range accrual)
- Single Range Accrual Put (One-sided put range accrual)
- Custom Structures (More tailored products available)
Structured products utilize Monte Carlo simulation and support GPU acceleration for enhanced performance. If your machine has NVIDIA RTX series or compatible GPUs installed, you can enable GPU acceleration through:
- PyXLL Configuration: Set
MCP_RUNMODE = GPU
inpyxll.cfg
- Environment Variable: Set
MCP_RUNMODE = GPU
in system environment variables
GPU acceleration significantly improves calculation speed for complex structured products pricing.
MCP supports both automated installation (recommended) and manual installation methods.
The easiest way to install MCP is using our automated installation script:
# Download and extract MCP to your desired location
# Then run the installation script
quick_install.bat
After installation, verify everything works:
python test_install.py
Features of Quick Installation:
- β Automatic Python 3.9.x compatibility check
- β Automatic dependency installation
- β System architecture detection (x64/Win32)
- β Excel version detection and configuration
- β PYTHONPATH environment setup
- β PyXLL Excel add-in installation (optional)
- β Comprehensive error handling and recovery
π Detailed Installation Guide: Installation Scripts Guide
If you prefer manual installation or automated installation fails:
- Python: 3.9.x (required)
- OS: Windows 10/11 (64-bit recommended)
- Excel: Microsoft Excel 2016 or later
- PyXLL: Professional License (for Excel integration)
# Navigate to MCP directory
cd C:\path\to\mcp-python
# Install dependencies
pip install -r requirements.txt
Add these paths to your system PYTHONPATH:
C:\path\to\mcp-python
C:\path\to\mcp-python\lib\X64
Windows 10/11 Setup:
- Press
Win + R
, typesysdm.cpl
, press Enter - Click "Environment Variables"
- Under "User variables", find or create "PYTHONPATH"
- Add the paths above, separated by semicolons
-
Update pyxll.cfg:
- Open
lib\X64\pyxll.cfg
(orlib\Win32\pyxll.cfg
for 32-bit) - Update the
executable
line to point to your Python installation:executable = C:\Python39\python.exe
- Open
-
Determine Excel Version:
- Open Excel
- Go to File β Account β About Excel
- Check if it shows "Microsoft Excel 2016 (64-bit)" or "Microsoft Excel 2016 (32-bit)"
- Or press Ctrl + G, type
=INFO("numfile")
, press Enter - If the result is 1, you have 32-bit Excel; if it's 2, you have 64-bit Excel
-
Install PyXLL add-in:
- Based on your Excel version, choose the correct file:
- 64-bit Excel: Use
lib\X64\pyxll.xll
- 32-bit Excel: Use
lib\Win32\pyxll.xll
- 64-bit Excel: Use
- Go to File β Options β Add-ins
- At the bottom, select Excel Add-ins from the dropdown and click Go
- Click Browse and navigate to the correct
pyxll.xll
file - Select the file and click OK
- Ensure the add-in is checked and click OK
- Based on your Excel version, choose the correct file:
-
Restart Excel and verify the add-in is loaded
# Test Python library
python -c "import mcp; print('MCP installed successfully')"
# Test example
python example\calendar\quickstart.py
π Detailed Manual Installation Guide: Manual Installation Guide
π Python API Guide: Python User Guide
π Excel API Guide: Excel User Guide
π New to MCP? Check out our Quick Start Guide for a 5-minute setup!
from mcp.tool.tools_main import McpVanillaOption
from mcp.utils.enums import BuySell, CallPut, OptionExpiryNature
# Create option parameters
option_args = {
'Pair': 'USD/CNY',
'BuySell': BuySell.Buy,
'CallPut': CallPut.Call,
'OptionExpiryNature': OptionExpiryNature.EUROPEAN,
'StrikePx': 7.3,
'SpotPx': 7.0671,
'Volatility': 0.0484,
'DomesticRate': 0.0186,
'ForeignRate': 0.0475,
'ExpiryDate': '2025-02-14',
'DeliveryDate': '2025-02-18',
'FaceAmount': 1000000
}
# Price the option
option = McpVanillaOption(option_args)
price = option.Price()
print(f"Option Price: {price:.2f}")
from mcp.tool.tools_main import McpYieldCurve2
from mcp.utils.enums import DayCounter, Frequency
# Build bilateral yield curve
curve_args = {
'ReferenceDate': '2024-12-13',
'Tenors': ['ON', '1M', '3M', '6M', '1Y', '2Y', '5Y'],
'BidZeroRates': [0.0458, 0.0433, 0.0433, 0.0433, 0.0433, 0.043, 0.042],
'AskZeroRates': [0.0459, 0.0458, 0.0458, 0.0458, 0.0458, 0.046, 0.045],
'DayCounter': DayCounter.Act365Fixed,
'Frequency': Frequency.Continuous
}
curve = McpYieldCurve2(curve_args)
zero_rate = curve.ZeroRate('2025-12-13', 'mid')
print(f"1Y Zero Rate: {zero_rate*100:.4f}%")
from mcp.tool.tools_main import McpFXForwardPointsCurve2
# Build bilateral forward points curve
forward_args = {
'ReferenceDate': '2024-12-13',
'Pair': 'USD/CNY',
'FXSpotRate': 7.1650,
'Tenors': ['ON', '1M', '3M', '6M', '1Y'],
'BidForwardPoints': [-22.0, -250, -733, -1393, -2395],
'AskForwardPoints': [-21.0, -248, -730, -1390, -2390]
}
forward_curve = McpFXForwardPointsCurve2(forward_args)
points = forward_curve.FXForwardPoints('2025-03-13', 'mid')
print(f"3M Forward Points: {points:.1f}")
mcp-python/
βββ mcp/ # Core MCP library python files
β βββ tool/ # Main pricing tools
β βββ utils/ # Utilities and enums
β βββ forward/ # Forward pricing
β βββ server_version/ # Server-side APIs
βββ lib/ # Core MCP library pyd files
β βββ Win32/ # Win32 pyd files
β βββ X64/ # X64 pyd files
βββ example/ # Pytho Example scripts
β βββ calendar/ # Calendar examples
β βββ fixedincome/ # Fixed income examples
β βββ forward_curve/ # Forward curve examples
β βββ option/ # Option pricing examples
β βββ volsurface2/ # Volatility surface examples
β βββ yield_curve/ # Yield curve examples
βββ pyxll_func/ # Excel add-in pyxll functions
β βββ core/ # Core MCP functions
β βββ custom/ # Any customzation functions be here!
βββ excel/ # Excel templates and examples
βββ en/ # English Version excel and docs
βββ zh/ # Chinese Version excel and docs
- π Quick Start: 5-minute setup guide
- π Installation Guide: Complete installation instructions
- π§ Scripts Guide: Installation scripts documentation
- API Reference: help.mathema.com.cn
- Python Guide: Python User Guide
- Excel Guide: Excel User Guide
- Python Examples: See the
example/
directory for comprehensive examples - Excel Examples: See the
excel/
directory for comprehensive excel template - Contributing: How to contribute
- License: MIT License details
- OS: Windows 10/11 (64-bit recommended)
- Python: 3.9.x (required)
- Memory: 4GB RAM minimum, 8GB recommended
- Storage: 500MB free space
- Excel: Microsoft Excel 2016 or later (for Excel integration)
- NumPy: Numerical computing
- Pandas: Data manipulation
- Requests: HTTP requests for server functions
- Python-dateutil: Date handling
- PyXLL: Commercial license required for Excel integration
- Matplotlib: Plotting and visualization
- Jupyter: Notebook support
- Development tools: pytest, black, flake8, mypy
To install optional dependencies:
pip install -r requirements-optional.txt
MCP includes PyXLL module for Excel integration:
- PyXLL License: Purchase from pyxll.com
- PyXLL Module: Already included in MCP (no pip install needed)
- Register MCP Add-in:
- Enhanced way: Run
python register_pyxll.py
- Manual way:
python -m pyxll install --install-first --non-interactive lib/X64 python -m pyxll activate --non-interactive lib/X64
- Enhanced way: Run
- quick_install.bat: Main automated installation script
- install_helper.py: Python installation helper (included in quick_install.bat)
- test_install.py: Installation verification script
This project is licensed under the MIT License - see the LICENSE file for details.
Important Notes:
- Python source code is open source and freely distributable
- Compiled binary components (.pyd files) are proprietary
- PyXLL requires a separate commercial license
- Excel templates are freely usable under MIT License
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- GitHub Issues: Report bugs and request features
- Documentation: help.mathema.com.cn
- Community: Join our discussions for help and best practices
Mathema Team specializes in quantitative finance and derivatives pricing solutions. Our MCP platform is used by leading financial institutions worldwide for:
- Risk management and compliance
- Trading desk operations
- Quantitative research
- Regulatory reporting
- Portfolio valuation
- Website: mathema.com.cn
- Documentation: help.mathema.com.cn
- PyXLL: www.pyxll.com
- GitHub: github.com/MDTSH
"Python 3.9.x required"
- Install Python 3.9.x from python.org
"ModuleNotFoundError: No module named 'mcp'"
- Check PYTHONPATH is set correctly
- Restart command prompt
- Run
python test_install.py
for diagnostics
Excel add-in not loading
- Restart Excel
- Check Excel Add-ins settings
- Verify PyXLL is installed
Windows 11 Specific Issues
If you're using Windows 11 and encounter these errors:
ModuleNotFoundError: No module named 'mcp._mcp'
- Excel shows "Error importing Python modules"
Solution: Copy and rename DLL files from system directory:
- Navigate to
C:\Windows\system32\
- Find these files:
msvcr120_clr0400.dll
msvcp120_clr0400.dll
- Copy them to
.\lib\X64\
and rename to:msvcr120.dll
msvcp120.dll
Note: Why this works? We don't know either π - but it fixes the issue on Windows 11!
- Run diagnostics:
python test_install.py
- Full guide: INSTALLATION.md
- Scripts guide: INSTALL_SCRIPTS_README.md
- GitHub issues: Report problems