Implementation:24mlight A Share investment Agent valuation agent
| Knowledge Sources | |
|---|---|
| Domains | Finance, Valuation |
| Last Updated | 2026-10-10 14:00 GMT |
Overview
Concrete tool for dual-method intrinsic valuation using DCF and Buffett Owner Earnings to assess stock fair value against market cap, provided by the A_Share_investment_Agent repository.
Description
The valuation_agent function computes two intrinsic value estimates: DCF (5-year projection with terminal value) and Owner Earnings (Buffett method with declining growth and margin of safety). It compares both against market capitalization to determine a valuation gap and generates a bullish/bearish/neutral signal.
The module also includes three standalone helper functions: calculate_owner_earnings_value, calculate_intrinsic_value, and calculate_working_capital_change.
Usage
Import when you need to:
- Estimate intrinsic value of a stock using DCF and Owner Earnings methods
- Run as a parallel node in the LangGraph workflow (after market_data_agent)
Decorated with @agent_endpoint("valuation", "估值分析师...").
Code Reference
Source Location
- Repository: A_Share_investment_Agent
- File: src/agents/valuation.py
- Lines: L12-247 (agent L12-100, helpers L103-247)
Signature
@agent_endpoint("valuation", "估值分析师,使用DCF和所有者收益法评估公司内在价值")
def valuation_agent(state: AgentState) -> dict:
"""Responsible for valuation analysis"""
def calculate_owner_earnings_value(
net_income: float,
depreciation: float,
capex: float,
working_capital_change: float,
growth_rate: float = 0.05,
required_return: float = 0.15,
margin_of_safety: float = 0.25,
num_years: int = 5,
) -> float:
"""Buffett owner earnings valuation with declining growth model."""
def calculate_intrinsic_value(
free_cash_flow: float,
growth_rate: float = 0.05,
discount_rate: float = 0.10,
terminal_growth_rate: float = 0.02,
num_years: int = 5,
) -> float:
"""Standard DCF valuation with 5-year projection and terminal value."""
def calculate_working_capital_change(
current_working_capital: float,
previous_working_capital: float,
) -> float:
"""Calculate absolute change in working capital."""
Import
from src.agents.valuation import valuation_agent, calculate_owner_earnings_value, calculate_intrinsic_value, calculate_working_capital_change
I/O Contract
Inputs (valuation_agent)
| Name | Type | Required | Description |
|---|---|---|---|
| state | AgentState | Yes | Reads data["financial_metrics"][0], data["financial_line_items"][0..1], data["market_cap"] |
Outputs (valuation_agent)
| Name | Type | Description |
|---|---|---|
| messages | list | HumanMessage with {signal, confidence, reasoning} |
| reasoning | dict | {dcf_analysis: {signal, details}, owner_earnings_analysis: {signal, details}} |
Usage Examples
DCF Valuation Standalone
from src.agents.valuation import calculate_intrinsic_value
value = calculate_intrinsic_value(
free_cash_flow=1000000.0,
growth_rate=0.08,
discount_rate=0.10,
terminal_growth_rate=0.03,
num_years=5,
)
print(f"Intrinsic value: ${value:,.2f}")
Owner Earnings Valuation Standalone
from src.agents.valuation import calculate_owner_earnings_value
value = calculate_owner_earnings_value(
net_income=500000.0,
depreciation=100000.0,
capex=50000.0,
working_capital_change=20000.0,
growth_rate=0.10,
required_return=0.15,
margin_of_safety=0.25,
)