buy
Record a buy in the local ledger to add to an existing position or open a new one, with weighted-average cost calculation. Bookkeeps trades the user already placed with their broker.
Instructions
Record a buy in the local ledger: adds to an existing position with weighted-average cost, or opens a new position for an unseen symbol. This bookkeeps a trade the user already placed with their broker — openInvest never places real orders.
Confirm symbol, units, and price with the user before calling; this moves ledger cash.
Args:
symbol: yfinance ticker (e.g. "AAPL", "510300.SS", "GC=F").
units: Quantity bought; must be > 0.
price: Execution price per unit, in currency.
currency: Currency of price (default "CNY").
kind: Asset kind tag, e.g. "equity", "etf", "commodity".
unit_label: Human display label for units (default "股", i.e. shares).
Returns: Updated position summary, or {"status": "error", "error": ...}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | Asset kind tag, e.g. 'equity', 'etf', 'commodity'. | equity |
| price | Yes | Execution price per unit, in `currency`. | |
| units | Yes | Quantity bought; must be > 0. | |
| symbol | Yes | yfinance ticker, e.g. 'AAPL', '510300.SS', 'GC=F'. | |
| currency | No | Currency of `price`, e.g. 'CNY', 'USD', 'AUD'. | CNY |
| unit_label | No | Human display label for units (default '股', i.e. shares). | 股 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |