nepse

package module
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 11 Imported by: 0

README

go-nepse

Type-safe Go client for NEPSE market data.

Disclaimer: Unofficial library using NEPSE's undocumented API. For educational/personal use only. May break without notice.

NEPSE Go Demo

Features

  • Type Safety - All responses are properly typed structs
  • Automatic Authentication - Token management handled transparently
  • Retry Logic - Built-in retry with exponential backoff
  • Context Support - Full context.Context support for cancellation and timeouts
  • Error Handling - Structured error types with proper error chains

Installation

go get github.com/voidarchive/go-nepse

Quick Start

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/voidarchive/go-nepse"
)

func main() {
    // Create a new NEPSE client
    opts := nepse.DefaultOptions()
    opts.TLSVerification = false // NEPSE servers have certificate issues

    client, err := nepse.NewClient(opts)
    if err != nil {
        log.Fatalf("Failed to create NEPSE client: %v", err)
    }
    defer client.Close()

    ctx := context.Background()

    // Get market summary
    summary, err := client.MarketSummary(ctx)
    if err != nil {
        log.Fatalf("Failed to get market summary: %v", err)
    }
    fmt.Printf("Total Turnover: Rs. %.2f\n", summary.TotalTurnover)
    fmt.Printf("Total Transactions: %.0f\n", summary.TotalTransactions)

    // Get company details by symbol
    details, err := client.CompanyBySymbol(ctx, "NABIL")
    if err != nil {
        log.Fatalf("Failed to get company details: %v", err)
    }
    fmt.Printf("Company: %s, LTP: Rs. %.2f\n", details.SecurityName, details.LastTradedPrice)
}

API Coverage

Market Data
Method Description
MarketSummary() Overall market statistics (turnover, volume, capitalization)
MarketStatus() Current market open/close status
NepseIndex() Main NEPSE index with current value and 52-week range
SubIndices() All sector sub-indices (Note: API currently returns empty)
LiveMarket() Real-time price and volume data
SupplyDemand() Aggregate supply and demand data
Securities & Companies
Method Description
Securities() All tradable securities
Companies() All listed companies with sector info
Company(id) Comprehensive info including price data
CompanyBySymbol(symbol) Same as above, by ticker symbol
SectorScrips() Securities grouped by sector
FindSecurity(id) / FindSecurityBySymbol(symbol) Find security by ID or symbol
Price & Trading Data
Method Description
TodaysPrices(date) Price data for all securities on a date
PriceHistory(id, start, end) Historical OHLCV data
PriceHistoryBySymbol(symbol, start, end) Same as above, by symbol
MarketDepth(id) / MarketDepthBySymbol(symbol) Order book (bid/ask levels)
FloorSheet() All trades for current day
FloorSheetOf(id, date) / FloorSheetBySymbol(symbol, date) Trades for specific security
Top Lists
Method Description
TopGainers() Securities with highest % gains
TopLosers() Securities with highest % losses
TopTenTrade() Top by traded share volume
TopTenTransaction() Top by transaction count
TopTenTurnover() Top by trading turnover
Graph Data
Method Description
DailyIndexGraph(indexType) Intraday graph for any index type
DailyNepseIndexGraph() Main NEPSE index chart
DailyScripGraph(id) Intraday chart for a security
Company Fundamentals
Method Description
CompanyProfile(id) / CompanyProfileBySymbol(symbol) Detailed company profile (contact, address, etc.)
BoardOfDirectors(id) / BoardOfDirectorsBySymbol(symbol) Board members with designations
Reports(id) / ReportsBySymbol(symbol) Quarterly & annual reports with PE, EPS, book value
CorporateActions(id) / CorporateActionsBySymbol(symbol) Bonus shares, rights issues (approval/distribution)
Dividends(id) / DividendsBySymbol(symbol) Dividend declarations (cash & bonus)

Note: Corporate Actions tracks when bonus/rights shares were approved/distributed, while Dividends tracks when they were declared. There may be a 1-year lag between declaration and distribution.

Configuration

opts := nepse.DefaultOptions()
opts.TLSVerification = false // NEPSE servers have certificate issues
opts.HTTPTimeout = 30 * time.Second
opts.MaxRetries = 3
opts.RetryDelay = time.Second

client, err := nepse.NewClient(opts)

Error Handling

The library provides structured error types:

import "errors"

data, err := client.MarketSummary(ctx)
if err != nil {
    var nepseErr *nepse.NepseError
    if errors.As(err, &nepseErr) {
        switch nepseErr.Type {
        case nepse.ErrorTypeNotFound:
            // Handle not found
        case nepse.ErrorTypeNetwork:
            // Handle network issues
        case nepse.ErrorTypeRateLimit:
            // Handle rate limiting
        }
    }
}

Production Checklist

  • API Risks: Unofficial API, will break when NEPSE updates infrastructure
  • TLS Security: Route through secure proxy to handle certificate issues
  • Caching: Cache responses to avoid rate limiting
  • Monitoring: Alert on ErrorTypeNetwork or ErrorTypeInternal
  • Rate Limiting: Respect implicit limits to avoid IP blocks
  • Fallback: Have alternative data source for outages

Examples

See _examples/ for complete usage examples:

# Run the basic example
go run _examples/basic/main.go

# Include graph endpoints
go run _examples/basic/main.go --with-graphs

# Include floor sheet data
go run _examples/basic/main.go --with-floorsheet

Requirements

  • Go 1.25+

License

MIT License - see LICENSE for details.

Documentation

Overview

Package nepse provides a type-safe Go client for NEPSE market data.

Covers market summaries, securities, prices, floor sheets, indices, company fundamentals, dividends, and corporate actions.

Example:

opts := nepse.DefaultOptions()
opts.TLSVerification = false // NEPSE servers have certificate issues

client, err := nepse.NewClient(opts)
if err != nil {
	log.Fatal(err)
}
defer client.Close()

summary, err := client.MarketSummary(context.Background())
if err != nil {
	log.Fatal(err)
}
fmt.Printf("Turnover: Rs. %.2f\n", summary.TotalTurnover)

Index

Constants

View Source
const (
	Version   = "0.2.0"
	UserAgent = "go-nepse/" + Version
)
View Source
const (
	DateFormat     = "2006-01-02"
	DateTimeFormat = "2006-01-02 15:04:05"
)

Date formats used by NEPSE API.

View Source
const (
	SectorBanking          = "Banking"
	SectorDevelopmentBank  = "Development Bank"
	SectorFinance          = "Finance"
	SectorHotelTourism     = "Hotel Tourism"
	SectorHydro            = "Hydro"
	SectorInvestment       = "Investment"
	SectorLifeInsurance    = "Life Insurance"
	SectorManufacturing    = "Manufacturing"
	SectorMicrofinance     = "Microfinance"
	SectorMutualFund       = "Mutual Fund"
	SectorNonLifeInsurance = "Non Life Insurance"
	SectorOthers           = "Others"
	SectorTrading          = "Trading"
	SectorPromoterShare    = "Promoter Share"
)

Sector names.

View Source
const DefaultBaseURL = "https://nepalstock.com.np"

DefaultBaseURL is the production NEPSE API URL.

Variables

View Source
var (
	ErrInvalidClientRequest  = &NepseError{Type: ErrorTypeInvalidClientRequest}
	ErrInvalidServerResponse = &NepseError{Type: ErrorTypeInvalidServerResponse}
	ErrTokenExpired          = &NepseError{Type: ErrorTypeTokenExpired}
	ErrNetworkError          = &NepseError{Type: ErrorTypeNetworkError}
	ErrUnauthorized          = &NepseError{Type: ErrorTypeUnauthorized}
	ErrNotFound              = &NepseError{Type: ErrorTypeNotFound}
	ErrRateLimit             = &NepseError{Type: ErrorTypeRateLimit}
	ErrInternal              = &NepseError{Type: ErrorTypeInternal}
)

Sentinel errors for use with errors.Is. Matching is based on ErrorType, not identity.

Functions

This section is empty.

Types

type BoardMember added in v0.2.1

type BoardMember struct {
	FirstName       string  `json:"firstName"`
	MiddleName      string  `json:"middleName"`
	LastName        string  `json:"lastName"`
	Designation     string  `json:"designation"`
	MemberPhotoPath *string `json:"memberPhotoPath"`
	Description     string  `json:"description"`
}

BoardMember represents a board of directors member.

func (*BoardMember) FullName added in v0.2.1

func (b *BoardMember) FullName() string

FullName returns the complete name of the board member.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the NEPSE API client. Use NewClient to create one.

func NewClient

func NewClient(options *Options) (*Client, error)

NewClient creates a NEPSE API client. If options is nil, DefaultOptions() is used.

func (*Client) BoardOfDirectors added in v0.2.1

func (c *Client) BoardOfDirectors(ctx context.Context, securityID int32) ([]BoardMember, error)

BoardOfDirectors returns the board of directors for a security.

func (*Client) BoardOfDirectorsBySymbol added in v0.2.1

func (c *Client) BoardOfDirectorsBySymbol(ctx context.Context, symbol string) ([]BoardMember, error)

BoardOfDirectorsBySymbol returns the board of directors for a security by symbol.

func (*Client) Close

func (c *Client) Close() error

Close releases resources held by the client.

func (*Client) Companies added in v0.1.2

func (c *Client) Companies(ctx context.Context) ([]Company, error)

Companies returns all listed companies on the exchange.

func (*Client) Company added in v0.1.2

func (c *Client) Company(ctx context.Context, securityID int32) (*CompanyDetails, error)

Company returns comprehensive information including price data for a security.

func (*Client) CompanyBySymbol added in v0.1.2

func (c *Client) CompanyBySymbol(ctx context.Context, symbol string) (*CompanyDetails, error)

CompanyBySymbol returns comprehensive information for a security by ticker symbol.

func (*Client) CompanyProfile added in v0.2.1

func (c *Client) CompanyProfile(ctx context.Context, securityID int32) (*CompanyProfile, error)

CompanyProfile returns detailed profile information for a security.

func (*Client) CompanyProfileBySymbol added in v0.2.1

func (c *Client) CompanyProfileBySymbol(ctx context.Context, symbol string) (*CompanyProfile, error)

CompanyProfileBySymbol returns detailed profile information for a security by symbol.

func (*Client) Config added in v0.1.2

func (c *Client) Config() *Config

Config returns the client's configuration.

func (*Client) CorporateActions added in v0.2.1

func (c *Client) CorporateActions(ctx context.Context, securityID int32) ([]CorporateAction, error)

CorporateActions returns corporate actions (bonus, rights, dividends) for a security.

func (*Client) CorporateActionsBySymbol added in v0.2.1

func (c *Client) CorporateActionsBySymbol(ctx context.Context, symbol string) ([]CorporateAction, error)

CorporateActionsBySymbol returns corporate actions for a security by symbol.

func (*Client) DailyBankSubindexGraph added in v0.1.2

func (c *Client) DailyBankSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyBankSubindexGraph returns intraday graph data for the banking sector sub-index.

func (*Client) DailyDevelopmentBankSubindexGraph added in v0.1.2

func (c *Client) DailyDevelopmentBankSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyDevelopmentBankSubindexGraph returns intraday graph data for the development bank sector.

func (*Client) DailyFinanceSubindexGraph added in v0.1.2

func (c *Client) DailyFinanceSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyFinanceSubindexGraph returns intraday graph data for the finance sector.

func (*Client) DailyFloatIndexGraph added in v0.1.2

func (c *Client) DailyFloatIndexGraph(ctx context.Context) (*GraphResponse, error)

DailyFloatIndexGraph returns intraday graph data for the float index.

func (*Client) DailyHotelTourismSubindexGraph added in v0.1.2

func (c *Client) DailyHotelTourismSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyHotelTourismSubindexGraph returns intraday graph data for the hotel & tourism sector.

func (*Client) DailyHydroSubindexGraph added in v0.1.2

func (c *Client) DailyHydroSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyHydroSubindexGraph returns intraday graph data for the hydropower sector.

func (*Client) DailyIndexGraph added in v0.1.2

func (c *Client) DailyIndexGraph(ctx context.Context, indexType IndexType) (*GraphResponse, error)

DailyIndexGraph returns intraday graph data points for any market index.

func (*Client) DailyInvestmentSubindexGraph added in v0.1.2

func (c *Client) DailyInvestmentSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyInvestmentSubindexGraph returns intraday graph data for the investment sector.

func (*Client) DailyLifeInsuranceSubindexGraph added in v0.1.2

func (c *Client) DailyLifeInsuranceSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyLifeInsuranceSubindexGraph returns intraday graph data for the life insurance sector.

func (*Client) DailyManufacturingSubindexGraph added in v0.1.2

func (c *Client) DailyManufacturingSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyManufacturingSubindexGraph returns intraday graph data for the manufacturing sector.

func (*Client) DailyMicrofinanceSubindexGraph added in v0.1.2

func (c *Client) DailyMicrofinanceSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyMicrofinanceSubindexGraph returns intraday graph data for the microfinance sector.

func (*Client) DailyMutualfundSubindexGraph added in v0.1.2

func (c *Client) DailyMutualfundSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyMutualfundSubindexGraph returns intraday graph data for the mutual fund sector.

func (*Client) DailyNepseIndexGraph added in v0.1.2

func (c *Client) DailyNepseIndexGraph(ctx context.Context) (*GraphResponse, error)

DailyNepseIndexGraph returns intraday graph data for the main NEPSE index.

func (*Client) DailyNonLifeInsuranceSubindexGraph added in v0.1.2

func (c *Client) DailyNonLifeInsuranceSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyNonLifeInsuranceSubindexGraph returns intraday graph data for the non-life insurance sector.

func (*Client) DailyOthersSubindexGraph added in v0.1.2

func (c *Client) DailyOthersSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyOthersSubindexGraph returns intraday graph data for the others sector.

func (*Client) DailyScripGraph added in v0.1.2

func (c *Client) DailyScripGraph(ctx context.Context, securityID int32) (*GraphResponse, error)

DailyScripGraph returns intraday price graph data for a specific security.

func (*Client) DailyScripGraphBySymbol added in v0.1.2

func (c *Client) DailyScripGraphBySymbol(ctx context.Context, symbol string) (*GraphResponse, error)

DailyScripGraphBySymbol returns intraday price graph data for a security by ticker symbol.

func (*Client) DailySensitiveFloatIndexGraph added in v0.1.2

