get_dupont_data
Retrieve quarterly DuPont analysis data for A-share stocks to assess financial performance through return on equity decomposition.
Instructions
Quarterly Dupont analysis data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| year | Yes | ||
| quarter | Yes | ||
| limit | No | ||
| format | No | markdown |
Implementation Reference
- src/tools/financial_reports.py:71-77 (handler)The primary MCP tool handler for 'get_dupont_data', decorated with @app.tool(). It invokes the fetch_dupont_data use case wrapped in error handling and logging.@app.tool() def get_dupont_data(code: str, year: str, quarter: int, limit: int = 250, format: str = "markdown") -> str: """Quarterly Dupont analysis data.""" return run_tool_with_handling( lambda: fetch_dupont_data(active_data_source, code=code, year=year, quarter=quarter, limit=limit, format=format), context=f"get_dupont_data:{code}:{year}Q{quarter}", )
- mcp_server.py:52-52 (registration)Invocation of the registration function that registers the financial_reports tools, including get_dupont_data, to the FastMCP app.register_financial_report_tools(app, active_data_source)
- Use case helper that performs input validation, fetches raw DuPont data from the data source, and formats it for output.def fetch_dupont_data(data_source: FinancialDataSource, *, code: str, year: str, quarter: int, limit: int, format: str) -> str: validate_year(year) validate_quarter(quarter) validate_output_format(format) df = data_source.get_dupont_data(code=code, year=year, quarter=quarter) return _format_financial_df(df, code=code, year=year, quarter=quarter, dataset="Dupont", format=format, limit=limit)
- src/baostock_data_source.py:433-435 (helper)Concrete implementation in BaostockDataSource that calls the Baostock query_dupont_data API via a shared financial data fetcher.def get_dupont_data(self, code: str, year: str, quarter: int) -> pd.DataFrame: """Fetches quarterly DuPont analysis data using Baostock.""" return _fetch_financial_data(bs.query_dupont_data, "DuPont Analysis", code, year, quarter)
- src/data_source_interface.py:154-156 (helper)Abstract method definition in the FinancialDataSource interface, defining the contract for DuPont data retrieval.@abstractmethod def get_dupont_data(self, code: str, year: str, quarter: int) -> pd.DataFrame: pass