Shop It Docs
Stock Analysis (Fundamentals)

Ratios

Per-tab ratio panel (valuation, profitability, solvency, growth) computed from the latest reported quarter

The ratios endpoint is the canonical home for ratio computation across the stock-analysis surface. The peers package imports ratios.ComputeTab, ratios.Inputs, and the Tab* constants so the comparison table covers the same metric surface.

MethodPathCache TTL
GET/api/nepse/companies/{symbol}/fundamentals/ratios10 min

Request

curl "$BASE/api/nepse/companies/NABIL/fundamentals/ratios?tab=valuation"

Query parameters

ParamDefaultValues
tabvaluationvaluation / profitability / solvency / growth

Response

{
  "message": "ok",
  "data": {
    "symbol": "NABIL",
    "tab": "valuation",
    "sector": "Commercial Banks",
    "rows": [
      {
        "key": "pe_ratio",
        "label": "P/E Ratio",
        "value": { "value": 12.76, "source": "computed", "status": "valid" },
        "sectorAvg": null,
        "unit": "x",
        "inverted": true,
        "formula": "LTP / EPS",
        "sparkline": []
      },
      {
        "key": "pb_ratio",
        "label": "P/B Ratio",
        "value": { "value": 5.43, "source": "computed", "status": "valid" },
        "sectorAvg": null,
        "unit": "x",
        "inverted": true,
        "formula": "LTP / Book Value Per Share",
        "sparkline": []
      }
      /* ... more rows ... */
    ],
    "note": "Sector benchmarks and historical sparklines activate once multi-quarter coverage is available.",
    "dataAsOf": "2026-05-23T14:55:00+05:45",
    "servedAt": "2026-05-23T14:56:30+05:45"
  }
}

Rows per tab

valuation

KeyLabelUnitInvertedFormula
pe_ratioP/E RatioxLTP / EPS
pb_ratioP/B RatioxLTP / Book Value Per Share
dividend_yieldDividend Yield%Sum(cash dividend %) / LTP
market_capMarket CapNPRLTP × Outstanding Shares
epsEPSNPRReported earnings per share
book_value_per_shareBook Value Per ShareNPRTotal Equity / Outstanding Shares

profitability

KeyLabelUnitFormula
net_marginNet Profit Margin%Net Profit / Revenue × 100
roaReturn on Assets (ROA)%Net Profit / Total Assets × 100
roeReturn on Equity (ROE)%Net Profit / Total Equity × 100

solvency

KeyLabelUnitInvertedFormula
debt_equityDebt to EquityxTotal Liabilities / Total Equity
current_ratioCurrent RatioxCurrent Assets / Current Liabilities
equity_ratioEquity Ratio%Total Equity / Total Assets × 100

growth

Every row returns status: insufficient_history under v4.5 — the slot stays in the response shape so adding YoY calculations is a service-only change once multi-quarter history lands.

KeyLabelFormula
revenue_growth_yoyRevenue Growth (YoY)((Revenue_t − Revenue_{t-1}) / Revenue_{t-1}) × 100
eps_growth_yoyEPS Growth (YoY)((EPS_t − EPS_{t-1}) / EPS_{t-1}) × 100
net_profit_growth_yoyNet Profit Growth (YoY)((NP_t − NP_{t-1}) / NP_{t-1}) × 100

Field rules

FieldTypeNotes
rows[].valueMetricFloat64The metric envelope; propagates input status
rows[].sectorAvg*float64Always null under v4.5 — explicit nullable so FE renders vs 0
rows[].unitstringDisplay unit; omitted when unitless
rows[].invertedbooltrue = lower is better (P/E, P/B, D/E)
rows[].formulastringPlain-text formula for tooltip rendering
rows[].sparklinefloat[]Always [] under v4.5; future home for trailing-N quarter history

inverted controls how the peer-comparison BestOf and radar normalization treat the metric. P/E and P/B are inverted so "lower-is-better" still scores higher on the radar.

Loss-making companies

net_margin is the only ratio that surfaces a valid number when the numerator is negative — a loss carries meaning ("margin = -8%"), and the row gets status: valid with the negative value so FE can colour it red without inferring sign. The other ratios (ROA, ROE, D/E, etc.) collapse to status: negative_input when their numerator/denominator goes non-positive, because the resulting ratio would be misleading.

Status propagation

Each computed row's status is the worst-of its inputs:

EPS statusLTPpe_ratio.status
upstream_missing*upstream_missing
valid (positive)nullupstream_missing
valid (≤0)valuenegative_input
valid (positive)valuevalid

Reused by Peers

The peers package imports this package's exported surface:

import "internal/modules/nepse/fundamentals/stock_analysis/ratios"

inputs := ratios.Inputs{ /* ... */ }
rows   := ratios.ComputeTab(ratios.TabValuation, inputs)

This is why the Inputs, Row, ComputeTab, Tab*, and OutstandingSharesPtr symbols are exported — see peers/service.go for the consumer.

Caching

KeyTTL
nepse:fundamentals:ratios:{SYMBOL}:{tab}10 min

Errors

CodeReason
200OK
400tab not in valuation/profitability/solvency/growth
404Symbol not in nepse_companies
500DB error