Skip to content
Back to skills

Net Present Value

ASecurity

Sub-skill of financial-analysis: Net Present Value (+5).

  • 17 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 9, 2026
datapythongoapi

Works with

  • api

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add vamseeachanta/workspace-hub --skill net-present-value --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Net Present Value?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Net Present Value
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vamseeachanta-net-present-value/badge)](https://www.skillsdirectory.com/skills/vamseeachanta-net-present-value)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: financial-analysis-net-present-value
description: 'Sub-skill of financial-analysis: Net Present Value (+5).'
version: 1.0.0
category: engineering
type: reference
scripts_exempt: true
---

# Net Present Value (+5)

## Net Present Value


```python
def calculate_npv(cash_flows, discount_rate, initial_investment=0):
    """Calculate Net Present Value."""
    pv = sum([cf / (1 + discount_rate)**i
              for i, cf in enumerate(cash_flows, 1)])
    return pv - initial_investment
```

## WACC Calculation


```python
def calculate_wacc(equity_weight, debt_weight, cost_of_equity,
                   cost_of_debt, tax_rate):
    """Calculate Weighted Average Cost of Capital."""
    return (equity_weight * cost_of_equity +
            debt_weight * cost_of_debt * (1 - tax_rate))
```

## Sharpe Ratio


```python
import numpy as np

def sharpe_ratio(returns, risk_free_rate, periods_per_year=252):
    """Calculate Sharpe Ratio."""
    excess_returns = returns - risk_free_rate / periods_per_year
    return np.sqrt(periods_per_year) * (excess_returns.mean() /
                                        excess_returns.std())
```

## Black-Scholes Option Pricing


```python
from scipy.stats import norm
import numpy as np

def black_scholes(S, K, T, r, sigma, option_type='call'):
    """Black-Scholes option pricing."""
    d1 = (np.log(S / K) + (r + 0.5 * sigma**2) * T) / (sigma * np.sqrt(T))
    d2 = d1 - sigma * np.sqrt(T)
    if option_type == 'call':
        return S * norm.cdf(d1) - K * np.exp(-r * T) * norm.cdf(d2)
    return K * np.exp(-r * T) * norm.cdf(-d2) - S * norm.cdf(-d1)
```

## Portfolio Metrics


```python
import pandas as pd
import numpy as np
from typing import Dict

def calculate_portfolio_metrics(
    returns: pd.Series,
    weights: np.ndarray,
    risk_free_rate: float = 0.02,
    periods_per_year: int = 252

*See sub-skills for full details.*

## Data Validation


```python
import pandas as pd

def validate_financial_data(data: pd.DataFrame) -> None:
    """Validate financial data quality and completeness."""
    if data.isnull().any().any():
        missing_cols = data.columns[data.isnull().any()].tolist()
        raise ValueError(f"Missing values in columns: {missing_cols}")
    price_cols = [col for col in data.columns if 'price' in col.lower()]
    for col in price_cols:
        if (data[col] < 0).any():
            raise ValueError(f"Negative values in price column: {col}")
    if 'volume' in data.columns and (data['volume'] < 0).any():
        raise ValueError("Negative volume detected")
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.