func (c *Client) DailySensitiveFloatIndexGraph(ctx context.Context) (*GraphResponse, error)

DailySensitiveFloatIndexGraph returns intraday graph data for the sensitive float index.

func (*Client) DailySensitiveIndexGraph added in v0.1.2

func (c *Client) DailySensitiveIndexGraph(ctx context.Context) (*GraphResponse, error)

DailySensitiveIndexGraph returns intraday graph data for the sensitive index.

func (*Client) DailyTradingSubindexGraph added in v0.1.2

func (c *Client) DailyTradingSubindexGraph(ctx context.Context) (*GraphResponse, error)

DailyTradingSubindexGraph returns intraday graph data for the trading sector.

func (*Client) DebugDecodedToken added in v0.1.2

func (c *Client) DebugDecodedToken(ctx context.Context) (string, error)

DebugDecodedToken returns the WASM-decoded access token for debugging. This is the token that would be sent in Authorization headers.

func (*Client) DebugRawPostRequest added in v0.1.2

func (c *Client) DebugRawPostRequest(ctx context.Context, endpoint string, body any) ([]byte, error)

DebugRawPostRequest makes an authenticated POST request and returns the raw response. This is for debugging API responses.

func (*Client) DebugRawRequest

func (c *Client) DebugRawRequest(ctx context.Context, endpoint string) ([]byte, error)

DebugRawRequest makes an authenticated request and returns the raw response. This is for debugging API responses.

func (*Client) DebugSecurityDetailRaw added in v0.2.4

func (c *Client) DebugSecurityDetailRaw(ctx context.Context, securityID int32) ([]byte, error)

DebugSecurityDetailRaw returns the raw JSON response from the security detail endpoint. This is useful for debugging the API response structure.

func (*Client) Dividends added in v0.2.1

func (c *Client) Dividends(ctx context.Context, securityID int32) ([]Dividend, error)

Dividends returns dividend history for a security.

func (*Client) DividendsBySymbol added in v0.2.1

func (c *Client) DividendsBySymbol(ctx context.Context, symbol string) ([]Dividend, error)

DividendsBySymbol returns dividend history for a security by symbol.

func (*Client) FindSecurity

func (c *Client) FindSecurity(ctx context.Context, securityID int32) (*Security, error)

FindSecurity returns the security with the given ID.

func (*Client) FindSecurityBySymbol

func (c *Client) FindSecurityBySymbol(ctx context.Context, symbol string) (*Security, error)

FindSecurityBySymbol returns the security with the given ticker symbol.

func (*Client) FloorSheet added in v0.1.2

func (c *Client) FloorSheet(ctx context.Context) ([]FloorSheetEntry, error)

FloorSheet returns all trades executed on the exchange for the current trading day. Handles both array and paginated response formats. Note: Returns empty slice if no trades have occurred yet.

func (*Client) FloorSheetBySymbol added in v0.1.2

func (c *Client) FloorSheetBySymbol(ctx context.Context, symbol string, businessDate string) ([]FloorSheetEntry, error)

FloorSheetBySymbol returns all trades for a specific security by symbol on a given date.

HACK: As of December 2025, NEPSE has blocked this endpoint at the server level. All requests return 403 Forbidden. Use Client.FloorSheet instead for general floorsheet data.

func (*Client) FloorSheetOf added in v0.1.2

func (c *Client) FloorSheetOf(ctx context.Context, securityID int32, businessDate string) ([]FloorSheetEntry, error)

FloorSheetOf returns all trades for a specific security on a given business date.

IMPORTANT: As of December 2025, NEPSE has blocked this endpoint at the server level. All requests return 403 Forbidden. Use Client.FloorSheet instead for general floorsheet data.

func (*Client) LiveMarket added in v0.1.2

func (c *Client) LiveMarket(ctx context.Context) ([]LiveMarketEntry, error)

LiveMarket returns real-time price and volume data for all actively traded securities.

func (*Client) MarketDepth added in v0.1.2

func (c *Client) MarketDepth(ctx context.Context, securityID int32) (*MarketDepth, error)

MarketDepth returns the order book (bid/ask levels) for a security.

func (*Client) MarketDepthBySymbol added in v0.1.2

func (c *Client) MarketDepthBySymbol(ctx context.Context, symbol string) (*MarketDepth, error)

MarketDepthBySymbol returns the order book for a security by ticker symbol.

func (*Client) MarketStatus added in v0.1.2

func (c *Client) MarketStatus(ctx context.Context) (*MarketStatus, error)

MarketStatus returns whether the market is currently open or closed.

func (*Client) MarketSummary added in v0.1.2

func (c *Client) MarketSummary(ctx context.Context) (*MarketSummary, error)

MarketSummary returns aggregate market statistics including turnover, volume, and capitalization.

func (*Client) NepseIndex added in v0.1.2

func (c *Client) NepseIndex(ctx context.Context) (*NepseIndex, error)

NepseIndex returns the main NEPSE index with current value, change, and 52-week range.

func (*Client) PriceHistory added in v0.1.2

func (c *Client) PriceHistory(ctx context.Context, securityID int32, startDate, endDate string) ([]PriceHistory, error)

PriceHistory returns historical OHLCV data for a security within a date range.

func (*Client) PriceHistoryBySymbol added in v0.1.2

func (c *Client) PriceHistoryBySymbol(ctx context.Context, symbol string, startDate, endDate string) ([]PriceHistory, error)

PriceHistoryBySymbol returns historical OHLCV data for a security by symbol.

func (*Client) Reports added in v0.2.1

func (c *Client) Reports(ctx context.Context, securityID int32) ([]Report, error)

Reports returns quarterly and annual reports for a security.

func (*Client) ReportsBySymbol added in v0.2.1

func (c *Client) ReportsBySymbol(ctx context.Context, symbol string) ([]Report, error)

ReportsBySymbol returns quarterly and annual reports for a security by symbol.

func (*Client) SectorScrips added in v0.1.2

func (c *Client) SectorScrips(ctx context.Context) (SectorScrips, error)

SectorScrips returns a map of sector names to their constituent security symbols.

func (*Client) Securities added in v0.1.2

func (c *Client) Securities(ctx context.Context) ([]Security, error)

Securities returns all tradable securities on the exchange.

func (*Client) SecurityDetail added in v0.2.4

func (c *Client) SecurityDetail(ctx context.Context, securityID int32) (*SecurityDetail, error)

SecurityDetail returns comprehensive security information including shareholding data. This uses a POST request to fetch additional data not available via Client.Company.

func (*Client) SecurityDetailBySymbol added in v0.2.4

func (c *Client) SecurityDetailBySymbol(ctx context.Context, symbol string) (*SecurityDetail, error)

SecurityDetailBySymbol returns comprehensive security information by ticker symbol.

func (*Client) SubIndices added in v0.1.2

func (c *Client) SubIndices(ctx context.Context) ([]SubIndex, error)

SubIndices returns other main indices (Sensitive, Float, Sensitive Float) excluding the main NEPSE index. Note: Sector sub-indices are only available through graph endpoints.

func (*Client) SupplyDemand added in v0.1.2

func (c *Client) SupplyDemand(ctx context.Context) (*SupplyDemandData, error)

SupplyDemand returns aggregate supply and demand data.

func (*Client) TodaysPrices added in v0.1.2

