# Portfolio P/L Calculator

Calculate profit and loss across long or short positions from pasted entry and current prices, with fees, tax estimates, sorting, and portfolio totals.

## Run it

- **CLI:** `gizza tool portfolio-pnl "Name, Quantity, Entry, Current, Fees, Dividends, Days, Side
AAPL, 50, 150, 187.50, 9.99
TSLA, 10, 250, 220
GME, 100, 40, 25, 5, 0, 60, short"`
- **Web:** https://gizza.ai/tools/portfolio-pnl/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/portfolio-pnl/tool.json

## Inputs

- `positions` — Positions _(field)_
- `side` — Default side _(field)_
- `fee_percent` — Percent fee _(field)_
- `tax_rate` — Tax rate _(field)_
- `sort` — Sort rows _(field)_
- `currency` — Currency symbol _(field)_

## Output

- P/L report (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `positions` — Positions
- `side` — Default side
- `fee_percent` — Percent fee
- `tax_rate` — Tax rate
- `sort` — Sort rows
- `currency` — Currency symbol

Example: `https://gizza.ai/tools/portfolio-pnl/?positions=Name%2C%20Quantity%2C%20Entry%2C%20Current%2C%20Fees%2C%20Dividends%2C%20Days%2C%20Side%0AAAPL%2C%2050%2C%20150%2C%20187.50%2C%209.99%0ATSLA%2C%2010%2C%20250%2C%20220%0AGME%2C%20100%2C%2040%2C%2025%2C%205%2C%200%2C%2060%2C%20short&side=long&fee_percent=0&tax_rate=0&sort=input&currency=%24`

---

## About this tool

Paste positions from a spreadsheet or broker export and calculate portfolio profit and loss locally. Each row is `name, quantity, entry price, current price` with optional flat fees, dividends, days held, and a `long` or `short` side. The report shows cost basis, market value, net P/L, return percentage, fee-adjusted break-even prices, winners/losers, and optional tax estimates.

Worked example:

```text
AAPL, 50, 150, 187.50, 9.99
TSLA, 10, 250, 220
```

With a 15% tax rate, the report nets the winning and losing positions together before estimating tax. A negative quantity or a trailing `short` marks a short position; otherwise rows use the selected default side.

Limits and edge cases: the tool does not fetch live market prices, value currencies, or provide investment advice. It reads the prices you supply, accepts up to 5,000 positions, rejects negative prices, treats flat fees as costs, and uses the optional tax rate only on a positive portfolio-level net gain.

## FAQ

<details>
<summary>What columns can I paste?</summary>

Use `name, quantity, entry price, current price` as the first four columns. Optional trailing columns are flat fees, dividends or income collected, days held, and a `long` or `short` side word. Tab-separated rows work too, which is useful when prices contain thousands separators.

</details>

<details>
<summary>Does it download current prices?</summary>

No. This is an offline calculator: every current price comes from the text you paste. That keeps results deterministic and avoids sending portfolio data to a price API.

</details>

<details>
<summary>How are fees and taxes handled?</summary>

A row-level flat fee is subtracted from that position. The percent fee setting is applied to both the entry notional and the current notional for every row. The tax estimate is applied only after gains and losses are netted at the portfolio level, and only when the net result is positive.

</details>

<details>
<summary>Can I calculate short positions?</summary>

Yes. Add `short` to the end of a row, choose short as the default side, or enter a negative quantity. Short rows gain when the current price is lower than the entry price, and their break-even price includes fees just like long rows.

</details>

## Related tools

- [Fiscal Quarter Mapper](https://gizza.ai/tools/fiscal-quarter-mapper/): Append fiscal quarter and fiscal year columns to a CSV date column for a fiscal year starting in any month. Paste a table and map every row in your browser.
- [Age encrypt](https://gizza.ai/tools/age-encrypt/): Encrypt small text into an ASCII-armored age ciphertext with a passphrase or native X25519 recipients.
- [Compound Interest Calculator](https://gizza.ai/tools/compound-interest-calculator/): Compute savings future value with compound interest, optional deposits, APY, total interest and a year-by-year schedule.
- [ECDSA secp256k1 sign & verify](https://gizza.ai/tools/ecdsa-secp256k1/): Generate secp256k1 keypairs and sign or verify messages with ECDSA (the Bitcoin/Ethereum curve). RFC 6979 deterministic, DER + compact — in your browser.
- [ECDSA sign](https://gizza.ai/tools/ecdsa-sign/): Sign a message with an ECDSA private key (NIST P-256 or P-384) and get a DER or raw r||s signature in base64 and hex, in your browser. Nothing is uploaded.
