Shop It Docs
TradingView UDF

GET /symbols

Resolve a NEPSE ticker into full TradingView symbol metadata

/symbols turns a ticker into the full metadata payload the Charting Library needs to render a chart — session window, pricescale, timezone, supported resolutions, etc.

  • Method: GET
  • Path: /api/nepse/tradingview/symbols
  • Content-Type: application/json

Query parameters

ParamRequiredTypeNotes
symbolstringTicker, optionally prefixed with NEPSE:. Case-insensitive. Prefix with ^ to address an index or sector sub-index (e.g. ^NEPSE, ^BANKING).

Input normalization:

  1. Trim whitespace.
  2. If a colon is present, keep only the portion after it (NEPSE:NABILNABIL, NEPSE:^NEPSE^NEPSE).
  3. Upper-case the remainder. The ^ prefix survives both steps.

Symbol namespace

KindSent by clientfull_nametype
StockNABILNEPSE:NABILstock
Top-level index^NEPSE, ^SENSITIVE, ^FLOAT, ^SFLOATNEPSE:^NEPSEindex
Sector sub-index^BANKING, ^DEVBANK, ^FINANCE, ^HOTELS, ^HYDRO, ^INVEST, ^LIFEINS, ^MFG, ^MICROFIN, ^MUTUAL, ^NONLIFE, ^OTHERS, ^TRADINGNEPSE:^BANKINGindex

The ^ prefix is a finance-industry convention (Yahoo ^GSPC, ^IXIC) that can never collide with NEPSE company tickers because NEPSE tickers are uppercase letters/digits only. The backend stores the bare ticker in the nepse_indices.tv_symbol / nepse_sub_indices.tv_symbol columns; the ^ is reattached in every /symbols, /search, and /history round trip.

Both top-level and sector indices come back with type: "index" — the frontend can infer sector-ness from the symbol list if it cares, but the Charting Library treats them identically.

Success response

{
  "name": "NABIL",
  "ticker": "NABIL",
  "full_name": "NEPSE:NABIL",
  "description": "Nabil Bank Limited",
  "type": "stock",
  "session": "1100-1500:23456",
  "timezone": "Asia/Kathmandu",
  "exchange": "NEPSE",
  "listed_exchange": "NEPSE",
  "minmov": 1,
  "pricescale": 100,
  "has_intraday": true,
  "intraday_multipliers": ["1", "5", "15", "30", "60"],
  "has_daily": true,
  "has_weekly_and_monthly": true,
  "supported_resolutions": ["1", "5", "15", "30", "60", "1D", "1W", "1M"],
  "currency_code": "NPR",
  "data_status": "streaming",
  "volume_precision": 0
}
FieldValueNotes
nameNABILDisplay name.
tickerNABILInternal identifier — stable across chart session.
full_nameNEPSE:NABILExchange-qualified name. Used in URL bar and save-state.
descriptionNabil Bank LimitedCompany name from nepse_companies.name.
typestockNEPSE has only stock-type instruments in UDF terms.
session1100-1500:23456NEPSE trading hours + day-of-week mask. See Session format.
timezoneAsia/KathmanduIANA zone the session is expressed in.
exchangeNEPSE
listed_exchangeNEPSETV spec requires both; kept identical.
minmov1Smallest price increment, scaled.
pricescale100Divisor. Together with minmov: minimum tick = 1/100 = 0.01 NPR.
has_intradaytrueIntraday bars are served.
intraday_multipliers["1","5","15","30","60"]Minute resolutions the backend can aggregate.
has_dailytrue
has_weekly_and_monthlytrue
supported_resolutionssame 8 as /configPer-symbol override of supported resolutions.
currency_codeNPR
data_statusstreamingTells the library the data is live (as opposed to delayed / endofday).
volume_precision0NEPSE volume is whole shares. Response serializes v as JSON integers.

Session format

The session field encodes both trading hours and active weekdays.

"1100-1500:23456"
 │         │
 │         └─── day mask, UDF encoding: 1=Sun, 2=Mon, 3=Tue, 4=Wed, 5=Thu, 6=Fri, 7=Sat
 └──────────── HHMM-HHMM window
  • NEPSE trades Monday–Friday, 11:00–15:00 NPT1100-1500:23456.
  • If NEPSE had a pre-open slot you wanted visible on the chart, you'd use multi-segment form: "1030-1100,1100-1500:23456".
  • The timezone field controls how the library interprets the HHMM values — so 1100-1500 here is 11:00 Asia/Kathmandu, not UTC.

The day mask uses UDF's own 1=Sun…7=Sat convention, which is different from both ISO (1=Mon) and time.Weekday (0=Sun). 23456 = Mon through Fri in that encoding.

Caching

Resolved symbols are cached in Redis for 5 minutes:

  • Key: nepse:tv:symbol:<UPPER_SYMBOL> (constant + cache.NepseTVSymbolKey)
  • TTL: cache.TTLNepseTVSymbol() = 5 minutes
  • 404 responses are never cached — a company added later must resolve on next call.

Redis failure (read or write) is non-fatal — the service logs a warning and falls through to the DB. This means a Redis outage degrades latency, not availability.

Error responses

All errors follow the UDF shape {"s":"error","errmsg":"..."} — never an envelope, never HTML.

ConditionStatuserrmsg
symbol param missing or empty after trim400symbol is required
Unknown / delisted symbol404unknown_symbol
Request timed out (5s budget)504timeout
Any other backend error500internal_error
Panic500internal_error (via Recoverer)

The 404 body still uses UDF error shape. Some UDF implementations return an empty SymbolInfo on unknown — we prefer the explicit error so the library's console reports unknown_symbol rather than silently attempting to render a symbol with blank metadata.

Prefix-stripping examples

RequestResolvedType
?symbol=NABILNABILstock
?symbol=nabilNABIL (upper-cased)stock
?symbol=NEPSE:NABILNABIL (prefix stripped)stock
?symbol=nepse:nabilNABIL (both)stock
?symbol= NABIL NABIL (trimmed)stock
?symbol=^NEPSE^NEPSEindex
?symbol=^nepse^NEPSE (case normalized)index
?symbol=NEPSE:^NEPSE^NEPSE (exchange prefix stripped, ^ preserved)index
?symbol=^BANKING^BANKINGindex
?symbol=400 symbol is required
?symbol=ZZZZZ404 unknown_symbol
?symbol=^XXX404 unknown_symbol

Verification

# Full payload — verify new fields are present
curl -s "$BASE/symbols?symbol=NABIL" | jq \
  '{full_name, listed_exchange, session, intraday_multipliers, volume_precision}'

# Prefix stripping
curl -s "$BASE/symbols?symbol=NEPSE:NABIL" | jq '.ticker'
# "NABIL"

# Unknown
curl -sw "\n%{http_code}\n" "$BASE/symbols?symbol=ZZZZZ"
# {"errmsg":"unknown_symbol","s":"error"}
# 404

Implementation

  • Handler: internal/modules/nepse/tradingview/handler.go(*Handler).Symbols
  • Service: internal/modules/nepse/tradingview/service.go(*Service).ResolveSymbol, (*Service).resolve
  • Type: internal/modules/nepse/tradingview/types.goSymbolResponse
  • sqlc: FindCompanyBySymbol (companies.sql), FindIndexByTVSymbol / FindSubIndexByTVSymbol (charts.sql)
  • Cache key helpers: internal/platform/cache/keys.goNepseTVSymbolKey, TTLNepseTVSymbol