func (c *Client) TodaysPrices(ctx context.Context, businessDate string) ([]TodayPrice, error)

TodaysPrices returns price data for all securities on a given business date. If businessDate is empty, returns data for the current trading day.

Note: This endpoint may return empty results. NEPSE's web interface uses a POST request that requires additional authentication not currently supported by this library. For current prices, consider using Client.TopGainers, Client.TopLosers, or Client.Company which return LTP (last traded price) data.

func (*Client) Token added in v0.1.2

func (c *Client) Token(ctx context.Context) (*auth.TokenResponse, error)

Token implements auth.NepseHTTP interface.

func (*Client) TopGainers added in v0.1.2

func (c *Client) TopGainers(ctx context.Context) ([]TopGainerLoserEntry, error)

TopGainers returns securities with the highest percentage gains for the trading day.

func (*Client) TopLosers added in v0.1.2

func (c *Client) TopLosers(ctx context.Context) ([]TopGainerLoserEntry, error)

TopLosers returns securities with the highest percentage losses for the trading day.

func (*Client) TopTenTrade added in v0.1.2

func (c *Client) TopTenTrade(ctx context.Context) ([]TopTradeEntry, error)

TopTenTrade returns the ten securities with the highest traded share volume.

func (*Client) TopTenTransaction added in v0.1.2

func (c *Client) TopTenTransaction(ctx context.Context) ([]TopTransactionEntry, error)

TopTenTransaction returns the ten securities with the most transactions.

func (*Client) TopTenTurnover added in v0.1.2

func (c *Client) TopTenTurnover(ctx context.Context) ([]TopTurnoverEntry, error)

TopTenTurnover returns the ten securities with the highest trading turnover (value).

type Company

type Company struct {
	ID             int32  `json:"id"`
	CompanyName    string `json:"companyName"`
	Symbol         string `json:"symbol"`
	SecurityName   string `json:"securityName"`
	Status         string `json:"status"`
	CompanyEmail   string `json:"companyEmail"`
	Website        string `json:"website"`
	SectorName     string `json:"sectorName"`
	RegulatoryBody string `json:"regulatoryBody"`
	InstrumentType string `json:"instrumentType"`
}

Company represents company information.

type CompanyDetails

type CompanyDetails struct {
	ID               int32  `json:"id"`
	Symbol           string `json:"symbol"`
	SecurityName     string `json:"securityName"`
	SectorName       string `json:"sectorName"`
	Email            string `json:"email"`
	ActiveStatus     string `json:"activeStatus"`
	PermittedToTrade string `json:"permittedToTrade"`

	OpenPrice           float64 `json:"openPrice"`
	HighPrice           float64 `json:"highPrice"`
	LowPrice            float64 `json:"lowPrice"`
	ClosePrice          float64 `json:"closePrice"`
	LastTradedPrice     float64 `json:"lastTradedPrice"`
	PreviousClose       float64 `json:"previousClose"`
	TotalTradeQuantity  int64   `json:"totalTradeQuantity"`
	TotalTrades         int32   `json:"totalTrades"`
	FiftyTwoWeekHigh    float64 `json:"fiftyTwoWeekHigh"`
	FiftyTwoWeekLow     float64 `json:"fiftyTwoWeekLow"`
	BusinessDate        string  `json:"businessDate"`
	LastUpdatedDateTime string  `json:"lastUpdatedDateTime"`
}

CompanyDetails represents processed company information.

type CompanyDetailsRaw

type CompanyDetailsRaw struct {
	SecurityMcsData struct {
		SecurityID          string  `json:"securityId"`
		OpenPrice           float64 `json:"openPrice"`
		HighPrice           float64 `json:"highPrice"`
		LowPrice            float64 `json:"lowPrice"`
		TotalTradeQuantity  int64   `json:"totalTradeQuantity"`
		TotalTrades         int32   `json:"totalTrades"`
		LastTradedPrice     float64 `json:"lastTradedPrice"`
		PreviousClose       float64 `json:"previousClose"`
		BusinessDate        string  `json:"businessDate"`
		ClosePrice          float64 `json:"closePrice"`
		FiftyTwoWeekHigh    float64 `json:"fiftyTwoWeekHigh"`
		FiftyTwoWeekLow     float64 `json:"fiftyTwoWeekLow"`
		LastUpdatedDateTime string  `json:"lastUpdatedDateTime"`
	} `json:"securityMcsData"`
	SecurityData struct {
		ID               int32  `json:"id"`
		Symbol           string `json:"symbol"`
		SecurityName     string `json:"securityName"`
		ActiveStatus     string `json:"activeStatus"`
		PermittedToTrade string `json:"permittedToTrade"`
		Email            string `json:"email"`
		Sector           string `json:"sector"`
	} `json:"securityData"`
}

CompanyDetailsRaw represents the raw nested company details response.

type CompanyInfo added in v0.2.2

type CompanyInfo struct {
	ID                        int32        `json:"id"`
	CompanyShortName          string       `json:"companyShortName"`
	CompanyName               string       `json:"companyName"`
	Email                     string       `json:"email"`
	CompanyWebsite            string       `json:"companyWebsite"`
	CompanyContactPerson      string       `json:"companyContactPerson"`
	SectorMaster              SectorMaster `json:"sectorMaster"`
	CompanyRegistrationNumber string       `json:"companyRegistrationNumber"`
	ActiveStatus              string       `json:"activeStatus"`
}

CompanyInfo represents company information within classification.

type CompanyNews added in v0.2.1

type CompanyNews struct {
	ID              int32           `json:"id"`
	NewsSource      string          `json:"newsSource"`
	NewsHeadline    string          `json:"newsHeadline"`
	NewsBody        string          `json:"newsBody"`
	NewsType        string          `json:"newsType"`
	ExpiryDate      string          `json:"expiryDate"`
	DividendsNotice *DividendNotice `json:"dividendsNotice"`
}

CompanyNews contains news/announcement details.

type CompanyProfile added in v0.2.1

type CompanyProfile struct {
	CompanyName          string `json:"companyName"`
	CompanyEmail         string `json:"companyEmail"`
	CompanyProfile       string `json:"companyProfile"`
	CompanyContactPerson string `json:"companyContactPerson"`
	LogoFilePath         string `json:"logoFilePath"`
	AddressType          string `json:"addressType"`
	AddressField         string `json:"addressField"`
	PhoneNumber          string `json:"phoneNumber"`
	Fax                  string `json:"fax"`
	Town                 string `json:"town"`
}

CompanyProfile represents detailed company profile information.

type Config

type Config struct {
	BaseURL   string
	Endpoints Endpoints
}

Config holds configuration for the NEPSE API client.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default NEPSE API configuration.

type CorporateAction added in v0.2.1

type CorporateAction struct {
	ActiveStatus          string   `json:"activeStatus"`
	AuthorizationComments *string  `json:"authorizationComments"`
	SubmittedDate         string   `json:"submittedDate"`
	FilePath              string   `json:"filePath"`
	DocumentID            int32    `json:"documentId"`
	RatioNum              float64  `json:"ratioNum"`
	RatioDen              float64  `json:"ratioDen"`
	CashDividend          *float64 `json:"cashDividend"`
	FiscalYear            string   `json:"fiscalYear"`
	RightAmountPerShare   *float64 `json:"rightAmountPerShare"`
	BonusPercentage       float64  `json:"bonusPercentage"`
	RightPercentage       *float64 `json:"rightPercentage"`
	SdID                  int32    `json:"sdId"`
}

