# `zfin import`

Synthesize a portfolio file from a brokerage positions export. Designed
for managed accounts (direct-indexing baskets, accounts you don't track
at lot granularity).

```
Usage: zfin -p <PORTFOLIO> import (--fidelity FILE | --schwab FILE | --wells-fargo FILE [--account NAME]) [-y]
```

Each run **replaces** the target portfolio file with synthetic lots --
one per (account, symbol) -- drawn from the export. Per-buy history is
lost; git serves as the file-level history.

**Re-import merge:** when the target already exists, lots still present
in the new export keep their prior `open_date`, `open_price`, and
`note::`, so trailing-return and ST/LT classifications stay stable and
`git diff` flags only genuine brokerage changes. New positions get an
`open_date::1970-01-01` sentinel; disappeared positions are dropped.
Hand-edited fields (`price::`, `ticker::`) are **not** preserved.

## Options

| Flag                     | Effect                                                                               |
|--------------------------|--------------------------------------------------------------------------------------|
| `-p, --portfolio <FILE>` | Target file (a single concrete path, not a glob). **Required.**                      |
| `--fidelity <CSV>`       | Fidelity positions CSV.                                                              |
| `--schwab <CSV>`         | Schwab per-account positions CSV.                                                    |
| `--wells-fargo <FILE>`   | Wells Fargo positions paste (`-` for stdin).                                         |
| `--account <NAME>`       | (Wells Fargo only) account to attribute lots to; must match an `accounts.srf` entry. |
| `-y, --yes`              | Don't prompt before overwriting an existing file.                                    |

Account resolution needs an [`accounts.srf`](../config/accounts-srf.md)
next to the target with `institution::` + `account_number::` entries
matching the export; import refuses to write when an export account is
unmapped.

## Example

```bash
zfin -p portfolio_managed.srf import --fidelity ~/Downloads/Portfolio_Positions.csv
```

## See also

- [`audit`](audit.md) -- reconcile an existing portfolio against an export instead of replacing it.
- [Map your accounts](../../guides/set-up-accounts.md) -- the institution/number mapping import needs.

---

[CLI command reference](index.md)
