record_dividend
Book dividends or interest already received by crediting ledger cash net of withholding tax; positions stay unchanged and cash is booked as account return, not a deposit.
Instructions
Record a dividend (or interest) the user already received: credits ledger cash by amount - tax_withheld, positions unchanged. It counts as account return (inside NAV), not as a deposit. Bookkeeping only — openInvest never moves money.
Confirm symbol, gross amount, withholding tax, and the date with the user before calling; this moves ledger cash. A symbol that is neither held nor in the ledger is rejected (typo guard).
Args:
amount: Gross amount before withholding tax; must be > 0.
currency: Currency of the cash credited.
symbol: Ticker (required for dividends; optional for interest).
kind: "dividend" (default) or "interest".
tax_withheld: Tax withheld at source; credited cash = amount - tax_withheld.
reinvest: DRIP — buy more symbol with the net amount.
reinvest_price: Price per unit for the reinvestment (default: stored raw close).
trade_date: YYYY-MM-DD the cash arrived (default today).
note: Free-text note.
idempotency_key: Reuse the same key when retrying this exact call; recorded once.
Returns: Cash credited and new balance, or {"status": "error", "error": ...}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | 'dividend' (default) or 'interest' (money-market / cash-account interest). | dividend |
| note | No | Free-text note stored with the ledger row. | |
| amount | Yes | Gross amount before withholding tax (for kind='interest': the interest credited); must be > 0. | |
| symbol | No | yfinance ticker the dividend belongs to (required for kind='dividend'; optional for interest = account-level). | |
| currency | Yes | Currency the cash was credited in, e.g. 'CNY', 'USD', 'AUD'. | |
| reinvest | No | DRIP: use the net cash to buy more of `symbol` (adds a second ledger row, source='drip'). The holding must exist and be in `currency`. | |
| trade_date | No | Date the event happened, YYYY-MM-DD (default: today). Account performance books it on this date, so pass the real date when back-filling history. | |
| tax_withheld | No | Tax already withheld at source (kind='dividend' only); cash credited = amount - tax_withheld. | |
| reinvest_price | No | Reinvestment price per unit. Omit to use the stored raw close for the date (run `backfill_raw_close` first). | |
| idempotency_key | No | Optional client-generated key (e.g. a UUID4). When retrying this SAME call after a timeout or an unknown result, reuse the same key: the ledger records it once and later calls return {"status": "duplicate"} without touching cash or holdings. Only the key is compared, not the arguments — a different order (other symbol/units/price/amount) needs a new key, or it is silently treated as the retry. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |