calculate_peg_ratio
Calculates PEG ratio for A-share stocks using current PE and latest YoY net profit growth, handling cases where earnings are negative or growth data is unavailable.
Instructions
Calculate PEG = current PE_TTM / G, with G the latest published YoY net profit growth.
PE is the latest available quote; G is the most recently disclosed YoY
growth, returned as growth_period (statDate) and growth_period_type
(Q1/H1/9M/FY). baostock's YOYNI is a ratio (0.1858 = +18.58% YoY); PEG
uses the percent number (18.58).
PEG is undefined and returns peg=None when:
PE == 0 (no TTM earnings data: index / non-equity, not loss-making)
PE < 0 (loss-making company; PE has no valuation meaning)
no growth report has been published yet (fresh IPO / data delay)
YoY growth <= 0 (PEG is a growth-stock metric; declining earnings yield a negative or nonsensical value that LLMs would misread as cheap)
Args: code: Stock code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |