get_loan_rate_data
Retrieve benchmark loan rate data for A-share market analysis. Specify date ranges and formats to access historical lending rate information.
Instructions
Benchmark loan rates.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_loan_rate_data"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | No | ||
| end_date | No | ||
| limit | No | ||
| format | No | markdown |
Implementation Reference
- src/tools/macroeconomic.py:33-39 (handler)The primary MCP tool handler for 'get_loan_rate_data'. It is decorated with @app.tool() for automatic registration and delegates execution to the use case layer with standardized error handling via run_tool_with_handling.
@app.tool() def get_loan_rate_data(start_date: Optional[str] = None, end_date: Optional[str] = None, limit: int = 250, format: str = "markdown") -> str: """Benchmark loan rates.""" return run_tool_with_handling( lambda: fetch_loan_rate_data(active_data_source, start_date=start_date, end_date=end_date, limit=limit, format=format), context="get_loan_rate_data", ) - mcp_server.py:55-55 (registration)The call to register_macroeconomic_tools which defines and registers the macroeconomic tools, including get_loan_rate_data, to the FastMCP app instance.
register_macroeconomic_tools(app, active_data_source) - src/use_cases/macroeconomic.py:16-20 (helper)Use case helper that fetches loan rate data from the data source, applies validation and formatting, and returns formatted output.
def fetch_loan_rate_data(data_source: FinancialDataSource, *, start_date: Optional[str], end_date: Optional[str], limit: int, format: str) -> str: validate_output_format(format) df = data_source.get_loan_rate_data(start_date=start_date, end_date=end_date) meta = {"dataset": "loan_rate", "start_date": start_date, "end_date": end_date} return format_table_output(df, format=format, max_rows=limit, meta=meta) - src/data_source_interface.py:104-105 (schema)Abstract method in FinancialDataSource interface defining the expected signature for loan rate data retrieval.
def get_loan_rate_data(self, start_date: Optional[str] = None, end_date: Optional[str] = None) -> pd.DataFrame: """Fetches benchmark loan rates.""" - src/baostock_data_source.py:668-670 (helper)Concrete implementation in BaostockDataSource that fetches loan rate data via Baostock API using the shared _fetch_macro_data helper.
def get_loan_rate_data(self, start_date: Optional[str] = None, end_date: Optional[str] = None) -> pd.DataFrame: """Fetches benchmark loan rates using Baostock.""" return _fetch_macro_data(bs.query_loan_rate_data, "Loan Rate", start_date, end_date)