Metadata-Version: 2.4
Name: finance-dag
Version: 0.1.0.dev7
Summary: Directed Acyclic Graph (DAG) management specifically for financial data workflows.
Project-URL: repository, https://github.com/tinamou8/finance-dag
Project-URL: documentation, https://finance-dag.readthedocs.io
Project-URL: issues, https://github.com/tinamou8/finance-dag/issues
Project-URL: changelog, https://github.com/tinamou8/finance-dag/blob/main/CHANGELOG.md
Author-email: "José A. del Val" <delval@duck.com>
License-Expression: Apache-2.0
License-File: LICENSE.txt
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.12
Provides-Extra: lint
Requires-Dist: ruff>=0.15.10; extra == 'lint'
Provides-Extra: test
Requires-Dist: pytest-cov>=7.1.0; extra == 'test'
Requires-Dist: pytest>=9.0.3; extra == 'test'
Provides-Extra: type
Requires-Dist: mypy>=1.20.1; extra == 'type'
Description-Content-Type: text/markdown

# finance-dag: a finance focused DAG library for Python

[![Test status](https://github.com/tinamou8/finance-dag/workflows/CI/badge.svg)](https://github.com/tinamou8/finance-dag/actions)
[![PyPI package](https://badge.fury.io/py/finance-dag.svg)](https://pypi.python.org/pypi/finance-dag)
[![Docs](https://readthedocs.org/projects/finance-dag/badge/?version=latest)](https://finance-dag.readthedocs.io/en/latest/)

## Introduction

finance-dag is a Python library for managing Directed Acyclic Graphs (DAGs) specifically built for financial data workflows, such as portfolio rebalancing and risk calculations.

## Installing

Requires Python 3.12+. Download and install the latest release:

```bash
pip install finance-dag
```

## Quick Start

Define your financial logic using the `ReactiveMixin` and decorate your nodes with `@node`. Dependencies are resolved automatically.

```python
from fdag import ReactiveMixin, node


class Portfolio(ReactiveMixin):
    @node
    def node_total_value(self) -> float:
        return self.node_cash() + self.node_equity()

    @node
    def node_cash(self) -> float:
        return 1000.0

    @node
    def node_equity(self) -> float:
        return 5000.0


if __name__ == "__main__":
    portfolio = Portfolio()

    # Calculates cash, equity, and total_value automatically
    print("Total Value:", portfolio.node_total_value())  # 6000.0

    # Cached access (instantaneous)
    print("Cached Value:", portfolio.node_total_value())

    # Changing value invalidates a base node; cascades to dependent nodes
    portfolio.node_equity = 3000

    # Recalculates total_value on next access
    print("Recalculated Value:", portfolio.node_total_value())  # 4000.0
```

## [Documentation](https://finance-dag.readthedocs.io/en/latest/)

- [Changelog](https://finance-dag.readthedocs.io/en/latest/changelog.html)

## Features

- Application Modeling: model relationships between entities in a straight-forward way
- Dependency Tracking: automatically infers and tracks dependencies between nodes
- Caching and Recalculation: caches computed values, invalidates only affected dependent nodes, and recomputes them when needed
- Graph Evaluation: eagerly evaluates static parts of the graph while lazily computing reactive nodes on demand

## License

This project is licensed under the Apache License, Version 2.0. See `LICENSE.txt` for the full text.