CorporateAction represents a corporate action (bonus, rights, cash dividend).

func (*CorporateAction) IsBonus added in v0.2.1

func (c *CorporateAction) IsBonus() bool

IsBonus returns true if this corporate action is a bonus share.

func (*CorporateAction) IsCashDividend added in v0.2.1

func (c *CorporateAction) IsCashDividend() bool

IsCashDividend returns true if this corporate action is a cash dividend.

func (*CorporateAction) IsRight added in v0.2.1

func (c *CorporateAction) IsRight() bool

IsRight returns true if this corporate action is a rights issue.

type DepthEntry

type DepthEntry struct {
	StockID  int32   `json:"stockId"`
	Price    float64 `json:"orderBookOrderPrice"`
	Quantity int64   `json:"quantity"`
	Orders   int32   `json:"orderCount"`
	IsBuy    int     `json:"isBuy"`
}

DepthEntry represents a single entry in market depth.

type Dividend added in v0.2.1

type Dividend struct {
	ID                int32        `json:"id"`
	ActiveStatus      string       `json:"activeStatus"`
	ModifiedDate      string       `json:"modifiedDate"`
	ApplicationType   int32        `json:"applicationType"`
	ApplicationStatus int32        `json:"applicationStatus"`
	CompanyNews       *CompanyNews `json:"companyNews"`
}

Dividend represents a dividend declaration.

func (*Dividend) BonusPercentage added in v0.2.1

func (d *Dividend) BonusPercentage() float64

BonusPercentage returns the bonus dividend percentage.

func (*Dividend) CashPercentage added in v0.2.1

func (d *Dividend) CashPercentage() float64

CashPercentage returns the cash dividend percentage.

func (*Dividend) FiscalYear added in v0.2.1

func (d *Dividend) FiscalYear() string

FiscalYear returns the fiscal year of the dividend.

func (*Dividend) HasBonusDividend added in v0.2.1

func (d *Dividend) HasBonusDividend() bool

HasBonusDividend returns true if this dividend includes bonus shares.

func (*Dividend) HasCashDividend added in v0.2.1

func (d *Dividend) HasCashDividend() bool

HasCashDividend returns true if this dividend includes cash.

type DividendNotice added in v0.2.1

type DividendNotice struct {
	ID            int32          `json:"id"`
	FinancialYear *FinancialYear `json:"financialYear"`
	CashDividend  float64        `json:"cashDividend"`
	BonusShare    float64        `json:"bonusShare"`
	RightShare    float64        `json:"rightShare"`
	Remarks       *string        `json:"remarks"`
}

DividendNotice contains dividend declaration details.

type Endpoints

type Endpoints struct {
	// Market data
	MarketSummary string
	MarketOpen    string
	LiveMarket    string
	SupplyDemand  string
	TodaysPrice   string
	FloorSheet    string

	// Index data
	NepseIndex string

	// Top ten lists
	TopGainers     string
	TopLosers      string
	TopTrade       string
	TopTransaction string
	TopTurnover    string

	// Security/Company data
	SecurityList        string
	CompanyList         string
	CompanyDetails      string
	CompanyPriceHistory string
	CompanyFloorsheet   string
	MarketDepth         string

	// Company fundamentals & financial data
	CompanyProfile   string
	BoardOfDirectors string
	CorporateActions string
	Reports          string
	Dividend         string

	// Graph endpoints (index charts)
	GraphNepseIndex            string
	GraphSensitiveIndex        string
	GraphFloatIndex            string
	GraphSensitiveFloatIndex   string
	GraphBankingSubindex       string
	GraphDevBankSubindex       string
	GraphFinanceSubindex       string
	GraphHotelSubindex         string
	GraphHydroSubindex         string
	GraphInvestmentSubindex    string
	GraphLifeInsSubindex       string
	GraphManufacturingSubindex string
	GraphMicrofinanceSubindex  string
	GraphMutualFundSubindex    string
	GraphNonLifeInsSubindex    string
	GraphOthersSubindex        string
	GraphTradingSubindex       string

	// Graph endpoints (company)
	CompanyDailyGraph string
}

Endpoints holds all NEPSE API endpoint paths.

func DefaultEndpoints

func DefaultEndpoints() Endpoints

DefaultEndpoints returns the default NEPSE API endpoints.

type ErrorType

type ErrorType string

ErrorType categorizes NEPSE errors for programmatic handling.

const (
	ErrorTypeInvalidClientRequest  ErrorType = "invalid_client_request"
	ErrorTypeInvalidServerResponse ErrorType = "invalid_server_response"
	ErrorTypeTokenExpired          ErrorType = "token_expired"
	ErrorTypeNetworkError          ErrorType = "network_error"
	ErrorTypeUnauthorized          ErrorType = "unauthorized"
	ErrorTypeNotFound              ErrorType = "not_found"
	ErrorTypeRateLimit             ErrorType = "rate_limit"
	ErrorTypeInternal              ErrorType = "internal_error"
)

type FinancialYear added in v0.2.1

type FinancialYear struct {
	ID           int32  `json:"id"`
	FYName       string `json:"fyName"`
	FYNameNepali string `json:"fyNameNepali"`
	FromYear     string `json:"fromYear"`
	ToYear       string `json:"toYear"`
}

FinancialYear represents a fiscal year.

type FiscalReport added in v0.2.1

type FiscalReport struct {
	ID               int32             `json:"id"`
	QuarterMaster    *QuarterMaster    `json:"quarterMaster"`
	ReportTypeMaster *ReportTypeMaster `json:"reportTypeMaster"`
	FinancialYear    *FinancialYear    `json:"financialYear"`
	PEValue          float64           `json:"peValue"`
	EPSValue         float64           `json:"epsValue"`
	PaidUpCapital    float64           `json:"paidUpCapital"`
	ProfitAmount     float64           `json:"profitAmount"`
	NetWorthPerShare float64           `json:"netWorthPerShare"`
	Remarks          *string           `json:"remarks"`
}

FiscalReport contains financial metrics from a report.

type FloorSheetEntry

type FloorSheetEntry struct {
	ContractID       int64   `json:"contractId"`
	StockSymbol      string  `json:"stockSymbol"`
	SecurityName     string  `json:"securityName"`
	BuyerMemberID    int32   `json:"buyerMemberId"`
	SellerMemberID   int32   `json:"sellerMemberId"`
	ContractQuantity int64   `json:"contractQuantity"`
	ContractRate     float64 `json:"contractRate"`
	BusinessDate     string  `json:"businessDate"`
	TradeTime        string  `json:"tradeTime"`
	SecurityID       int32   `json:"securityId"`
	ContractAmount   float64 `json:"contractAmount"`
	BuyerBrokerName  string  `json:"buyerBrokerName"`
	SellerBrokerName string  `json:"sellerBrokerName"`
	TradeBookID      int64   `json:"tradeBookId"`
}

FloorSheetEntry represents a single floor sheet entry.

type FloorSheetResponse

