aipa-fundamentals
Developed by AIPriceAction. More data and documentation at https://aipriceaction.com
Cập nhật: 2026-06-10
What is aipa
aipa is an AI-powered financial analysis CLI for Vietnamese stocks, cryptocurrencies, and global assets. The aipa fundamentals commands fetch company profiles, financial ratios, and ranking/screening data — no LLM, no API key required.
Installation
Use uvx — no install needed. On the first call of each session, use uvx aipa-cli@latest to refresh the cache. For all subsequent calls, use plain uvx aipa-cli (fast, cached).
# All calls — fast cached execution (uvx automatically checks for updates)
uvx aipa-cli fundamentals info VCB
uvx aipa-cli fundamentals ratios VCB --latest
# Fallback: pip (if uv is not available)
pip install aipa-cli
aipa fundamentals info VCB
# Fallback: system pip (if pip fails due to PEP 668)
python3 -m pip install aipa-cli --break-system-packages
aipa fundamentals info VCB
# If neither uv nor pip are installed, install uv first:
curl -LsSf https://astral.sh/uv/install.sh | sh
All command examples in this skill use aipa for brevity. Replace aipa with uvx aipa-cli if not installed globally.
Keeping the CLI Updated
The aipa CLI is actively developed with frequent improvements. Always prefer uvx aipa-cli over aipa. When using uvx:
- Use plain
uvx for fast cached execution:
uvx aipa-cli fundamentals rank --sort-by roe
- Fallback on failure — if a command fails with a schema or missing argument error, retry with
@latest:
uvx aipa-cli fundamentals rank --sort-by roe (add @latest if the command fails)
If aipa is installed globally via pip, update before each session:
pip install --upgrade aipa-cli
The agent should prefer uvx aipa-cli for all commands. Only fall back to aipa if uvx is unavailable.
Version Gate
aipa fundamentals requires aipa-cli >= 0.1.48. Verify before use:
uvx aipa-cli --version
If < 0.1.48, upgrade: uvx aipa-cli@latest or pip install --upgrade aipa-cli.
Environment Variables
None required. aipa fundamentals reads from cached vn.zip (downloads ~15-20 MB on first call, cached locally after).
aipa-config — Settings Management
aipa config get # show all settings (JSON, api_key redacted)
aipa config get use_sma # show single value: true or false
aipa config get language # show language: en or vn
aipa config set use_sma false # switch all commands to EMA
aipa config set use_sma true # switch to SMA
aipa config set language vn # change language
aipa config path # show path to settings file
| Setting |
Default |
Values |
Description |
use_sma |
true |
true / false |
true = SMA, false = EMA. Controls MA type for all commands. CLI flags (--sma, --ema) override per-invocation. |
language |
vn |
en / vn |
Output language for analyze and deep-research |
MA Type Priority: CLI flag (--sma/--ema) > settings.json (use_sma) > default (sma).
IMPORTANT: Before any analysis session, run aipa config get use_sma to check the current MA type setting. Do NOT assume SMA — the user may have switched to EMA. All MA references in your analysis must match the active setting (SMA or EMA).
Available Data Sources
- Vietnamese stocks (
source: vn): VIC, VCB, FPT, HPG, VNM, MBB, TCB, CTG, VPB, HDB, etc. — this is the primary source for fundamental data
- Cryptocurrencies (
source: crypto): BTCUSDT, ETHUSDT, BNBUSDT, SOLUSDT, etc.
- Global/Yahoo (
source: global/yahoo): AAPL, TSLA, NVDA, SPY, etc.
- SJC Gold (
source: sjc): SJC gold prices
Fundamental data (info, ratios, rank, screen) is currently available for Vietnamese stocks only. For non-VN tickers (crypto, global stocks), see the Non-VN Fallback section below.
Predefined Watchlists
The CLI has built-in watchlists for common ticker groups.
| Name |
Tickers |
Count |
| VN30 |
ACB, BID, BSR, CTG, FPT, GAS, GVR, HDB, HPG, LPB, MBB, MSN, MWG, PLX, SAB, SHB, SSB, SSI, STB, TCB, TPB, VCB, VHM, VIB, VIC, VJC, VNM, VPB, VRE, VPL |
30 |
| VINGROUP |
VIC, VHM, VRE, VPL |
4 |
| TM |
GEX, GEE, VIX, EIB, VGC, IDC |
6 |
| MASAN |
MSN, MCH, MSR, MML, VCF, VSN, NET |
7 |
| INDEX |
VNINDEX, VN30, VN30F1M, VN100, VNMIDCAP, VNSMALLCAP, VNALLSHARE, VNXALLSHARE, VNFIN, HNX30, VNREAL, VNENE, VNMITECH, VNUTI, VNCONS, VNCOND, VNHEAL, VNIND, VNFINLEAD, VNFINSELECT, VNDIAMOND, VNDIVIDEND |
22 |
| CROSS |
VNINDEX, ^GSPC, GC=F, SJC-GOLD, KC=F, BZ=F, BTCUSDT |
7 |
aipa watchlist ls # list all
aipa watchlist get VN30 # get tickers
aipa watchlist set MYWATCH FPT VCB # create custom
aipa watchlist rm MYWATCH # delete custom
Use watchlists as ticker sources for rank and screen:
aipa fundamentals rank --watchlist VN30 --sort-by roe
aipa fundamentals screen --watchlist VN30 --pe-max 20 --roe-min 0.10
Nhóm Chủ Lực (Core Market Sectors - VN Market Only)
When analyzing or ranking VN tickers, be aware of these core sector groupings:
- Nhóm Ngân hàng (Banking): VCB, BID, CTG, TCB, MBB, ACB, VPB, HDB, SHB, TPB, VIB, SSB, MSB, STB, LPB, EIB.
- Nhóm Bất động sản (Real Estate): VIC, VHM, VRE, VPL, DIG, CEO, L14, TCH, HHS, VGC, IDC.
- Nhóm Chứng khoán (Securities): SSI, VND, HCM, VCI, SHS, VIX, VDS.
- Nhóm Trụ cột / Sản xuất & Bán lẻ (Blue-chips / Core Economy): HPG, HSG, NKG, FPT, MWG, GAS, GVR, PLX, BSR, MSN, VNM, SAB.
- Nhóm Hệ sinh thái (Corporate Ecosystems):
- Họ Vingroup: VIC, VHM, VRE, VPL.
- Họ Bầu Thụy: STB, LPB, THD, HAG.
- Họ Gelex ("Tuấn Mượt"): GEX, GEE, VIX, VGC, EIB, IDC.
- Họ Hoàng Huy: TCH, HHS.
- Họ A7: DIG, CEO, L14.
- Họ TTC: SBT, GEG, VDS.
- Họ Masan: MSN, MCH, MSR, MML, VCF, VSN, NET.
- Họ Viettel: VGI, CTR, VTP.
(Note: This classification applies only to the Vietnamese market.)
Overview
This skill provides a structured fundamental analysis framework for Vietnamese stocks. It answers 11 key questions every investor should ask before holding a stock long-term.
The supervisor decomposes the request into sector-based batches and spawns parallel subagents. Each subagent answers the 11 questions for its assigned tickers, producing written insights with sector-relative comparisons.
11 Fundamental Questions
| # |
Question |
Purpose |
| 1 |
Dividend + EPS — what does each share earn and pay? |
Dividend yield, EPS per share |
| 2 |
P/B + D/E — bankruptcy scenario, asset backing |
Book value/CP, P/B, Debt/Equity |
| 3 |
P/E + PEG vs sector — cheap or expensive considering growth? |
P/E, PEG ratio vs sector average |
| 4 |
ROE + ROA — capital efficiency |
How well capital generates returns |
| 5 |
Financial safety — debt, liquidity; Banks: NPL, CAR, LDR, CIR |
Balance sheet health |
| 6 |
Margins — gross, net, is the business model profitable? |
Gross Margin, Net Margin |
| 7 |
EV/EBITDA — total enterprise valuation vs sector |
Enterprise-level valuation comparison |
| 8 |
ROIC + Asset Turnover — how well does management allocate capital? |
ROIC, Asset Turnover, operational efficiency |
| 9 |
EBITDA — earnings quality & cash generation proxy |
EBITDA absolute, EBITDA vs sector, P/CF context |
| 10 |
Market cap + CASA (banks) — scale and funding advantage |
Company size, liquidity; CASA for banks |
| 11 |
Summary — strengths, weaknesses, long-term hold? |
Overall assessment, conclusion |
Commands Reference
aipa fundamentals info — Company Profile
aipa fundamentals info TICKER
| Flag |
Default |
Description |
TICKER |
— |
Ticker symbol (required) |
--source |
auto |
Data source |
Output: Industry, market cap, current price, outstanding shares, top shareholders, officers.
aipa fundamentals ratios — Financial Ratios
aipa fundamentals ratios TICKER [options]
| Flag |
Default |
Description |
TICKER |
— |
Ticker symbol (required) |
--latest |
off |
Latest period only (fastest) |
--no-yearly |
off |
Include quarterly reports |
--yearly |
off |
Yearly reports only |
--year YEAR |
— |
Specific year (e.g. 2024) |
--period PERIOD |
— |
Specific period like "2024 Q2" |
--category |
all |
valuation, profitability, leverage, liquidity, bank, efficiency |
--json |
off |
Raw JSON output |
Categories:
| Category |
Fields |
| Valuation |
PE, PB, PS, EV/EBITDA, Price/CashFlow, Dividend Yield, Market Cap |
| Profitability |
ROE, ROA, ROIC, Gross Margin, After-Tax Margin, Pre-Tax Margin, EBIT Margin, NIM |
| Efficiency |
Asset Turnover, Fixed Asset Turnover, Cash Cycle, DSO, DIO, DPO |
| Leverage |
Debt/Equity, Financial Leverage, Equity/Liabilities, Equity/Loans, Equity/Total Asset |
| Liquidity |
Current Ratio, Quick Ratio, Cash Ratio |
| Bank |
NPL, LDR, CAR, CASA, CIR, Non-Interest Income, Deposit/Loans Growth, LLR ratios |
aipa fundamentals rank — Rank by Field (50+ fields)
aipa fundamentals rank [TICKERS...] [options]
| Flag |
Default |
Description |
tickers |
all VN |
Positional ticker symbols |
--sort-by |
roe |
Field to rank by |
--direction |
desc |
desc or asc |
--limit |
10 |
Max results |
--latest |
off |
Latest period only |
--yearly |
off |
Yearly reports only |
--year YEAR |
— |
Specific year |
--period PERIOD |
— |
Specific period like "2024 Q2" |
--watchlist |
— |
Use watchlist as ticker source |
--source |
auto |
Data source |
Sortable fields: pe, pb, ps, ev_to_ebitda, price_to_cash_flow, dividend_yield, market_cap, roe, roa, roic, gross_margin, after_tax_profit_margin, pre_tax_profit_margin, ebit_margin, net_interest_margin, ebit, ebitda, asset_turnover, fixed_asset_turnover, debt_to_equity, financial_leverage, equity_to_liabilities, current_ratio, quick_ratio, cash_ratio, cash_cycle, npl, ldr_loan_deposit_ratio, car, casa_ratio, cir, cost_to_income, non_and_interest_income, deposit_growth, loans_growth, outstanding_shares, employees, current_price, and more.
Ticker source resolution: --watchlist NAME > positional tickers > default (all VN).
aipa fundamentals screen — Multi-Criteria Screening
aipa fundamentals screen [TICKERS...] [options]
| Flag |
Default |
Description |
tickers |
all VN |
Positional ticker symbols |
--sort-by |
roe |
Field to rank by |
--direction |
desc |
Sort direction |
--limit |
50 |
Max results (1–500) |
--latest |
off |
Latest period only |
--yearly |
off |
Yearly reports only |
--year YEAR |
— |
Specific year |
--period PERIOD |
— |
Specific period like "2024 Q2" |
--watchlist |
— |
Use watchlist as ticker source |
--source |
auto |
Data source |
--pe-min / --pe-max |
— |
PE range filter |
--pb-min / --pb-max |
— |
PB range filter |
--roe-min / --roe-max |
— |
ROE range filter |
--roa-min / --roa-max |
— |
ROA range filter |
--dividend-yield-min / --dividend-yield-max |
— |
Dividend yield range |
--debt-to-equity-max |
— |
Max Debt/Equity |
--npl-max |
— |
Max NPL (banks) |
--car-min |
— |
Min CAR (banks) |
--cir-max |
— |
Max CIR (banks) |
--market-cap-min / --market-cap-max |
— |
Market cap range |
--industry |
— |
Industry filter (substring, case-insensitive) |
Filter behavior: All filters optional, inclusive ranges, missing data excluded, --industry is case-insensitive substring.
aipa ticker-list — Discover Tickers
aipa ticker-list [--source vn] [--group GROUP] [--compact]
Use this to discover available tickers before analysis:
aipa ticker-list --source vn --group NGAN_HANG # banking sector
aipa ticker-list --source vn --compact # all VN symbols comma-separated
Sector-Level Commands (run once per batch)
# Q1: Dividend + EPS
aipa fundamentals rank TICKERS --sort-by dividend_yield --direction desc
# Note: EPS not available in rank. Get from ratios --category valuation or derive from market_cap/outstanding_shares/pe.
# Q2: P/B + D/E
aipa fundamentals rank TICKERS --sort-by pb --direction asc
aipa fundamentals rank TICKERS --sort-by debt_to_equity --direction asc
# Q3: P/E vs sector
aipa fundamentals rank TICKERS --sort-by pe --direction asc
# Q4: ROE
aipa fundamentals rank TICKERS --sort-by roe --direction desc
# Q7: EV/EBITDA vs sector
aipa fundamentals rank TICKERS --sort-by ev_to_ebitda --direction asc
# Q8: ROIC + Asset Turnover
aipa fundamentals rank TICKERS --sort-by roic --direction desc
aipa fundamentals rank TICKERS --sort-by asset_turnover --direction desc
# Q9: EBITDA (earnings quality proxy)
aipa fundamentals rank TICKERS --sort-by ebitda --direction desc
# Q10: Market Cap
aipa fundamentals rank TICKERS --sort-by market_cap --direction desc
# Q10: CASA (Banks only — field name is casa_ratio)
aipa fundamentals rank TICKERS --sort-by casa_ratio --direction desc
# Screen entire sector (for Q3 — P/E filter)
aipa fundamentals screen --industry "SECTOR_NAME" --sort-by pe
Per-Ticker Detail (Tier 1 & 2)
# All ratios (covers Q1-Q7, Q10)
aipa fundamentals ratios TICKER --latest
# Q5: Debt & liquidity (non-banks)
aipa fundamentals ratios TICKER --category leverage --latest
# Q5 + Q10: Bank-specific metrics (Banks only)
aipa fundamentals ratios TICKER --category bank --latest
# Q4 + Q6: Efficiency & profit margins
aipa fundamentals ratios TICKER --category profitability --latest
# Q8: ROIC + Asset Turnover
aipa fundamentals ratios TICKER --category profitability --latest
aipa fundamentals ratios TICKER --category efficiency --latest
# Q9: EBITDA
aipa fundamentals ratios TICKER --category profitability --latest
# Company info (Tier 1 only)
aipa fundamentals info TICKER
Tier X — use sector-level rank data only
Do NOT run ratios individually. Use data from sector-level rank to assign quickly.
Subagent Pipeline
Step 1 — Supervisor: Decompose into batches
Group tickers by sector and spawn one subagent per batch. Use aipa ticker-list --source vn --group GROUP to discover tickers, or accept a user-provided list.
Example batch decomposition (NOT exhaustive — build dynamically):
| Batch |
Sector |
Tickers |
Special |
| 1 |
Banking |
VCB, BID, CTG, TCB, MBB, ACB, VPB, ... |
--category bank |
| 2 |
Real Estate |
VIC, VHM, VRE, VPL, DIG, ... |
--category leverage |
| 3 |
Securities |
SSI, VND, HCM, VCI, SHS, ... |
--category leverage |
| 4 |
Oil & Gas |
PLX, BSR, GAS, GVR, PVD, ... |
--category leverage |
| 5 |
Others |
HPG, FPT, VNM, MWG, HSG, ... |
Mixed |
The supervisor should dynamically build batches based on the actual request (e.g., "banking fundamentals" → single batch; "all VN30" → 3-4 batches by sector).
Step 2 — Parallel Workers
Each subagent receives its batch of tickers and follows this workflow:
- Sector-level rank — run all
rank commands once for the entire batch
- Per-ticker detail — run
ratios for Tier 1 (major) tickers, skip Tier X
- Answer 11 questions — write prose answers using data from steps 1-2
- Output — use
template.md format for each ticker
Step 3 — Aggregation
Collect all subagent results, cross-reference rankings, and produce a unified sector summary with top picks by fundamental strength.
Fundamental Comparison Workflow
When comparing fundamentals across multiple tickers, follow this workflow. Do NOT call aipa fundamentals ratios TICKER --latest for each ticker individually — use rank and screen first.
Step 1: Side-by-side ranking (mandatory)
Run at least 2 perspectives relevant to the sector:
# Profitability
aipa fundamentals rank VCB BID CTG TCB MBB --sort-by roe
# Valuation
aipa fundamentals rank VCB BID CTG TCB MBB --sort-by pe --direction asc
# Bank health
aipa fundamentals rank VCB BID CTG TCB MBB --sort-by npl --direction asc
aipa fundamentals rank VCB BID CTG TCB MBB --sort-by car --direction desc
Step 2: Screen for quality (optional but recommended)
aipa fundamentals screen VCB BID CTG TCB MBB --npl-max 0.015 --roe-min 0.15 --sort-by roe
Step 3: Individual deep dive (only for shortlisted tickers)
aipa fundamentals ratios VCB --latest
aipa fundamentals ratios VCB --category bank --latest
aipa fundamentals info VCB
Why: rank and screen return all tickers in a single comparative table — far more efficient than N separate ratios calls.
Output Template
Use template.md (bundled with this skill) as the standard output format. Copy the template section and paste it into the target ticker file, replacing all [giá trị] placeholders with actual data from aipa fundamentals commands.
Template location: template.md (same directory as this SKILL.md)
Insertion rules:
- Insert ABOVE
## 📌 Trạng thái hiện tại in the target ticker file
- Replace ALL
[giá trị] placeholders with real data
- Write answers in prose (1-3 sentences), not just numbers
Interpreting Output
The CLI outputs to two streams:
- stdout: The fundamental data or ranking result. This is what you should use.
- stderr: Status messages with structured markers.
Status Markers (stderr)
| Marker |
Meaning |
[build] |
Data fetching status and timing |
[error] |
Error message |
[done] |
Fetch complete, includes total time |
Attribution
When presenting data or analysis to the user, always include:
- English: "Data by AIPriceAction | AI-powered analysis — may contain errors. Verify before trading."
- Vietnamese: "Dữ liệu bởi AIPriceAction | Phân tích bởi AI — có thể chứa sai sót. Vui lòng kiểm chứng trước khi giao dịch."
Do NOT say "analysis provided by AIPriceAction" or "phân tích được cung cấp bởi AIPriceAction". AIPriceAction provides the data; the analysis is AI-generated and may be inaccurate.
When to Use This Skill vs Others
| User Request |
Use |
| "Fundamental analysis for VCB" |
This skill (aipa-fundamentals) |
| "Phân tích cơ bản ngân hàng" |
This skill (aipa-fundamentals) |
| "Compare VCB TCB MBB PE, ROE, NPL" |
This skill (aipa-fundamentals) |
| "Rank banks by ROE" |
aipa fundamentals rank --sort-by roe (this skill) |
| "Screen for low PE banks" |
aipa fundamentals screen (this skill) |
| "Company profile for FPT" |
aipa fundamentals info FPT (this skill) |
| "Analyze VCB" (technical) |
aipa-analyze |
| "Get price data for VCB" |
aipa-data |
| "Research the banking sector deeply" |
aipa-research |
| "Top gainers / losers" |
aipa performers (aipa-data) |
Key rule: fundamentals → aipa-fundamentals, AI technical analysis → aipa-analyze, raw numbers → aipa-data, comprehensive report → aipa-research.
Data Usage Policy (CRITICAL)
- NEVER generate, guess, estimate, or hallucinate any numbers — PE, PB, ROE, EPS, dividend yield, or any financial data. Only use data from tool results or user-provided context
- NEVER mention a specific number unless it appears in your tool results or user-provided context
- Use tools proactively — call
aipa fundamentals rank or screen BEFORE answering fundamental questions
- If data is missing for any metric, write "(không có dữ liệu)" or "(no data available)" instead of guessing
- For non-VN tickers using web search, numbers come from web sources — always cite the source and note they may be stale or inaccurate
Non-VN Ticker Fallback (Crypto, Global Stocks)
aipa fundamentals only supports Vietnamese stocks. For non-VN tickers (e.g., AAPL, NVDA, BTCUSDT), fall back to web search to answer the 11 questions as best as possible.
Workflow
- Identify the ticker source — if it's not a VN stock, skip all
aipa fundamentals commands
- Use web search to find fundamental data for each question
- Search queries should target authoritative sources (Yahoo Finance, Seeking Alpha, CoinGecko, company investor relations, SEC filings, etc.)
- Answer the 11 questions using whatever data is available — some questions may not apply (e.g., Q10 CASA for non-banks is already skipped; Q2 P/B for crypto may not apply)
- Always cite the source for every number (e.g., "Source: Yahoo Finance", "Source: CoinGecko")
- Mark unavailable data clearly — write "(no data available)" instead of guessing
Example web search queries
# For a global stock like AAPL
# Q1: Dividend yield + EPS
web search: "AAPL Apple dividend yield 2025" "AAPL EPS 2025"
# Q2: P/B, D/E
web search: "AAPL Apple price to book ratio 2025" "AAPL debt to equity ratio"
# Q3: P/E vs sector
web search: "AAPL P/E ratio 2025" "tech sector average P/E ratio 2025"
# Q4: ROE, ROA
web search: "AAPL return on equity ROE 2025" "AAPL return on assets ROA"
# Q5: Debt, liquidity
web search: "AAPL Apple balance sheet current ratio 2025"
# Q8: ROIC, Asset Turnover
web search: "AAPL Apple ROIC 2025" "AAPL asset turnover ratio"
# Q9: EBITDA
web search: "AAPL Apple EBITDA 2025"
# Q10: Market cap
web search: "AAPL Apple market cap 2025"
# For crypto like BTCUSDT
# Q1: No dividend/EPS — skip or note "N/A for crypto"
# Q3: P/E does not apply to crypto — skip
# Q9: EBITDA — N/A for crypto
# Q10: Market cap
web search: "Bitcoin BTC market cap 2025"
# Q11: Summary only — based on available on-chain/market metrics
Adaptation rules per question
| Question |
Crypto |
Global Stock |
| Q1 (Dividend/EPS) |
N/A — mark as "không áp dụng cho crypto" |
Search for dividend yield + EPS |
| Q2 (P/B, D/E) |
N/A — no book value |
Search for P/B, debt/equity |
| Q3 (P/E, PEG) |
N/A — no earnings |
Search for P/E, PEG, sector average |
| Q4 (ROE/ROA) |
N/A — no equity |
Search for ROE, ROA |
| Q5 (Debt safety) |
N/A — no debt |
Search for balance sheet, current ratio |
| Q6 (Margins) |
N/A |
Search for gross/net margin |
| Q7 (EV/EBITDA) |
N/A |
Search for EV/EBITDA |
| Q8 (ROIC/Asset Turnover) |
N/A — no equity |
Search for ROIC, asset turnover |
| Q9 (EBITDA) |
N/A |
Search for EBITDA, EBITDA margin |
| Q10 (Market cap, CASA) |
Search for market cap |
Search for market cap; CASA = banks only |
| Q11 (Summary) |
Based on market position, network metrics |
Based on all available data |
Calculate Metrics with Python — No Hallucinated Numbers
Symptom: AI writes "P/E sector average is ~10" or "ROE is top 20%" based on visual scanning of rank output instead of computing actual values.
Rule: Before writing ANY numerical claim in fundamental analysis (sector average, percentile rank, book value, DuPont decomposition), you MUST compute it using aipa fundamentals | python3 pipe. NEVER estimate or guess.
Sector Average from rank Output
Useful for Q3 (P/E vs sector), Q7 (EV/EBITDA vs sector), Q10 (market cap comparison).
uvx aipa-cli fundamentals rank VCB BID CTG TCB MBB ACB VPB HDB --sort-by pe 2>/dev/null | python3 -c "
import sys
values = []
for line in sys.stdin:
parts = line.split()
if parts and parts[0].isdigit() and len(parts) >= 3:
try:
val = float(parts[2].replace('%', ''))
values.append(val)
except ValueError:
pass
if values:
avg = sum(values) / len(values)
s = sorted(values)
print(f'n={len(values)} | avg={avg:.1f} | min={s[0]:.1f} | median={s[len(s)//2]:.1f} | max={s[-1]:.1f}')
"
Tip: Use median (not average) when the data contains outliers (e.g., P/E of 296,613 for a company with near-zero earnings). Median is more robust for sector comparison.
Ticker Percentile in Sector
Useful for Q3, Q4, Q7 — "VCB ROE is in the top X% of the banking sector".
uvx aipa-cli fundamentals rank VCB BID CTG TCB MBB ACB VPB HDB SHB TPB VIB SSB MSB STB --sort-by roe 2>/dev/null | python3 -c "
import sys
ticker = 'VCB'
rank = None
total = 0
for line in sys.stdin:
parts = line.split()
if parts and parts[0].isdigit():
total += 1
if len(parts) >= 3 and parts[1] == ticker:
rank = int(parts[0])
if rank and total:
pct = (total - rank) / (total - 1) * 100
print(f'{ticker}: rank {rank}/{total} (top {100-pct:.0f}%)')
"
Book Value per Share (from P/B + Market Cap)
Useful for Q2 — "if the company liquidates, shareholders get X per share".
uvx aipa-cli fundamentals ratios VCB --category valuation --latest 2>/dev/null | python3 -c "
import sys
data = {}
for line in sys.stdin:
parts = line.split()
if len(parts) >= 2 and not line.strip().startswith('===') and not line.strip().startswith('Total') and parts[0] not in ('Valuation:',):
raw = parts[-1].replace('%', '').replace(',', '')
try:
data[parts[0]] = float(raw)
except ValueError:
pass
pb = data.get('PB')
market_cap = data.get('Market')
if pb and pb > 0 and market_cap:
bv = market_cap / pb
print(f'P/B: {pb:.2f} | Market Cap: {market_cap/1e12:.1f}T VND | Book Value (total equity): {bv/1e12:.1f}T VND')
else:
print(f'Missing data: PB={pb} Market Cap={market_cap}')
"
DuPont ROE Decomposition
Useful for Q4 — break down ROE into its three drivers: profitability, efficiency, and leverage.
uvx aipa-cli fundamentals ratios FPT --latest 2>/dev/null | python3 -c "
import sys
data = {}
for line in sys.stdin:
parts = line.split()
if len(parts) >= 2 and not line.strip().startswith('===') and not line.strip().startswith('Total') and parts[0] not in ('Valuation:', 'Profitability:', 'Efficiency:', 'Leverage:', 'Liquidity:', 'Bank:'):
raw = parts[-1].replace('%', '').replace(',', '')
try:
data[parts[0]] = float(raw) / 100 if '%' in parts[-1] else float(raw)
except ValueError:
pass
nm = data.get('After-Tax')
at = data.get('Asset')
de = data.get('Financial')
roe_reported = data.get('ROE')
if nm is not None and at is not None and de is not None:
em = 1 + de
dupont = nm * at * em
print(f'Net Margin: {nm*100:.1f}% | Asset Turnover: {at:.2f}x | Equity Multiplier: {em:.2f}x (1 + D/E {de:.2f})')
if roe_reported:
gap = abs(dupont - roe_reported)
print(f'DuPont ROE: {dupont*100:.1f}% | Reported ROE: {roe_reported*100:.1f}% | Gap: {gap*100:.1f}pp')
else:
print(f'DuPont ROE: {dupont*100:.1f}%')
print(f'Decomposition: {nm*100:.1f}% x {at:.2f} x {em:.2f} = {dupont*100:.1f}%')
if nm > 0.15: print(f' -> Profitability driver: STRONG (NM > 15%)')
elif nm > 0.05: print(f' -> Profitability driver: MODERATE')
else: print(f' -> Profitability driver: WEAK')
if at > 1.0: print(f' -> Efficiency driver: STRONG (AT > 1.0)')
elif at > 0.5: print(f' -> Efficiency driver: MODERATE')
else: print(f' -> Efficiency driver: WEAK')
if em > 2.0: print(f' -> Leverage driver: HIGH (EM > 2.0)')
elif em > 1.0: print(f' -> Leverage driver: MODERATE')
else: print(f' -> Leverage driver: LOW')
else:
print(f'Incomplete data: NM={nm} AT={at} D/E={de}')
"
Note: DuPont ROE may differ from reported ROE by a few percentage points due to quarterly data, minority interest, or different data source definitions. A gap of < 5pp is normal. The value is in understanding the relative strength of each driver, not exact reproduction.
Mandatory rule: If you cannot verify a number with a pipe command, do NOT write it in any file. Use the actual computed value, rounded to 1 decimal place for ratios and 0.1% for percentages.
Answering Principles
- Read data → answer in prose, not just show tables of numbers
- Compare with sector — "cheap/low" means nothing without sector context
- Use sector averages from
screen or rank results for comparison
- Q10 (CASA): Only answer CASA for bank tickers. For non-banks, only answer Market Cap and skip CASA
- Q11: Summary must include strengths, weaknesses, and final conclusion
- Never hallucinate numbers — only use values from tool output or web search results (with source citation)
- For non-VN tickers: Use web search to answer the 11 questions. Mark N/A questions as "không áp dụng" rather than skipping silently. Always cite web sources.
Tips for AI Agents
No API key or LLM needed: aipa fundamentals reads from cached data. Works without OPENAI_API_KEY.
Auto-uppercase: Ticker symbols are automatically uppercased. vcb, tcb all work.
rank before ratios: When comparing multiple tickers, always start with rank to get a single comparative table. Only use ratios for individual deep dives on shortlisted tickers.
screen for filtering: Use screen when you need to filter by quality criteria (PE < 15, ROE > 15%, NPL < 2%, etc.) before analyzing individually.
--watchlist for groups: Use --watchlist VN30 instead of typing all 30 tickers. Works with both rank and screen.
--industry for sector filtering: Use --industry "ngân hàng" to filter by industry substring (case-insensitive) in screen.
--category for focused ratios: Use --category bank for bank-specific fields (NPL, CAR, CASA, CIR), --category leverage for debt metrics, --category profitability for margins and efficiency.
--latest for speed: Use --latest to get only the most recent period. Much faster than pulling all historical periods.
--json for parsing: Use --json flag on ratios when you need structured data for programmatic use.
Use aipa ticker-list to discover tickers: When you need to know what tickers are available in a sector, use aipa ticker-list --source vn --group NGAN_HANG. Add --compact for a comma-separated list.
Fundamental context enhances technical analysis: When combining with aipa-analyze, fundamental metrics provide valuation context (PE=8 breakout vs PE=30 breakout have different risk profiles) and financial health context (high NPL + bearish technicals = strong sell signal).
1---2name: aipa-fundamentals3description: Fundamental analysis workflow for Vietnamese stocks using the aipa CLI. Use this skill when the user explicitly asks for fundamental analysis, "phân tích cơ bản", financial ratios (PE, PB, ROE, ROA, NPL, CAR, CASA, CIR), valuation metrics (EPS, EV/EBITDA, dividend yield), company profiles, or sector-wide fundamental screening and ranking. This skill spawns parallel subagents to analyze tickers by sector using a structured 11-question framework. For technical analysis (VPA, Wyckoff), use aipa-analyze instead. For raw data without analysis, use aipa-data.4---56# aipa-fundamentals78Developed by AIPriceAction. More data and documentation at https://aipriceaction.com910> Cập nhật: 2026-06-101112---1314## What is aipa1516`aipa` is an AI-powered financial analysis CLI for Vietnamese stocks, cryptocurrencies, and global assets. The `aipa fundamentals` commands fetch company profiles, financial ratios, and ranking/screening data — no LLM, no API key required.1718## Installation1920Use `uvx` — no install needed. On the **first call of each session**, use `uvx aipa-cli@latest` to refresh the cache. For all subsequent calls, use plain `uvx aipa-cli` (fast, cached).2122```bash23# All calls — fast cached execution (uvx automatically checks for updates)24uvx aipa-cli fundamentals info VCB2526uvx aipa-cli fundamentals ratios VCB --latest2728# Fallback: pip (if uv is not available)29pip install aipa-cli30aipa fundamentals info VCB3132# Fallback: system pip (if pip fails due to PEP 668)33python3 -m pip install aipa-cli --break-system-packages34aipa fundamentals info VCB3536# If neither uv nor pip are installed, install uv first:37curl -LsSf https://astral.sh/uv/install.sh | sh38```3940All command examples in this skill use `aipa` for brevity. Replace `aipa` with `uvx aipa-cli` if not installed globally.4142## Keeping the CLI Updated4344The aipa CLI is actively developed with frequent improvements. **Always prefer `uvx aipa-cli` over `aipa`**. When using `uvx`:45461. **Use plain `uvx` for fast cached execution:**47 `uvx aipa-cli fundamentals rank --sort-by roe`482. **Fallback on failure** — if a command fails with a schema or missing argument error, retry with `@latest`:49 `uvx aipa-cli fundamentals rank --sort-by roe` (add `@latest` if the command fails)5051If `aipa` is installed globally via `pip`, update before each session:5253```bash54pip install --upgrade aipa-cli55```5657The agent should prefer `uvx aipa-cli` for all commands. Only fall back to `aipa` if `uvx` is unavailable.5859## Version Gate6061> `aipa fundamentals` requires **aipa-cli >= 0.1.48**. Verify before use:62> ```bash63> uvx aipa-cli --version64> ```65> If < 0.1.48, upgrade: `uvx aipa-cli@latest` or `pip install --upgrade aipa-cli`.6667## Environment Variables6869None required. `aipa fundamentals` reads from cached `vn.zip` (downloads ~15-20 MB on first call, cached locally after).7071### aipa-config — Settings Management7273```bash74aipa config get # show all settings (JSON, api_key redacted)75aipa config get use_sma # show single value: true or false76aipa config get language # show language: en or vn77aipa config set use_sma false # switch all commands to EMA78aipa config set use_sma true # switch to SMA79aipa config set language vn # change language80aipa config path # show path to settings file81```8283| Setting | Default | Values | Description |84|---|---|---|---|85| `use_sma` | `true` | `true` / `false` | `true` = SMA, `false` = EMA. Controls MA type for all commands. CLI flags (`--sma`, `--ema`) override per-invocation. |86| `language` | `vn` | `en` / `vn` | Output language for analyze and deep-research |8788**MA Type Priority:** CLI flag (`--sma`/`--ema`) > `settings.json` (`use_sma`) > default (`sma`).8990> **IMPORTANT:** Before any analysis session, run `aipa config get use_sma` to check the current MA type setting. Do NOT assume SMA — the user may have switched to EMA. All MA references in your analysis must match the active setting (SMA or EMA).9192## Available Data Sources9394- **Vietnamese stocks** (`source: vn`): VIC, VCB, FPT, HPG, VNM, MBB, TCB, CTG, VPB, HDB, etc. — **this is the primary source for fundamental data**95- **Cryptocurrencies** (`source: crypto`): BTCUSDT, ETHUSDT, BNBUSDT, SOLUSDT, etc.96- **Global/Yahoo** (`source: global/yahoo`): AAPL, TSLA, NVDA, SPY, etc.97- **SJC Gold** (`source: sjc`): SJC gold prices9899Fundamental data (info, ratios, rank, screen) is currently available for **Vietnamese stocks only**. For non-VN tickers (crypto, global stocks), see the **Non-VN Fallback** section below.100101### Predefined Watchlists102103The CLI has built-in watchlists for common ticker groups.104105| Name | Tickers | Count |106|---|---|---|107| **VN30** | ACB, BID, BSR, CTG, FPT, GAS, GVR, HDB, HPG, LPB, MBB, MSN, MWG, PLX, SAB, SHB, SSB, SSI, STB, TCB, TPB, VCB, VHM, VIB, VIC, VJC, VNM, VPB, VRE, VPL | 30 |108| **VINGROUP** | VIC, VHM, VRE, VPL | 4 |109| **TM** | GEX, GEE, VIX, EIB, VGC, IDC | 6 |110| **MASAN** | MSN, MCH, MSR, MML, VCF, VSN, NET | 7 |111| **INDEX** | VNINDEX, VN30, VN30F1M, VN100, VNMIDCAP, VNSMALLCAP, VNALLSHARE, VNXALLSHARE, VNFIN, HNX30, VNREAL, VNENE, VNMITECH, VNUTI, VNCONS, VNCOND, VNHEAL, VNIND, VNFINLEAD, VNFINSELECT, VNDIAMOND, VNDIVIDEND | 22 |112| **CROSS** | VNINDEX, ^GSPC, GC=F, SJC-GOLD, KC=F, BZ=F, BTCUSDT | 7 |113114```bash115aipa watchlist ls # list all116aipa watchlist get VN30 # get tickers117aipa watchlist set MYWATCH FPT VCB # create custom118aipa watchlist rm MYWATCH # delete custom119```120121Use watchlists as ticker sources for `rank` and `screen`:122```bash123aipa fundamentals rank --watchlist VN30 --sort-by roe124aipa fundamentals screen --watchlist VN30 --pe-max 20 --roe-min 0.10125```126127### Nhóm Chủ Lực (Core Market Sectors - VN Market Only)128129When analyzing or ranking VN tickers, be aware of these core sector groupings:130131- **Nhóm Ngân hàng (Banking):** VCB, BID, CTG, TCB, MBB, ACB, VPB, HDB, SHB, TPB, VIB, SSB, MSB, STB, LPB, EIB.132- **Nhóm Bất động sản (Real Estate):** VIC, VHM, VRE, VPL, DIG, CEO, L14, TCH, HHS, VGC, IDC.133- **Nhóm Chứng khoán (Securities):** SSI, VND, HCM, VCI, SHS, VIX, VDS.134- **Nhóm Trụ cột / Sản xuất & Bán lẻ (Blue-chips / Core Economy):** HPG, HSG, NKG, FPT, MWG, GAS, GVR, PLX, BSR, MSN, VNM, SAB.135- **Nhóm Hệ sinh thái (Corporate Ecosystems):**136 - Họ Vingroup: VIC, VHM, VRE, VPL.137 - Họ Bầu Thụy: STB, LPB, THD, HAG.138 - Họ Gelex ("Tuấn Mượt"): GEX, GEE, VIX, VGC, EIB, IDC.139 - Họ Hoàng Huy: TCH, HHS.140 - Họ A7: DIG, CEO, L14.141 - Họ TTC: SBT, GEG, VDS.142 - Họ Masan: MSN, MCH, MSR, MML, VCF, VSN, NET.143 - Họ Viettel: VGI, CTR, VTP.144145*(Note: This classification applies only to the Vietnamese market.)*146147---148149## Overview150151This skill provides a **structured fundamental analysis framework** for Vietnamese stocks. It answers 11 key questions every investor should ask before holding a stock long-term.152153The supervisor decomposes the request into sector-based batches and spawns parallel subagents. Each subagent answers the 11 questions for its assigned tickers, producing written insights with sector-relative comparisons.154155---156157## 11 Fundamental Questions158159| # | Question | Purpose |160|---|---------|---------|161| 1 | Dividend + EPS — what does each share earn and pay? | Dividend yield, EPS per share |162| 2 | P/B + D/E — bankruptcy scenario, asset backing | Book value/CP, P/B, Debt/Equity |163| 3 | P/E + PEG vs sector — cheap or expensive considering growth? | P/E, PEG ratio vs sector average |164| 4 | ROE + ROA — capital efficiency | How well capital generates returns |165| 5 | Financial safety — debt, liquidity; Banks: NPL, CAR, LDR, CIR | Balance sheet health |166| 6 | Margins — gross, net, is the business model profitable? | Gross Margin, Net Margin |167| 7 | EV/EBITDA — total enterprise valuation vs sector | Enterprise-level valuation comparison |168| 8 | ROIC + Asset Turnover — how well does management allocate capital? | ROIC, Asset Turnover, operational efficiency |169| 9 | EBITDA — earnings quality & cash generation proxy | EBITDA absolute, EBITDA vs sector, P/CF context |170| 10 | Market cap + CASA (banks) — scale and funding advantage | Company size, liquidity; CASA for banks |171| 11 | Summary — strengths, weaknesses, long-term hold? | Overall assessment, conclusion |172173---174175## Commands Reference176177### `aipa fundamentals info` — Company Profile178179```bash180aipa fundamentals info TICKER181```182183| Flag | Default | Description |184|---|---|---|185| `TICKER` | — | Ticker symbol (required) |186| `--source` | auto | Data source |187188Output: Industry, market cap, current price, outstanding shares, top shareholders, officers.189190### `aipa fundamentals ratios` — Financial Ratios191192```bash193aipa fundamentals ratios TICKER [options]194```195196| Flag | Default | Description |197|---|---|---|198| `TICKER` | — | Ticker symbol (required) |199| `--latest` | off | Latest period only (fastest) |200| `--no-yearly` | off | Include quarterly reports |201| `--yearly` | off | Yearly reports only |202| `--year YEAR` | — | Specific year (e.g. `2024`) |203| `--period PERIOD` | — | Specific period like `"2024 Q2"` |204| `--category` | all | `valuation`, `profitability`, `leverage`, `liquidity`, `bank`, `efficiency` |205| `--json` | off | Raw JSON output |206207**Categories:**208209| Category | Fields |210|---|---|211| Valuation | PE, PB, PS, EV/EBITDA, Price/CashFlow, Dividend Yield, Market Cap |212| Profitability | ROE, ROA, ROIC, Gross Margin, After-Tax Margin, Pre-Tax Margin, EBIT Margin, NIM |213| Efficiency | Asset Turnover, Fixed Asset Turnover, Cash Cycle, DSO, DIO, DPO |214| Leverage | Debt/Equity, Financial Leverage, Equity/Liabilities, Equity/Loans, Equity/Total Asset |215| Liquidity | Current Ratio, Quick Ratio, Cash Ratio |216| Bank | NPL, LDR, CAR, CASA, CIR, Non-Interest Income, Deposit/Loans Growth, LLR ratios |217218### `aipa fundamentals rank` — Rank by Field (50+ fields)219220```bash221aipa fundamentals rank [TICKERS...] [options]222```223224| Flag | Default | Description |225|---|---|---|226| `tickers` | all VN | Positional ticker symbols |227| `--sort-by` | `roe` | Field to rank by |228| `--direction` | `desc` | `desc` or `asc` |229| `--limit` | `10` | Max results |230| `--latest` | off | Latest period only |231| `--yearly` | off | Yearly reports only |232| `--year YEAR` | — | Specific year |233| `--period PERIOD` | — | Specific period like `"2024 Q2"` |234| `--watchlist` | — | Use watchlist as ticker source |235| `--source` | auto | Data source |236237**Sortable fields:** `pe`, `pb`, `ps`, `ev_to_ebitda`, `price_to_cash_flow`, `dividend_yield`, `market_cap`, `roe`, `roa`, `roic`, `gross_margin`, `after_tax_profit_margin`, `pre_tax_profit_margin`, `ebit_margin`, `net_interest_margin`, `ebit`, `ebitda`, `asset_turnover`, `fixed_asset_turnover`, `debt_to_equity`, `financial_leverage`, `equity_to_liabilities`, `current_ratio`, `quick_ratio`, `cash_ratio`, `cash_cycle`, `npl`, `ldr_loan_deposit_ratio`, `car`, `casa_ratio`, `cir`, `cost_to_income`, `non_and_interest_income`, `deposit_growth`, `loans_growth`, `outstanding_shares`, `employees`, `current_price`, and more.238239**Ticker source resolution:** `--watchlist NAME` > positional `tickers` > default (all VN).240241### `aipa fundamentals screen` — Multi-Criteria Screening242243```bash244aipa fundamentals screen [TICKERS...] [options]245```246247| Flag | Default | Description |248|---|---|---|249| `tickers` | all VN | Positional ticker symbols |250| `--sort-by` | `roe` | Field to rank by |251| `--direction` | `desc` | Sort direction |252| `--limit` | `50` | Max results (1–500) |253| `--latest` | off | Latest period only |254| `--yearly` | off | Yearly reports only |255| `--year YEAR` | — | Specific year |256| `--period PERIOD` | — | Specific period like `"2024 Q2"` |257| `--watchlist` | — | Use watchlist as ticker source |258| `--source` | auto | Data source |259| `--pe-min` / `--pe-max` | — | PE range filter |260| `--pb-min` / `--pb-max` | — | PB range filter |261| `--roe-min` / `--roe-max` | — | ROE range filter |262| `--roa-min` / `--roa-max` | — | ROA range filter |263| `--dividend-yield-min` / `--dividend-yield-max` | — | Dividend yield range |264| `--debt-to-equity-max` | — | Max Debt/Equity |265| `--npl-max` | — | Max NPL (banks) |266| `--car-min` | — | Min CAR (banks) |267| `--cir-max` | — | Max CIR (banks) |268| `--market-cap-min` / `--market-cap-max` | — | Market cap range |269| `--industry` | — | Industry filter (substring, case-insensitive) |270271**Filter behavior:** All filters optional, inclusive ranges, missing data excluded, `--industry` is case-insensitive substring.272273### `aipa ticker-list` — Discover Tickers274275```bash276aipa ticker-list [--source vn] [--group GROUP] [--compact]277```278279Use this to discover available tickers before analysis:280```bash281aipa ticker-list --source vn --group NGAN_HANG # banking sector282aipa ticker-list --source vn --compact # all VN symbols comma-separated283```284285---286287## Sector-Level Commands (run once per batch)288289```bash290# Q1: Dividend + EPS291aipa fundamentals rank TICKERS --sort-by dividend_yield --direction desc292# Note: EPS not available in rank. Get from ratios --category valuation or derive from market_cap/outstanding_shares/pe.293294# Q2: P/B + D/E295aipa fundamentals rank TICKERS --sort-by pb --direction asc296aipa fundamentals rank TICKERS --sort-by debt_to_equity --direction asc297298# Q3: P/E vs sector299aipa fundamentals rank TICKERS --sort-by pe --direction asc300301# Q4: ROE302aipa fundamentals rank TICKERS --sort-by roe --direction desc303304# Q7: EV/EBITDA vs sector305aipa fundamentals rank TICKERS --sort-by ev_to_ebitda --direction asc306307# Q8: ROIC + Asset Turnover308aipa fundamentals rank TICKERS --sort-by roic --direction desc309aipa fundamentals rank TICKERS --sort-by asset_turnover --direction desc310311# Q9: EBITDA (earnings quality proxy)312aipa fundamentals rank TICKERS --sort-by ebitda --direction desc313314# Q10: Market Cap315aipa fundamentals rank TICKERS --sort-by market_cap --direction desc316317# Q10: CASA (Banks only — field name is casa_ratio)318aipa fundamentals rank TICKERS --sort-by casa_ratio --direction desc319320# Screen entire sector (for Q3 — P/E filter)321aipa fundamentals screen --industry "SECTOR_NAME" --sort-by pe322```323324## Per-Ticker Detail (Tier 1 & 2)325326```bash327# All ratios (covers Q1-Q7, Q10)328aipa fundamentals ratios TICKER --latest329330# Q5: Debt & liquidity (non-banks)331aipa fundamentals ratios TICKER --category leverage --latest332333# Q5 + Q10: Bank-specific metrics (Banks only)334aipa fundamentals ratios TICKER --category bank --latest335336# Q4 + Q6: Efficiency & profit margins337aipa fundamentals ratios TICKER --category profitability --latest338339# Q8: ROIC + Asset Turnover340aipa fundamentals ratios TICKER --category profitability --latest341aipa fundamentals ratios TICKER --category efficiency --latest342343# Q9: EBITDA344aipa fundamentals ratios TICKER --category profitability --latest345346# Company info (Tier 1 only)347aipa fundamentals info TICKER348```349350### Tier X — use sector-level rank data only351352Do NOT run `ratios` individually. Use data from sector-level `rank` to assign quickly.353354---355356## Subagent Pipeline357358### Step 1 — Supervisor: Decompose into batches359360Group tickers by sector and spawn one subagent per batch. Use `aipa ticker-list --source vn --group GROUP` to discover tickers, or accept a user-provided list.361362**Example batch decomposition (NOT exhaustive — build dynamically):**363364| Batch | Sector | Tickers | Special |365|-------|--------|---------|---------|366| 1 | Banking | VCB, BID, CTG, TCB, MBB, ACB, VPB, ... | `--category bank` |367| 2 | Real Estate | VIC, VHM, VRE, VPL, DIG, ... | `--category leverage` |368| 3 | Securities | SSI, VND, HCM, VCI, SHS, ... | `--category leverage` |369| 4 | Oil & Gas | PLX, BSR, GAS, GVR, PVD, ... | `--category leverage` |370| 5 | Others | HPG, FPT, VNM, MWG, HSG, ... | Mixed |371372The supervisor should dynamically build batches based on the actual request (e.g., "banking fundamentals" → single batch; "all VN30" → 3-4 batches by sector).373374### Step 2 — Parallel Workers375376Each subagent receives its batch of tickers and follows this workflow:3773781. **Sector-level rank** — run all `rank` commands once for the entire batch3792. **Per-ticker detail** — run `ratios` for Tier 1 (major) tickers, skip Tier X3803. **Answer 11 questions** — write prose answers using data from steps 1-23814. **Output** — use `template.md` format for each ticker382383### Step 3 — Aggregation384385Collect all subagent results, cross-reference rankings, and produce a unified sector summary with top picks by fundamental strength.386387---388389## Fundamental Comparison Workflow390391When comparing fundamentals across multiple tickers, follow this workflow. **Do NOT call `aipa fundamentals ratios TICKER --latest` for each ticker individually** — use `rank` and `screen` first.392393**Step 1: Side-by-side ranking (mandatory)**394395Run at least 2 perspectives relevant to the sector:396397```bash398# Profitability399aipa fundamentals rank VCB BID CTG TCB MBB --sort-by roe400401# Valuation402aipa fundamentals rank VCB BID CTG TCB MBB --sort-by pe --direction asc403404# Bank health405aipa fundamentals rank VCB BID CTG TCB MBB --sort-by npl --direction asc406aipa fundamentals rank VCB BID CTG TCB MBB --sort-by car --direction desc407```408409**Step 2: Screen for quality (optional but recommended)**410411```bash412aipa fundamentals screen VCB BID CTG TCB MBB --npl-max 0.015 --roe-min 0.15 --sort-by roe413```414415**Step 3: Individual deep dive (only for shortlisted tickers)**416417```bash418aipa fundamentals ratios VCB --latest419aipa fundamentals ratios VCB --category bank --latest420aipa fundamentals info VCB421```422423**Why:** `rank` and `screen` return all tickers in a single comparative table — far more efficient than N separate `ratios` calls.424425---426427## Output Template428429Use `template.md` (bundled with this skill) as the standard output format. Copy the template section and paste it into the target ticker file, replacing all `[giá trị]` placeholders with actual data from `aipa fundamentals` commands.430431**Template location:** `template.md` (same directory as this SKILL.md)432433**Insertion rules:**434- Insert ABOVE `## 📌 Trạng thái hiện tại` in the target ticker file435- Replace ALL `[giá trị]` placeholders with real data436- Write answers in prose (1-3 sentences), not just numbers437438---439440## Interpreting Output441442The CLI outputs to two streams:443444- **stdout**: The fundamental data or ranking result. This is what you should use.445- **stderr**: Status messages with structured markers.446447### Status Markers (stderr)448449| Marker | Meaning |450|---|---|451| `[build]` | Data fetching status and timing |452| `[error]` | Error message |453| `[done]` | Fetch complete, includes total time |454455### Attribution456457When presenting data or analysis to the user, always include:458459- **English:** "_Data by [AIPriceAction](https://aipriceaction.com/) | AI-powered analysis — may contain errors. Verify before trading._"460- **Vietnamese:** "_Dữ liệu bởi [AIPriceAction](https://aipriceaction.com/) | Phân tích bởi AI — có thể chứa sai sót. Vui lòng kiểm chứng trước khi giao dịch._"461462Do NOT say "analysis provided by AIPriceAction" or "phân tích được cung cấp bởi AIPriceAction". AIPriceAction provides the **data**; the **analysis** is AI-generated and may be inaccurate.463464---465466## When to Use This Skill vs Others467468| User Request | Use |469|---|---|470| "Fundamental analysis for VCB" | This skill (`aipa-fundamentals`) |471| "Phân tích cơ bản ngân hàng" | This skill (`aipa-fundamentals`) |472| "Compare VCB TCB MBB PE, ROE, NPL" | This skill (`aipa-fundamentals`) |473| "Rank banks by ROE" | `aipa fundamentals rank --sort-by roe` (this skill) |474| "Screen for low PE banks" | `aipa fundamentals screen` (this skill) |475| "Company profile for FPT" | `aipa fundamentals info FPT` (this skill) |476| "Analyze VCB" (technical) | `aipa-analyze` |477| "Get price data for VCB" | `aipa-data` |478| "Research the banking sector deeply" | `aipa-research` |479| "Top gainers / losers" | `aipa performers` (`aipa-data`) |480481Key rule: **fundamentals → `aipa-fundamentals`, AI technical analysis → `aipa-analyze`, raw numbers → `aipa-data`, comprehensive report → `aipa-research`**.482483---484485## Data Usage Policy (CRITICAL)4864871. **NEVER generate, guess, estimate, or hallucinate any numbers** — PE, PB, ROE, EPS, dividend yield, or any financial data. Only use data from tool results or user-provided context4882. **NEVER mention a specific number unless it appears in your tool results or user-provided context**4893. **Use tools proactively** — call `aipa fundamentals rank` or `screen` BEFORE answering fundamental questions4904. **If data is missing** for any metric, write "(không có dữ liệu)" or "(no data available)" instead of guessing4915. **For non-VN tickers using web search**, numbers come from web sources — always cite the source and note they may be stale or inaccurate492493---494495## Non-VN Ticker Fallback (Crypto, Global Stocks)496497`aipa fundamentals` only supports Vietnamese stocks. For non-VN tickers (e.g., AAPL, NVDA, BTCUSDT), fall back to web search to answer the 11 questions as best as possible.498499### Workflow5005011. **Identify the ticker source** — if it's not a VN stock, skip all `aipa fundamentals` commands5022. **Use web search** to find fundamental data for each question5033. **Search queries should target authoritative sources** (Yahoo Finance, Seeking Alpha, CoinGecko, company investor relations, SEC filings, etc.)5044. **Answer the 11 questions using whatever data is available** — some questions may not apply (e.g., Q10 CASA for non-banks is already skipped; Q2 P/B for crypto may not apply)5055. **Always cite the source** for every number (e.g., "Source: Yahoo Finance", "Source: CoinGecko")5066. **Mark unavailable data clearly** — write "(no data available)" instead of guessing507508### Example web search queries509510```bash511# For a global stock like AAPL512# Q1: Dividend yield + EPS513web search: "AAPL Apple dividend yield 2025" "AAPL EPS 2025"514# Q2: P/B, D/E515web search: "AAPL Apple price to book ratio 2025" "AAPL debt to equity ratio"516# Q3: P/E vs sector517web search: "AAPL P/E ratio 2025" "tech sector average P/E ratio 2025"518# Q4: ROE, ROA519web search: "AAPL return on equity ROE 2025" "AAPL return on assets ROA"520# Q5: Debt, liquidity521web search: "AAPL Apple balance sheet current ratio 2025"522# Q8: ROIC, Asset Turnover523web search: "AAPL Apple ROIC 2025" "AAPL asset turnover ratio"524# Q9: EBITDA525web search: "AAPL Apple EBITDA 2025"526# Q10: Market cap527web search: "AAPL Apple market cap 2025"528529# For crypto like BTCUSDT530# Q1: No dividend/EPS — skip or note "N/A for crypto"531# Q3: P/E does not apply to crypto — skip532# Q9: EBITDA — N/A for crypto533# Q10: Market cap534web search: "Bitcoin BTC market cap 2025"535# Q11: Summary only — based on available on-chain/market metrics536```537538### Adaptation rules per question539540| Question | Crypto | Global Stock |541|---|---|---|542| Q1 (Dividend/EPS) | N/A — mark as "không áp dụng cho crypto" | Search for dividend yield + EPS |543| Q2 (P/B, D/E) | N/A — no book value | Search for P/B, debt/equity |544| Q3 (P/E, PEG) | N/A — no earnings | Search for P/E, PEG, sector average |545| Q4 (ROE/ROA) | N/A — no equity | Search for ROE, ROA |546| Q5 (Debt safety) | N/A — no debt | Search for balance sheet, current ratio |547| Q6 (Margins) | N/A | Search for gross/net margin |548| Q7 (EV/EBITDA) | N/A | Search for EV/EBITDA |549| Q8 (ROIC/Asset Turnover) | N/A — no equity | Search for ROIC, asset turnover |550| Q9 (EBITDA) | N/A | Search for EBITDA, EBITDA margin |551| Q10 (Market cap, CASA) | Search for market cap | Search for market cap; CASA = banks only |552| Q11 (Summary) | Based on market position, network metrics | Based on all available data |553554---555556## Calculate Metrics with Python — No Hallucinated Numbers557558**Symptom:** AI writes "P/E sector average is ~10" or "ROE is top 20%" based on visual scanning of `rank` output instead of computing actual values.559560**Rule:** Before writing ANY numerical claim in fundamental analysis (sector average, percentile rank, book value, DuPont decomposition), you MUST compute it using `aipa fundamentals | python3` pipe. NEVER estimate or guess.561562### Sector Average from `rank` Output563564Useful for Q3 (P/E vs sector), Q7 (EV/EBITDA vs sector), Q10 (market cap comparison).565566```bash567uvx aipa-cli fundamentals rank VCB BID CTG TCB MBB ACB VPB HDB --sort-by pe 2>/dev/null | python3 -c "568import sys569values = []570for line in sys.stdin:571 parts = line.split()572 if parts and parts[0].isdigit() and len(parts) >= 3:573 try:574 val = float(parts[2].replace('%', ''))575 values.append(val)576 except ValueError:577 pass578if values:579 avg = sum(values) / len(values)580 s = sorted(values)581 print(f'n={len(values)} | avg={avg:.1f} | min={s[0]:.1f} | median={s[len(s)//2]:.1f} | max={s[-1]:.1f}')582"583```584585> **Tip:** Use **median** (not average) when the data contains outliers (e.g., P/E of 296,613 for a company with near-zero earnings). Median is more robust for sector comparison.586587### Ticker Percentile in Sector588589Useful for Q3, Q4, Q7 — "VCB ROE is in the top X% of the banking sector".590591```bash592uvx aipa-cli fundamentals rank VCB BID CTG TCB MBB ACB VPB HDB SHB TPB VIB SSB MSB STB --sort-by roe 2>/dev/null | python3 -c "593import sys594ticker = 'VCB'595rank = None596total = 0597for line in sys.stdin:598 parts = line.split()599 if parts and parts[0].isdigit():600 total += 1601 if len(parts) >= 3 and parts[1] == ticker:602 rank = int(parts[0])603if rank and total:604 pct = (total - rank) / (total - 1) * 100605 print(f'{ticker}: rank {rank}/{total} (top {100-pct:.0f}%)')606"607```608609### Book Value per Share (from P/B + Market Cap)610611Useful for Q2 — "if the company liquidates, shareholders get X per share".612613```bash614uvx aipa-cli fundamentals ratios VCB --category valuation --latest 2>/dev/null | python3 -c "615import sys616data = {}617for line in sys.stdin:618 parts = line.split()619 if len(parts) >= 2 and not line.strip().startswith('===') and not line.strip().startswith('Total') and parts[0] not in ('Valuation:',):620 raw = parts[-1].replace('%', '').replace(',', '')621 try:622 data[parts[0]] = float(raw)623 except ValueError:624 pass625pb = data.get('PB')626market_cap = data.get('Market')627if pb and pb > 0 and market_cap:628 bv = market_cap / pb629 print(f'P/B: {pb:.2f} | Market Cap: {market_cap/1e12:.1f}T VND | Book Value (total equity): {bv/1e12:.1f}T VND')630else:631 print(f'Missing data: PB={pb} Market Cap={market_cap}')632"633```634635### DuPont ROE Decomposition636637Useful for Q4 — break down ROE into its three drivers: profitability, efficiency, and leverage.638639```bash640uvx aipa-cli fundamentals ratios FPT --latest 2>/dev/null | python3 -c "641import sys642data = {}643for line in sys.stdin:644 parts = line.split()645 if len(parts) >= 2 and not line.strip().startswith('===') and not line.strip().startswith('Total') and parts[0] not in ('Valuation:', 'Profitability:', 'Efficiency:', 'Leverage:', 'Liquidity:', 'Bank:'):646 raw = parts[-1].replace('%', '').replace(',', '')647 try:648 data[parts[0]] = float(raw) / 100 if '%' in parts[-1] else float(raw)649 except ValueError:650 pass651nm = data.get('After-Tax')652at = data.get('Asset')653de = data.get('Financial')654roe_reported = data.get('ROE')655if nm is not None and at is not None and de is not None:656 em = 1 + de657 dupont = nm * at * em658 print(f'Net Margin: {nm*100:.1f}% | Asset Turnover: {at:.2f}x | Equity Multiplier: {em:.2f}x (1 + D/E {de:.2f})')659 if roe_reported:660 gap = abs(dupont - roe_reported)661 print(f'DuPont ROE: {dupont*100:.1f}% | Reported ROE: {roe_reported*100:.1f}% | Gap: {gap*100:.1f}pp')662 else:663 print(f'DuPont ROE: {dupont*100:.1f}%')664 print(f'Decomposition: {nm*100:.1f}% x {at:.2f} x {em:.2f} = {dupont*100:.1f}%')665 if nm > 0.15: print(f' -> Profitability driver: STRONG (NM > 15%)')666 elif nm > 0.05: print(f' -> Profitability driver: MODERATE')667 else: print(f' -> Profitability driver: WEAK')668 if at > 1.0: print(f' -> Efficiency driver: STRONG (AT > 1.0)')669 elif at > 0.5: print(f' -> Efficiency driver: MODERATE')670 else: print(f' -> Efficiency driver: WEAK')671 if em > 2.0: print(f' -> Leverage driver: HIGH (EM > 2.0)')672 elif em > 1.0: print(f' -> Leverage driver: MODERATE')673 else: print(f' -> Leverage driver: LOW')674else:675 print(f'Incomplete data: NM={nm} AT={at} D/E={de}')676"677```678679> **Note:** DuPont ROE may differ from reported ROE by a few percentage points due to quarterly data, minority interest, or different data source definitions. A gap of < 5pp is normal. The value is in understanding the *relative strength* of each driver, not exact reproduction.680681**Mandatory rule:** If you cannot verify a number with a pipe command, do NOT write it in any file. Use the actual computed value, rounded to 1 decimal place for ratios and 0.1% for percentages.682683---684685## Answering Principles6866871. **Read data → answer in prose**, not just show tables of numbers6882. **Compare with sector** — "cheap/low" means nothing without sector context6893. **Use sector averages** from `screen` or `rank` results for comparison6904. **Q10 (CASA):** Only answer CASA for bank tickers. For non-banks, only answer Market Cap and skip CASA6915. **Q11:** Summary must include strengths, weaknesses, and final conclusion6926. **Never hallucinate numbers** — only use values from tool output or web search results (with source citation)6937. **For non-VN tickers**: Use web search to answer the 11 questions. Mark N/A questions as "không áp dụng" rather than skipping silently. Always cite web sources.694695---696697## Tips for AI Agents6986991. **No API key or LLM needed**: `aipa fundamentals` reads from cached data. Works without `OPENAI_API_KEY`.7007012. **Auto-uppercase**: Ticker symbols are automatically uppercased. `vcb`, `tcb` all work.7027033. **`rank` before `ratios`**: When comparing multiple tickers, always start with `rank` to get a single comparative table. Only use `ratios` for individual deep dives on shortlisted tickers.7047054. **`screen` for filtering**: Use `screen` when you need to filter by quality criteria (PE < 15, ROE > 15%, NPL < 2%, etc.) before analyzing individually.7067075. **`--watchlist` for groups**: Use `--watchlist VN30` instead of typing all 30 tickers. Works with both `rank` and `screen`.7087096. **`--industry` for sector filtering**: Use `--industry "ngân hàng"` to filter by industry substring (case-insensitive) in `screen`.7107117. **`--category` for focused ratios**: Use `--category bank` for bank-specific fields (NPL, CAR, CASA, CIR), `--category leverage` for debt metrics, `--category profitability` for margins and efficiency.7127138. **`--latest` for speed**: Use `--latest` to get only the most recent period. Much faster than pulling all historical periods.7147159. **`--json` for parsing**: Use `--json` flag on `ratios` when you need structured data for programmatic use.71671710. **Use `aipa ticker-list` to discover tickers**: When you need to know what tickers are available in a sector, use `aipa ticker-list --source vn --group NGAN_HANG`. Add `--compact` for a comma-separated list.71871911. **Fundamental context enhances technical analysis**: When combining with `aipa-analyze`, fundamental metrics provide valuation context (PE=8 breakout vs PE=30 breakout have different risk profiles) and financial health context (high NPL + bearish technicals = strong sell signal).