get_gold_price
Retrieve gold prices from Vietnam's stock market for specific dates and sources like SJC or BTMC, returning data in JSON or dataframe format.
Instructions
Get gold price from stock market
Args:
date: str = None (if None, return today's price. Format: YYYY-MM-DD)
source: Literal['SJC', 'BTMC'] = 'SJC' (source to get gold price)
output_format: Literal['json', 'dataframe'] = 'json'
Returns:
pd.DataFrame
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | ||
| source | No | SJC | |
| output_format | No | json |
Implementation Reference
- src/vnstock_mcp/server.py:621-648 (handler)The handler function for the 'get_gold_price' tool. It is decorated with @server.tool(), serving as both implementation and registration. Handles parameters for date, source (SJC/BTMC), and output format, delegating to vnstock library helpers for data fetching.@server.tool() def get_gold_price( date: str = None, source: Literal["SJC", "BTMC"] = "SJC", output_format: Literal["json", "dataframe"] = "json", ): # pyright: ignore[reportUndefinedVariable] # noqa: F821 """ Get gold price from stock market Args: date: str = None (if None, return today's price. Format: YYYY-MM-DD) source: Literal['SJC', 'BTMC'] = 'SJC' (source to get gold price) output_format: Literal['json', 'dataframe'] = 'json' Returns: pd.DataFrame """ if date: price = sjc_gold_price(date=date) if output_format == "json": return price.to_json(orient="records", force_ascii=False) else: return price else: price = sjc_gold_price() if source == "SJC" else btmc_goldprice() if output_format == "json": return price.to_json(orient="records", force_ascii=False) else: return price