type FloorSheetResponse struct {
	FloorSheets struct {
		Content          []FloorSheetEntry `json:"content"`
		PageNumber       int32             `json:"number"`
		Size             int32             `json:"size"`
		TotalElements    int64             `json:"totalElements"`
		TotalPages       int32             `json:"totalPages"`
		First            bool              `json:"first"`
		Last             bool              `json:"last"`
		NumberOfElements int32             `json:"numberOfElements"`
	} `json:"floorsheets"`
}

FloorSheetResponse represents the paginated floor sheet response.

type GraphDataPoint

type GraphDataPoint struct {
	Timestamp int64
	Value     float64
}

GraphDataPoint represents a single data point in graph data. The NEPSE API returns different formats for different endpoints: - Index graphs: [timestamp, value] arrays - Scrip graphs: {"time": timestamp, "value": value} objects

func (*GraphDataPoint) UnmarshalJSON added in v0.1.2

func (g *GraphDataPoint) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom unmarshaling for GraphDataPoint. Handles both array format [timestamp, value] and object format {"time": ..., "value": ...}.

type GraphResponse

type GraphResponse struct {
	Data []GraphDataPoint
}

GraphResponse represents graph data response.

type IndexType

type IndexType int

IndexType represents the type of market index for graph data retrieval.

const (
	IndexNepse IndexType = iota
	IndexSensitive
	IndexFloat
	IndexSensitiveFloat
	IndexBanking
	IndexDevBank
	IndexFinance
	IndexHotelTourism
	IndexHydro
	IndexInvestment
	IndexLifeInsurance
	IndexManufacturing
	IndexMicrofinance
	IndexMutualFund
	IndexNonLifeInsurance
	IndexOthers
	IndexTrading
)

type InstrumentType added in v0.2.2

type InstrumentType struct {
	ID           int32  `json:"id"`
	Code         string `json:"code"`
	Description  string `json:"description"`
	ActiveStatus string `json:"activeStatus"`
}

InstrumentType represents the type of financial instrument.

type LiveMarketEntry

type LiveMarketEntry struct {
	SecurityID          string  `json:"securityId"`
	Symbol              string  `json:"symbol"`
	SecurityName        string  `json:"securityName"`
	OpenPrice           float64 `json:"openPrice"`
	HighPrice           float64 `json:"highPrice"`
	LowPrice            float64 `json:"lowPrice"`
	LastTradedPrice     float64 `json:"lastTradedPrice"`
	TotalTradeQuantity  int64   `json:"totalTradeQuantity"`
	TotalTradeValue     float64 `json:"totalTradeValue"`
	PreviousClose       float64 `json:"previousClose"`
	PercentageChange    float64 `json:"percentageChange"`
	LastTradedVolume    int64   `json:"lastTradedVolume"`
	LastUpdatedDateTime string  `json:"lastUpdatedDateTime"`
	AverageTradedPrice  float64 `json:"averageTradedPrice"`
}

LiveMarketEntry represents live market data entry.

type MarketDepth

type MarketDepth struct {
	TotalBuyQty  int64
	TotalSellQty int64
	BuyDepth     []DepthEntry
	SellDepth    []DepthEntry
}

MarketDepth represents processed market depth information.

type MarketDepthRaw

type MarketDepthRaw struct {
	TotalBuyQty  int64 `json:"totalBuyQty"`
	TotalSellQty int64 `json:"totalSellQty"`
	MarketDepth  struct {
		BuyList  []DepthEntry `json:"buyMarketDepthList"`
		SellList []DepthEntry `json:"sellMarketDepthList"`
	} `json:"marketDepth"`
}

MarketDepthRaw represents the raw API response for market depth.

type MarketStatus

type MarketStatus struct {
	IsOpen string `json:"isOpen"`
	AsOf   string `json:"asOf"`
	ID     int32  `json:"id"`
}

MarketStatus represents the current market status.

func (*MarketStatus) IsMarketOpen

func (m *MarketStatus) IsMarketOpen() bool

IsMarketOpen returns true if the market is currently open.

type MarketSummary

type MarketSummary struct {
	TotalTurnover             float64
	TotalTradedShares         float64
	TotalTransactions         float64
	TotalScripsTraded         float64
	TotalMarketCapitalization float64
	TotalFloatMarketCap       float64
}

MarketSummary represents the processed market summary data.

type MarketSummaryItem

type MarketSummaryItem struct {
	Detail string  `json:"detail"`
	Value  float64 `json:"value"`
}

MarketSummaryItem represents a single item in the market summary response.

type NepseError

type NepseError struct {
	Type    ErrorType // Category of error
	Message string    // Human-readable description
	Err     error     // Underlying error, if any
}

NepseError is the error type returned by all NEPSE API operations. Use errors.Is with sentinel errors (e.g., ErrNotFound) to check error categories, or errors.As to extract the full error details.

func MapHTTPStatusToError

func MapHTTPStatusToError(statusCode int, message string) *NepseError

MapHTTPStatusToError converts an HTTP status code to the appropriate NepseError.

func NewInternalError

func NewInternalError(message string, err error) *NepseError

NewInternalError wraps unexpected internal failures.

func NewInvalidClientRequestError

func NewInvalidClientRequestError(message string) *NepseError

NewInvalidClientRequestError returns an error for malformed requests (HTTP 400).

func NewInvalidServerResponseError

func NewInvalidServerResponseError(message string) *NepseError

NewInvalidServerResponseError returns an error for unexpected server responses (5xx).

func NewNepseError

func NewNepseError(errorType ErrorType, message string, err error) *NepseError

NewNepseError constructs an error with the given type, message, and optional wrapped error.

func NewNetworkError

func NewNetworkError(err error) *NepseError

NewNetworkError wraps a low-level network failure (DNS, connection, timeout).

func NewNotFoundError

func NewNotFoundError(resource string) *NepseError

NewNotFoundError returns an error for missing resources (HTTP 404). If resource is empty, a generic message is used.

func NewRateLimitError

func NewRateLimitError() *NepseError

NewRateLimitError returns an error when API rate limits are exceeded (HTTP 429).

func NewTokenExpiredError

func NewTokenExpiredError() *NepseError

NewTokenExpiredError returns an error indicating the access token has expired.

func NewUnauthorizedError

func NewUnauthorizedError(message string) *NepseError

NewUnauthorizedError returns an error for forbidden access (HTTP 403). If message is empty, a default message is used.

func (*NepseError) Error

func (e *NepseError) Error() string

Error implements the error interface.

func (*NepseError) Is

func (e *NepseError) Is(target error) bool

Is reports whether e matches target by comparing ErrorType fields.

func (*NepseError) IsRetryable

func (e *NepseError) IsRetryable() bool

IsRetryable reports whether the operation that caused this error may succeed on retry. Token expiration, network errors, server errors, and rate limits are considered retryable.

func (*NepseError) Unwrap

func (e *NepseError) Unwrap() error

Unwrap returns the underlying error.

type NepseIndex

type NepseIndex struct {
	IndexValue       float64 `json:"close"`
	PercentChange    float64 `json:"perChange"`
	PointChange      float64 `json:"change"`
	High             float64 `json:"high"`
	Low              float64 `json:"low"`
	PreviousClose    float64 `json:"previousClose"`
	FiftyTwoWeekHigh float64 `json:"fiftyTwoWeekHigh"`
	FiftyTwoWeekLow  float64 `json:"fiftyTwoWeekLow"`
	CurrentValue     float64 `json:"currentValue"`
	GeneratedTime    string  `json:"generatedTime"`
}

