Shop It Docs
Stock Analysis (Fundamentals)

Reference

Every stock-analysis endpoint, DTO, cache key, and sqlc query on one page

A single-page lookup table for the stock-analysis umbrella. All paths prefixed with /api/nepse/. All endpoints public (rate-limited at 30 req/min/IP under the rl30 group), HTTP GET only.

All 9 endpoints

Per-symbol (8 endpoints, tag Fundamentals)

MethodPathHandlerCache TTL
GET/companies/{symbol}/fundamentals/snapshotsnapshot.Handler.HTTP5 min
GET/companies/{symbol}/fundamentals/statementsstatements.Handler.HTTP10 min
GET/companies/{symbol}/fundamentals/ratiosratios.Handler.HTTP10 min
GET/companies/{symbol}/fundamentals/dividendsdividends.Handler.HTTP30 min
GET/companies/{symbol}/fundamentals/ownershipownership.Handler.HTTP1 hr
GET/companies/{symbol}/fundamentals/peerspeers.Handler.HTTP10 min
GET/companies/{symbol}/fundamentals/announcementsannouncements.Handler.HTTP5 min
GET/companies/{symbol}/fundamentals/fair-valuefairvalue.Handler.HTTP10 min

Global (1 endpoint)

MethodPathHandlerCache TTL
GET/upcoming-book-closesdividends.Handler.UpcomingBookCloses1 hr

Bundle composition

// internal/modules/nepse/fundamentals/stock_analysis/deps.go
type Bundle struct {
    Snapshot      *snapshot.Handler
    Statements    *statements.Handler
    Ratios        *ratios.Handler
    Dividends     *dividends.Handler
    Ownership     *ownership.Handler
    Peers         *peers.Handler
    Announcements *announcements.Handler
    FairValue     *fairvalue.Handler
}

func NewBundle(q *sqlc.Queries, tax *taxonomy.Manager, c *cache.Cache) *Bundle

Mounted from cmd/server/main.go:

stockAnalysisBundle := stockanalysis.NewBundle(queries, taxonomyManager, cacheLayer)

And from internal/http/router/router.go:

if deps.StockAnalysis != nil {
    stockanalysis.Routes(r, deps.StockAnalysis)       // 8 per-symbol
    stockanalysis.GlobalRoutes(r, deps.StockAnalysis) // /upcoming-book-closes
}

DTOs

Each feature owns its own DTO file (types.go). The cross-cutting envelope:

type Envelope<T> = { message: string; data: T };

type MetricFloat64 = {
  value?: number;
  source: 'mdp' | 'computed' | 'manual_swp';
  status: 'valid' | 'upstream_missing' | 'insufficient_history' | 'negative_input' | 'insufficient_cohort';
};
DTOFileUsed by
snapshot.Responsesnapshot/types.goGET /snapshot
statements.Responsestatements/types.goGET /statements
ratios.Response, ratios.Row, ratios.Inputsratios/types.goGET /ratios, imported by peers
dividends.Response, dividends.UpcomingBookClosesResponse, dividends.UpcomingBookCloseRowdividends/types.goGET /dividends, GET /upcoming-book-closes
ownership.Response, ownership.Tier2, ownership.Tier4ownership/types.goGET /ownership
peers.Response, peers.Company, peers.Row, peers.RadarEntry, peers.ExcludedPeerpeers/types.goGET /peers
announcements.Response, announcements.Row, announcements.ExpandResultsannouncements/types.goGET /announcements
fairvalue.Response, fairvalue.Method, fairvalue.Inputs, fairvalue.Summaryfair_value/types.goGET /fair-value

Cache keys

All in the nepse:fundamentals: namespace. Constants in cachekey.go:

ConstPatternUsed by
PrefixSnapshotnepse:fundamentals:snapshot:{SYM}snapshot
PrefixStatementsnepse:fundamentals:statements:{SYM}:{type}:{period}:y{years}statements
PrefixRatiosnepse:fundamentals:ratios:{SYM}:{tab}ratios
PrefixDividendsnepse:fundamentals:dividends:{SYM}:y{years}:d{upcomingDays}dividends
PrefixUpcomingBookClosesnepse:fundamentals:upcoming-book-closes:d{days}:l{limit}dividends (global)
PrefixOwnershipnepse:fundamentals:ownership:{SYM}ownership
PrefixPeersnepse:fundamentals:peers:{FOCAL}:{sortedPeers}peers
PrefixAnnouncementsnepse:fundamentals:announcements:{SYM}:t{sortedTypes}:f{from}:x{to}:l{limit}announcements
PrefixFairValuenepse:fundamentals:fair-value:{SYM}fair_value

sqlc queries

Located in internal/platform/database/queries/fundamentals_*.sql (and corporate_*.sql):

QueryUsed by
GetFundamentalsSnapshotCoresnapshot, statements, ratios, peers (404 probe), announcements (404 probe), fair_value, dividends
GetFundamentalsSnapshotReportssnapshot, ratios, peers, fair_value
GetFundamentalsSnapshotDividendssnapshot, ratios, peers
GetFundamentalsStatementsHistorystatements
GetFundamentalsAuditedAnnualOverridesstatements (annual mode)
GetFundamentalsDividendEventsdividends
GetFundamentalsRightsEventsdividends
GetFundamentalsTRIndexAnchordividends (TR-index series)
GetFundamentalsUpcomingBookCloseBySymboldividends (per-symbol upcoming)
GetFundamentalsUpcomingBookClosesGlobaldividends (global feed)
GetFundamentalsOwnershipCoreownership
GetFundamentalsOwnershipExtendedLatestownership (Tier4 override)
GetFundamentalsAuditorLatestownership
GetFundamentalsTopShareholdersLatestownership
GetAnnouncementsDividendsannouncements
GetAnnouncementsRightsannouncements
GetAnnouncementsAGMsannouncements
GetAnnouncementsMergersannouncements
GetAnnouncementsResultsannouncements
GetFundamentalsFairValueSectorCohortfair_value

Shared compute helpers

Reused across features — internal/modules/nepse/fundamentals/compute/:

HelperReturnsUsed by
compute.ItemsFromReports(reports, "Balance Sheet")map[string]*float64snapshot, ratios, peers, fair_value, statements
compute.BookValuePerShare(reg, bsItems, outstanding, sector)MetricFloat64snapshot, ratios, fair_value
compute.EPSCurrent(reg, isItems, sector)MetricFloat64snapshot, ratios, fair_value
compute.ComputeMarketCap(core)*float64snapshot, ratios, peers, fair_value
compute.ComputeDividendYield(dividends, ltp)MetricFloat64snapshot, ratios

BookValuePerShare and EPSCurrent were lifted out of snapshot/ and ratios/ in P11 of the refactor — fair_value now imports them too instead of carrying near-duplicates.

Notable file paths

FilePurpose
internal/modules/nepse/fundamentals/stock_analysis/deps.goBundle + NewBundle
internal/modules/nepse/fundamentals/stock_analysis/routes.goRoutes (per-symbol) + GlobalRoutes
internal/modules/nepse/fundamentals/stock_analysis/cachekey.goAll cache-prefix constants
internal/modules/nepse/fundamentals/stock_analysis/internal/store/store.goSnapshotReader interface (3 shared sqlc reads)
internal/modules/nepse/fundamentals/stock_analysis/internal/goldenjson/JSON-shape pin tests + cache-prefix drift detector
internal/modules/nepse/financial_reports/taxonomy/Registry.LookupValue + canonical row vocabulary
internal/modules/nepse/fundamentals/compute/Shared BVPS / EPS / market cap / yield helpers
internal/modules/nepse/fundamentals/metric/MetricFloat64 + status enum
internal/http/router/router.go:142-149Route mounting block
cmd/server/main.go:312Bundle construction
docs/FUNDAMENTALS_REFACTOR_PLAN.mdMulti-phase plan that produced this layout