sell
Records a completed broker sale in the local ledger, reducing holding units and crediting cost-currency cash; OpenInvest books the transaction and never places real orders.
Instructions
Record a sell in the local ledger: reduces the position's units (average cost unchanged) and credits cash in the holding's cost currency. Bookkeeps a trade already executed at the user's broker — openInvest never places real orders.
Confirm symbol, units, and price with the user before calling; this moves ledger cash.
Args: symbol: yfinance ticker of an existing holding. units: Quantity sold; must be > 0. price: Execution price per unit, in the holding's cost currency. idempotency_key: Reuse the same key when retrying this exact call; recorded once.
Returns: Updated position summary, or {"status": "error", "error": ...}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| price | Yes | Execution price per unit, in the holding's cost currency. | |
| units | Yes | Quantity sold; must be > 0. | |
| symbol | Yes | yfinance ticker of an existing holding. | |
| 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 |