NepseIndex represents the NEPSE main index (ID 58).

type NepseIndexRaw

type NepseIndexRaw struct {
	ID               int32   `json:"id"`
	Index            string  `json:"index"`
	Close            float64 `json:"close"`
	High             float64 `json:"high"`
	Low              float64 `json:"low"`
	PreviousClose    float64 `json:"previousClose"`
	Change           float64 `json:"change"`
	PerChange        float64 `json:"perChange"`
	FiftyTwoWeekHigh float64 `json:"fiftyTwoWeekHigh"`
	FiftyTwoWeekLow  float64 `json:"fiftyTwoWeekLow"`
	CurrentValue     float64 `json:"currentValue"`
	GeneratedTime    string  `json:"generatedTime"`
}

NepseIndexRaw represents the raw NEPSE index response item.

type Options

type Options struct {
	BaseURL         string        // Override default API URL (useful for testing/proxying)
	TLSVerification bool          // Set false only for development; NEPSE uses self-signed certs
	HTTPTimeout     time.Duration // Per-request timeout
	MaxRetries      int           // Retry count for transient failures (5xx, rate limits)
	RetryDelay      time.Duration // Base delay; actual delay uses exponential backoff
	Config          *Config       // API endpoint paths and headers
	HTTPClient      *http.Client  // Bring your own client; nil uses sensible defaults
}

Options configures the NEPSE client.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns sensible defaults for the NEPSE client.

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Content          []T   `json:"content"`
	PageNumber       int32 `json:"number"`
	Size             int32 `json:"size"`
	TotalElements    int64 `json:"totalElements"`
	TotalPages       int32 `json:"totalPages"`
	First            bool  `json:"first"`
	Last             bool  `json:"last"`
	NumberOfElements int32 `json:"numberOfElements"`
}

PaginatedResponse represents a generic paginated response.

type ParsedValue added in v0.2.2

type ParsedValue struct {
	Source      string  `json:"source"`
	ParsedValue float64 `json:"parsedValue"`
}

ParsedValue represents a value with its source string and parsed numeric value.

type PriceHistory

type PriceHistory struct {
	BusinessDate        string  `json:"businessDate"`
	HighPrice           float64 `json:"highPrice"`
	LowPrice            float64 `json:"lowPrice"`
	ClosePrice          float64 `json:"closePrice"`
	TotalTradedQuantity int64   `json:"totalTradedQuantity"`
	TotalTradedValue    float64 `json:"totalTradedValue"`
	TotalTrades         int32   `json:"totalTrades"`
}

PriceHistory represents historical OHLCV data for a security. Note: NEPSE API does not provide open price in historical data.

type QuarterMaster added in v0.2.1

type QuarterMaster struct {
	ID          int32  `json:"id"`
	QuarterName string `json:"quarterName"`
}

QuarterMaster represents a fiscal quarter.

type Report added in v0.2.1

type Report struct {
	ID                             int32            `json:"id"`
	ActiveStatus                   string           `json:"activeStatus"`
	ModifiedDate                   string           `json:"modifiedDate"`
	ApplicationType                int32            `json:"applicationType"`
	ApplicationStatus              int32            `json:"applicationStatus"`
	FiscalReport                   *FiscalReport    `json:"fiscalReport"`
	ApplicationDocumentDetailsList []ReportDocument `json:"applicationDocumentDetailsList"`
}

Report represents a quarterly or annual financial report.

func (*Report) IsAnnual added in v0.2.1

func (r *Report) IsAnnual() bool

IsAnnual returns true if this is an annual report.

func (*Report) IsQuarterly added in v0.2.1

func (r *Report) IsQuarterly() bool

IsQuarterly returns true if this is a quarterly report.

func (*Report) QuarterName added in v0.2.1

func (r *Report) QuarterName() string

QuarterName returns the quarter name (e.g., "First Quarter") or empty if annual.

type ReportDocument added in v0.2.1

type ReportDocument struct {
	ID            int32  `json:"id"`
	SubmittedDate string `json:"submittedDate"`
	FilePath      string `json:"filePath"`
	EncryptedID   string `json:"encryptedId"`
}

ReportDocument represents a document attached to a report.

type ReportTypeMaster added in v0.2.1

type ReportTypeMaster struct {
	ID         int32  `json:"id"`
	ReportName string `json:"reportName"`
}

ReportTypeMaster represents a report type (Annual/Quarterly).

type SectorMaster added in v0.2.2

type SectorMaster struct {
	ID                int32  `json:"id"`
	SectorDescription string `json:"sectorDescription"`
	ActiveStatus      string `json:"activeStatus"`
	RegulatoryBody    string `json:"regulatoryBody"`
}

SectorMaster represents sector information.

type SectorScrips

type SectorScrips map[string][]string

SectorScrips represents scrips grouped by sector.

type Security

type Security struct {
	ID           int32  `json:"id"`
	Symbol       string `json:"symbol"`
	SecurityName string `json:"securityName"`
	ActiveStatus string `json:"activeStatus"`
}

Security represents a listed security/company. Note: The security list API only returns id, symbol, securityName, and activeStatus. For sector info, use GetCompanyList() instead.

type SecurityDetail added in v0.2.4

type SecurityDetail struct {
	// Basic info
	ID               int32   `json:"id"`
	Symbol           string  `json:"symbol"`
	ISIN             string  `json:"isin"`
	PermittedToTrade string  `json:"permittedToTrade"`
	FaceValue        float64 `json:"faceValue"` // Typically 100 or 10

	// Shareholding data
	ListedShares    int64   `json:"listedShares"`
	PaidUpCapital   float64 `json:"paidUpCapital"`
	IssuedCapital   float64 `json:"issuedCapital"`
	MarketCap       float64 `json:"marketCap"`
	PublicShares    int64   `json:"publicShares"`
	PublicPercent   float64 `json:"publicPercent"`
	PromoterShares  int64   `json:"promoterShares"`
	PromoterPercent float64 `json:"promoterPercent"`

	// Price data
	OpenPrice           float64 `json:"openPrice"`
	HighPrice           float64 `json:"highPrice"`
	LowPrice            float64 `json:"lowPrice"`
	ClosePrice          float64 `json:"closePrice"`
	LastTradedPrice     float64 `json:"lastTradedPrice"`
	PreviousClose       float64 `json:"previousClose"`
	TotalTradedQuantity int64   `json:"totalTradedQuantity"`
	TotalTrades         int32   `json:"totalTrades"`
	FiftyTwoWeekHigh    float64 `json:"fiftyTwoWeekHigh"`
	FiftyTwoWeekLow     float64 `json:"fiftyTwoWeekLow"`
	BusinessDate        string  `json:"businessDate"`
	LastUpdatedDateTime string  `json:"lastUpdatedDateTime"`
}

SecurityDetail represents comprehensive security information including shareholding. Use Client.SecurityDetail to fetch this data via POST request.

type SecurityDetailRaw added in v0.2.4

