Metadata-Version: 2.1
Name: lifelib-pyql
Version: 0.0.1
Summary: QuantLib Cython wrappers
Author: Didrik Pinte, Patrick Henaff
License: BSD 3-Clause License
        
        Copyright (c) 2026, lifelib-dev contributors
        All rights reserved.
        
        This project is a fork of PyQL, originally developed by Enthought, Inc.,
        Didrik Pinte, and Patrick Henaff. The original PyQL license is preserved
        in LICENSE_ORIGINAL_PYQL.txt.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
         * Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
         * Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
         * Neither the name of the copyright holder nor the names of its contributors
           may be used to endorse or promote products derived from this software
           without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
License-File: LICENSE_ORIGINAL_PYQL.txt
Requires-Dist: tabulate
Requires-Dist: pandas
Requires-Dist: six

lifelib-pyql
============

Cython-based Python bindings for the [QuantLib](http://www.quantlib.org) C++ library.

This project is a fork of [PyQL](https://github.com/enthought/pyql) (originally developed by Enthought) that replaces SWIG wrappers with a more Pythonic API built on Cython. It provides comprehensive coverage of QuantLib's functionality, including term structures, instruments, pricing engines, short-rate and equity models, and more.

## Portfolio Module

Beyond the core QuantLib bindings, lifelib-pyql is developing a `portfolio` submodule for processing a large number of instruments of the same type efficiently.

When working with thousands or millions of instruments, creating a separate Python object for each one is too slow. The `portfolio` submodule provides a set of new APIs that let you create a single Python object representing a large set of instruments of the same type, whose methods operate on all instruments in the set at once rather than one at a time.

Currently, the `portfolio` module includes:

- **`Schedules`** -- A vectorized collection of payment schedules. It bulk-generates QuantLib `Schedule` objects from arrays of parameters and stores the resulting dates in a compact 2D NumPy `datetime64[D]` array.

```python
from lifelib_pyql.portfolio.api import Schedules
import numpy as np

schedules = Schedules(
    effective_dates=np.array(['2024-01-15', '2024-03-01'], dtype='datetime64[D]'),
    termination_dates=np.array(['2029-01-15', '2029-03-01'], dtype='datetime64[D]'),
    tenors=np.array([6, 3]),       # months
    max_size=20,
)

schedules.dates    # 2D datetime64[D] array, NaT-padded
schedules.size     # number of dates per schedule
schedules[0]       # returns a single Schedule object
schedules[0:1]     # returns a new Schedules slice
```

- **`FixedRateBonds`** -- A vectorized collection of fixed-rate bonds stored as parallel NumPy arrays. It bulk-stores bond parameters and reconstructs individual QuantLib `FixedRateBond` objects on demand via indexing.

```python
from lifelib_pyql.portfolio.api import Schedules, FixedRateBonds
from lifelib_pyql.time.daycounters.actual_actual import ActualActual
from lifelib_pyql.time.businessdayconvention import Following
import numpy as np

bonds = FixedRateBonds(
    settlement_days=np.array([3, 3, 3]),
    face_amounts=np.array([100.0, 100.0, 100.0]),
    schedules=schedules,                        # a Schedules object
    coupons=np.array([0.05, 0.04, 0.06]),       # one coupon rate per bond
    accrual_day_counter=ActualActual(ActualActual.ISMA),
    payment_convention=Following,
    redemptions=100.0,                          # scalar broadcasts to all
    issue_dates=np.array(['2024-01-15', '2024-03-01', '2024-06-01'],
                         dtype='datetime64[D]'),
)

bonds[0]           # returns a single FixedRateBond object
bonds[0:2]         # returns a new FixedRateBonds slice
len(bonds)         # number of bonds in the collection
bonds.coupons      # 1D or 2D array of coupon rates
```

## Prerequisites

* [QuantLib](http://www.quantlib.org) 1.41 or higher (with [Boost](https://www.boost.org/) 1.78.0+)
* [Cython](http://www.cython.org) 3.0 or higher
* Python 3.10+
* NumPy

## Building

```bash
# Build Cython extensions in-place
make build

# Run the test suite
make tests

# Build documentation (requires Sphinx, nbsphinx)
make docs
```

See the [Getting started](docs/source/getting_started.rst) guide for full details.

## License

BSD 3-Clause. See [LICENSE.txt](LICENSE.txt). The original PyQL license is preserved in [LICENSE_ORIGINAL_PYQL.txt](LICENSE_ORIGINAL_PYQL.txt).
