Build Lots
build_lotsBuild the lot inventory per account and every disposal with basis, gain and holding period. PREMIUM (license).
Methods: fifo (the default rule when no specific identification is made, Treas. Reg. 1.1012-1(j)), lifo, hifo, or specific_id via a row's specific_lots {lot_id: qty}. Typical input {"ledger": , "method": "hifo", "transfers": } returns {"disposals": [{"row": "cb9", "asset": "BTC", "qty": "0.5", "proceeds": "31000.00", "basis": "20000.00", "gain": "11000.00", "term": "long", ...}], "open_lots": [...], "summary": {"short_term": {...}, "long_term": {...}}}. Fees: a cash purchase's fee joins basis; a sale's or exchange's fee reduces the amount realized (1.1001-7); a network fee paid in the transferred asset is a disposal of those units (transfer_fee_policy dispose) unless you choose ignore. Transfers between your own accounts move lots with their basis and acquisition date. Use once ledger_lint reports no errors. Not tax advice: it applies the stated rules to your rows and shows its work. Errors: on invalid, missing, or malformed input this tool never raises a protocol error — it returns {"error": ""} (for example {"error": "method must be fifo, lifo, hifo or specific_id"}). Every call is read-only and idempotent, so after correcting the input it is always safe to retry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ledger | Yes | canonical rows. | |
| method | No | fifo, lifo, hifo or specific_id (rows without specific_lots fall back to fifo). | fifo |
| tax_year | No | when set, only disposals in that calendar year are returned (the inventory still runs from the start). | |
| transfers | No | pairs from match_transfers ({"out": id, "in": id, ...}); empty to auto-match with the defaults. | |
| on_missing_lots | No | error (default), or zero_basis for lenient mode - disposals beyond the lots held get zero basis and unmatched transfer_out rows simply leave the inventory, each flagged. | error |
| transfer_fee_policy | No | dispose (default) or ignore for network fees paid in the transferred asset. | dispose |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||