type SecurityDetailRaw struct {
	Security struct {
		ID               int32   `json:"id"`
		Symbol           string  `json:"symbol"`
		Isin             string  `json:"isin"`
		PermittedToTrade string  `json:"permittedToTrade"`
		FaceValue        float64 `json:"faceValue"`
	} `json:"security"`
	SecurityDailyTradeDTO struct {
		SecurityID          string  `json:"securityId"`
		OpenPrice           float64 `json:"openPrice"`
		HighPrice           float64 `json:"highPrice"`
		LowPrice            float64 `json:"lowPrice"`
		ClosePrice          float64 `json:"closePrice"`
		TotalTradeQuantity  int64   `json:"totalTradeQuantity"`
		TotalTrades         int32   `json:"totalTrades"`
		LastTradedPrice     float64 `json:"lastTradedPrice"`
		PreviousClose       float64 `json:"previousClose"`
		FiftyTwoWeekHigh    float64 `json:"fiftyTwoWeekHigh"`
		FiftyTwoWeekLow     float64 `json:"fiftyTwoWeekLow"`
		LastUpdatedDateTime string  `json:"lastUpdatedDateTime"`
		BusinessDate        string  `json:"businessDate"`
	} `json:"securityDailyTradeDto"`

	// Shareholding data at root level
	StockListedShares    float64 `json:"stockListedShares"`
	PaidUpCapital        float64 `json:"paidUpCapital"`
	IssuedCapital        float64 `json:"issuedCapital"`
	MarketCapitalization float64 `json:"marketCapitalization"`
	PublicShares         int64   `json:"publicShares"`
	PublicPercentage     float64 `json:"publicPercentage"`
	PromoterShares       float64 `json:"promoterShares"`
	PromoterPercentage   float64 `json:"promoterPercentage"`
}

SecurityDetailRaw represents the raw response from POST /api/nots/security/{id}. This endpoint returns additional shareholding data not available via GET.

type ShareGroup added in v0.2.2

type ShareGroup struct {
	ID              int32   `json:"id"`
	Name            string  `json:"name"`
	Description     string  `json:"description"`
	CapitalRangeMin int64   `json:"capitalRangeMin"`
	ModifiedBy      *string `json:"modifiedBy"`
	ModifiedDate    *string `json:"modifiedDate"`
	ActiveStatus    string  `json:"activeStatus"`
	IsDefault       string  `json:"isDefault"`
}

ShareGroup represents the share group classification.

type SubIndex

type SubIndex struct {
	ID               int32   `json:"id"`
	Index            string  `json:"index"`
	Close            float64 `json:"close"`
	High             float64 `json:"high"`
	Low              float64 `json:"low"`
	PreviousClose    float64 `json:"previousClose"`
	Change           float64 `json:"change"`
	PerChange        float64 `json:"perChange"`
	FiftyTwoWeekHigh float64 `json:"fiftyTwoWeekHigh"`
	FiftyTwoWeekLow  float64 `json:"fiftyTwoWeekLow"`
	CurrentValue     float64 `json:"currentValue"`
	GeneratedTime    string  `json:"generatedTime"`
}

SubIndex represents a sector sub-index.

type SupplyDemandData

type SupplyDemandData struct {
	SupplyList []SupplyDemandItem `json:"supplyList"`
	DemandList []SupplyDemandItem `json:"demandList"`
}

SupplyDemandData represents the combined supply and demand response.

type SupplyDemandItem

type SupplyDemandItem struct {
	SecurityID    int32  `json:"securityId"`
	Symbol        string `json:"symbol"`
	SecurityName  string `json:"securityName"`
	TotalQuantity int64  `json:"totalQuantity"`
	TotalOrder    int32  `json:"totalOrder"`
}

SupplyDemandItem represents a single item in supply or demand list.

type TodayPrice

type TodayPrice struct {
	ID                  int32   `json:"id"`
	Symbol              string  `json:"symbol"`
	SecurityName        string  `json:"securityName"`
	OpenPrice           float64 `json:"openPrice"`
	HighPrice           float64 `json:"highPrice"`
	LowPrice            float64 `json:"lowPrice"`
	ClosePrice          float64 `json:"closePrice"`
	TotalTradedQuantity int64   `json:"totalTradedQuantity"`
	TotalTradedValue    float64 `json:"totalTradedValue"`
	PreviousClose       float64 `json:"previousClose"`
	DifferenceRs        float64 `json:"differenceRs"`
	PercentageChange    float64 `json:"percentageChange"`
	TotalTrades         int32   `json:"totalTrades"`
	BusinessDate        string  `json:"businessDate"`
	SecurityID          int32   `json:"securityId"`
	LastTradedPrice     float64 `json:"lastTradedPrice"`
	MaxPrice            float64 `json:"maxPrice"`
	MinPrice            float64 `json:"minPrice"`
}

TodayPrice represents today's price data for a security.

type TopGainerLoserEntry

type TopGainerLoserEntry struct {
	Symbol           string  `json:"symbol"`
	SecurityName     string  `json:"securityName"`
	SecurityID       int32   `json:"securityId"`
	LTP              float64 `json:"ltp"`
	PointChange      float64 `json:"pointChange"`
	PercentageChange float64 `json:"percentageChange"`
}

TopGainerLoserEntry represents entries in top gainers/losers lists.

type TopListEntry

type TopListEntry struct {
	Symbol              string  `json:"symbol"`
	SecurityName        string  `json:"securityName"`
	ClosePrice          float64 `json:"closePrice"`
	PercentageChange    float64 `json:"percentageChange"`
	DifferenceRs        float64 `json:"differenceRs"`
	TotalTradedQuantity int64   `json:"totalTradedQuantity"`
	TotalTradedValue    float64 `json:"totalTradedValue"`
	TotalTrades         int32   `json:"totalTrades"`
	HighPrice           float64 `json:"highPrice,omitempty"`
	LowPrice            float64 `json:"lowPrice,omitempty"`
	OpenPrice           float64 `json:"openPrice,omitempty"`
	PreviousClose       float64 `json:"previousClose,omitempty"`
}

TopListEntry is deprecated, use specific types instead. Kept for backward compatibility.

type TopTradeEntry

type TopTradeEntry struct {
	Symbol       string  `json:"symbol"`
	SecurityName string  `json:"securityName"`
	SecurityID   int32   `json:"securityId"`
	ShareTraded  int64   `json:"shareTraded"`
	ClosingPrice float64 `json:"closingPrice"`
}

TopTradeEntry represents entries in top trade (volume) list.

type TopTransactionEntry

type TopTransactionEntry struct {
	Symbol          string  `json:"symbol"`
	SecurityName    string  `json:"securityName"`
	SecurityID      int32   `json:"securityId"`
	TotalTrades     int32   `json:"totalTrades"`
	LastTradedPrice float64 `json:"lastTradedPrice"`
}

TopTransactionEntry represents entries in top transaction list.

type TopTurnoverEntry

type TopTurnoverEntry struct {
	Symbol       string  `json:"symbol"`
	SecurityName string  `json:"securityName"`
	SecurityID   int32   `json:"securityId"`
	Turnover     float64 `json:"turnover"`
	ClosingPrice float64 `json:"closingPrice"`
}

TopTurnoverEntry represents entries in top turnover list.

Directories

Path Synopsis
_examples
basic command
debug command
explore command
server command
internal
auth
Package auth handles NEPSE API authentication using embedded WASM to decode obfuscated tokens returned by the NEPSE API.
Package auth handles NEPSE API authentication using embedded WASM to decode obfuscated tokens returned by the NEPSE API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL