Metadata-Version: 2.1
Name: pyCorpFin
Version: 0.1.0
Summary: Corporate Finance calculations library with AI agent integration
Author-email: Rahul V Rao <rahulvrao.star@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/rahulvrao28/pyCorpFin
Project-URL: Documentation, https://github.com/rahulvrao28/pyCorpFin/blob/main/README.md
Project-URL: Repository, https://github.com/rahulvrao28/pyCorpFin
Keywords: finance,corporate finance,IRR,NPV,XIRR,ai-agents,langchain
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: langchain
Requires-Dist: langchain>=0.1.0; extra == "langchain"
Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.0.20; extra == "langgraph"
Provides-Extra: all
Requires-Dist: langchain>=0.1.0; extra == "all"
Requires-Dist: langchain-core>=0.1.0; extra == "all"
Requires-Dist: langgraph>=0.0.20; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"

# pyCorpFin

A Python library for corporate finance calculations with built-in AI agent integration for LangChain, LangGraph, and other agentic frameworks.

## Features

- **Core Finance Functions**: NPV, IRR, MIRR, XIRR, EMI calculations
- **AI Agent Ready**: Pre-built tools for LangChain and LangGraph
- **Zero Dependencies**: Core library works without external packages
- **Pure Python**: No compiled extensions required

## Installation

### Basic Installation
```bash
pip install pyCorpFin
```

### With LangChain Support
```bash
pip install pyCorpFin[langchain]
```

### With LangGraph Support
```bash
pip install pyCorpFin[langgraph]
```

### With All AI Features
```bash
pip install pyCorpFin[all]
```

## Quick Start

### Direct Usage
```python
from pyCorpFin import IRR, calculate_xirr
from datetime import datetime

# Calculate IRR
cashflows = [-1000, 300, 400, 500]
irr = IRR(cashflows)
print(f"IRR: {irr:.2%}")

# Calculate XIRR
dates = [datetime(2023, 1, 1), datetime(2023, 6, 1), 
         datetime(2023, 12, 1), datetime(2024, 6, 1)]
xirr = calculate_xirr(cashflows, dates)
print(f"XIRR: {xirr:.2%}")
```

### With LangChain
```python
from pyCorpFin.tools import get_langchain_tools
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI

# Get finance tools
tools = get_langchain_tools()

# Create agent
llm = ChatOpenAI(temperature=0)
agent = initialize_agent(
    tools, 
    llm, 
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True
)

# Use the agent
result = agent.run(
    "Calculate the IRR for an investment of $10,000 that returns "
    "$3,000 per year for 4 years"
)
```

### With LangGraph
```python
from langgraph.prebuilt import create_react_agent
from pyCorpFin.tools import get_langchain_tools
from langchain_openai import ChatOpenAI

tools = get_langchain_tools()
model = ChatOpenAI(model="gpt-4")

agent = create_react_agent(model, tools)

response = agent.invoke({
    "messages": [("user", "What's the EMI on a $100,000 loan at 8% for 20 years?")]
})
```

## API Reference

### Core Functions

- `IRR(cashflows, guess=0.1)` - Internal Rate of Return
- `calculate_mirr(cashflows, finance_rate, reinvest_rate)` - Modified IRR
- `calculate_xirr(cashflows, dates, guess=0.1)` - Extended IRR
- `presentValue(cf, r, n)` - Present Value
- `futureValue(cf, r, n)` - Future Value
- `emi(PV, r, n)` - Equated Monthly Installment

## License

MIT License
