zfin/docs/reference/cli/import.md

4.5 KiB

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) [-y]

Each run replaces the target portfolio file with lots drawn from the export:

  • Fidelity and Schwab exports are per-position, so each (account, symbol) becomes one synthetic lot. Per-buy history is lost; git serves as the file-level history.
  • Wells Fargo exports list every tax lot, so each WF lot becomes a lot with its real trade date and cost. One WF file covers every account in the household.

Re-import merge: when the target already exists, lots still present in the new export keep their prior note:: and every hand-edited field (ticker::, label::, price::, price_ratio::, drip::, ...), so git diff flags only genuine brokerage changes. A lot whose export row has no buy date (every Fidelity/Schwab position, and a Wells Fargo Intra-Day fund) also keeps its prior open_date and open_price; new ones get an open_date::1970-01-01 sentinel. Disappeared positions are dropped.

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 <XLS> Wells Fargo positions spreadsheet (- for stdin). See below.
-y, --yes Don't prompt before overwriting an existing file.

Account resolution needs an accounts.srf next to the target with institution:: + account_number:: entries matching the export; import refuses to write when an export account is unmapped.

A target that doesn't exist yet is created in the current directory, so run a first import from the portfolio's own directory.

Wells Fargo

On the WF site, download the positions spreadsheet with Download Type "Portfolio-Expanded Detail", Portfolio View "Positions", for all brokerage accounts. It saves as WFA_Portfolio_Positions_*.xls.

  • "Portfolio-Collapsed Detail" has no per-lot rows; import rejects it.
  • Each row names its account as *1234; map it with institution::wells_fargo,account_number::1234.
  • Cash is one lot per account: cash balance, sweep, and accrued interest combined, matching WF's own cash total.

Direct-indexing accounts

An account flagged direct_indexing:bool:true in accounts.srf churns too much to track lot by lot (a tax-loss-harvesting sleeve, a mechanical rotation strategy). Import never writes its individual holdings. Instead the account lives as one proxy lot that you seed once by hand in the target file: a ticker:: alias to a fund that tracks the account, e.g.

symbol::DI-ROTH,ticker::VTI,shares:num:1000,open_date::2025-01-02,open_price:num:250,account::Sample Roth IRA,note::direct indexing proxy

On every import, the proxy is carried forward unchanged except for price_ratio, which is set so that shares x the ticker's close x price_ratio equals the account's securities in the export. The close used is the export's own price date (Wells Fargo's "Priced as of" date; today for other sources). The account's cash still imports as a normal cash lot, and the summary reports each re-pricing.

  • Any share count works; pick open_price so shares x open_price is the account's cost basis if you want gain/loss to mean something.
  • Import refuses, with a ready-to-paste line, when the account has no stock lot or more than one in the target file, and when the proxy cannot be priced (no shares, no close for its ticker, or an account that now holds only cash).

Example

zfin -p portfolio_managed.srf import --fidelity ~/Downloads/Portfolio_Positions.csv
zfin -p portfolio_wells_fargo.srf import --wells-fargo ~/Downloads/WFA_Portfolio_Positions_100326_1247.xls

See also

  • audit -- reconcile an existing portfolio against an export instead of replacing it.
  • Map your accounts -- the institution/number mapping import needs.

CLI command reference