Security Client

nepse.SecurityClient

class nepse.security.core.SecurityClient(client_wrapper: nepse.utils._ClientWrapperHTTPX, cache_retain_time: Optional[int] = 60, use_cache: Optional[bool] = False)

Bases: object

async get_company(symbol: str, use_cache: Optional[bool] = None) nepse.security.types.SecurityResponse

Get company by its symbol

Parameters
  • symbol (str) – The symbol of the company/security

  • use_cache (Optional[bool]) – Use cache or fetch from API. Defaults to nepse.use_cache user provided during initializtion of nepse.

Returns

The response object

Return type

SecurityResponse

async get_companies(use_cache: Optional[bool] = None) List[nepse.security.types.SecurityResponse]

Returns all the companies/securities

Parameters

use_cache (Optional[bool]) – Use cache or fetch from API. Defaults to nepse.use_cache user provided during initializtion of nepse.

Returns

List of the response object

Return type

List[SecurityResponse]

async get_company_detailed(security_id: int) nepse.security.types.SecurityResponseDetailed

Returns the detailed object of a company

Parameters

security_id (int) – The security_id of the company/security_id

Raises

NotFound – Raised if the given security_id is not valid

Returns

A detailed response object of the company

Return type

SecurityResponseDetailed

async get_company_live_price(symbol: str) nepse.security.types.LiveSecurityTrade

Returns the live prices of the company_id

Parameters

symbol (str) – Symbol of the company to fetch

Raises

NotFound – Raised if the given symbol is not valid

Returns

Object with live trade data

Return type

LiveSecurityTrade

async get_companies_live_prices() List[nepse.security.types.LiveSecurityTrade]

Returns all the companies taking part in the trade today

Returns

List of Objects containing the live trade data of

companies

Return type

List[LiveSecurityTrade]

async get_company_history(company_id: int) List[nepse.security.types.CompanyHistory]

Returns the history of the company

Parameters

company_id (int) – ID of the company user wants to get data of

Returns

List of Objects containing the history of the company

Return type

List[CompanyHistory]

async get_top_gainers() nepse.security.types.Gainer

Returns the top gainers for the current day

Returns

List of Objects containing the top gainers for the day

Return type

TopGainers

async get_top_losers() nepse.security.types.Loser

Returns the top losers for the current day

Returns

List of Objects containing the top losers for the day

Return type

TopLosers

nepse.SecurityClient.types

class nepse.security.types.Instrument(id: int, code: str, description: str, active_status: str)

Bases: object

id: int
code: str
description: str
active_status: str
class nepse.security.types.ShareGroup(id: int, name: str, description: str, capital_range_min: int, modified_by: str, modified_date: datetime.date, active_status: str, is_default: str)

Bases: object

id: int
name: str
description: str
capital_range_min: int
modified_by: str
modified_date: datetime.date
active_status: str
is_default: str
class nepse.security.types.SectorMaster(id: int, sector_description: str, active_status: str, regulatory_body: str)

Bases: object

id: int
sector_description: str
active_status: str
regulatory_body: str
class nepse.security.types.Company(id: int, company_short_name: str, company_name: str, email: str, company_website: str, company_contact_person: str, sector_master: nepse.security.types.SectorMaster, company_registration_number: int, active_status: str)

Bases: object

id: int
company_short_name: str
company_name: str
email: str
company_website: str
company_contact_person: str
sector_master: nepse.security.types.SectorMaster
company_registration_number: int
active_status: str
class nepse.security.types.Security(id: int, symbol: str, isin: str, permitted_to_trade: bool, listing_date: datetime.date, credit_rating: Any, tick_size: int, instrument_type: nepse.security.types.Instrument, capital_gain_base_date: datetime.date, face_value: int, high_range_dpr: Any, issuer_name: str, me_instance_number: int, parent_id: int, record_type: int, scheme_description: str, scheme_name: str, secured: Any, series: Any, active_status: str, divisor: int, cds_stock_ref_id: int, security_name: str, trading_start_date: datetime.datetime, networth_base_price: float, security_trade_cycle: int, is_promoter: bool, company_id: nepse.security.types.Company, share_group_id: nepse.security.types.ShareGroup)

Bases: object

id: int
symbol: str
isin: str
permitted_to_trade: bool
listing_date: datetime.date
credit_rating: Any
tick_size: int
instrument_type: nepse.security.types.Instrument
capital_gain_base_date: datetime.date
face_value: int
high_range_dpr: Any
issuer_name: str
me_instance_number: int
parent_id: int
record_type: int
scheme_description: str
scheme_name: str
secured: Any
series: Any
active_status: str
divisor: int
cds_stock_ref_id: int
security_name: str
trading_start_date: datetime.datetime
networth_base_price: float
security_trade_cycle: int
is_promoter: bool
company_id: nepse.security.types.Company
share_group_id: nepse.security.types.ShareGroup
class nepse.security.types.DailyTrade(security_id: int, open_price: int, high_price: int, low_price: int, total_trade_quantity: int, total_trades: int, last_traded_price: int, previous_close: int, business_date: datetime.date, close_price: int, fifty_two_week_high: int, fifty_two_week_low: int, last_updated_date_time: datetime.time)

Bases: object

security_id: int
open_price: int
high_price: int
low_price: int
total_trade_quantity: int
total_trades: int
last_traded_price: int
previous_close: int
business_date: datetime.date
close_price: int
fifty_two_week_high: int
fifty_two_week_low: int
last_updated_date_time: datetime.time
class nepse.security.types.SecurityResponseDetailed(security_daily_trade_dto: nepse.security.types.DailyTrade, security: nepse.security.types.Security, stock_listed_shares: int, paid_up_capital: int, issued_capital: int, market_capitalization: int, public_shares: int, public_percentage: int, promoter_shares: int, promoter_percentage: int, updated_date: datetime.date, security_id: int)

Bases: object

security_daily_trade_dto: nepse.security.types.DailyTrade
security: nepse.security.types.Security
stock_listed_shares: int
paid_up_capital: int
issued_capital: int
market_capitalization: int
public_shares: int
public_percentage: int
promoter_shares: int
promoter_percentage: int
updated_date: datetime.date
security_id: int
class nepse.security.types.SecurityResponse(security_id: int, security_name: str, symbol: str, index_id: int, open_price: int, high_price: int, low_price: int, total_trade_quantity: int, last_traded_price: int, percentage_change: float, last_updated_date_time: datetime.datetime, last_traded_volume: Any, previous_close: int, total_trade_value: int)

Bases: object

security_id: int
security_name: str
symbol: str
index_id: int
open_price: int
high_price: int
low_price: int
total_trade_quantity: int
last_traded_price: int
percentage_change: float
last_updated_date_time: datetime.datetime
last_traded_volume: Any
previous_close: int
total_trade_value: int
class nepse.security.types.LiveSecurityTrade(id: int, business_date: datetime.date, security_id: int, symbol: str, security_name: str, open_price: int, high_price: int, low_price: int, close_price: int, total_traded_quantity: int, total_traded_value: int, previous_day_close_price: int, fifty_two_week_high: int, fifty_two_week_low: int, last_updated_time: datetime.datetime, last_updated_price: int, total_trades: int, average_traded_price: float, market_capitalization: float)

Bases: object

id: int
business_date: datetime.date
security_id: int
symbol: str
security_name: str
open_price: int
high_price: int
low_price: int
close_price: int
total_traded_quantity: int
total_traded_value: int
previous_day_close_price: int
fifty_two_week_high: int
fifty_two_week_low: int
last_updated_time: datetime.datetime
last_updated_price: int
total_trades: int
average_traded_price: float
market_capitalization: float
class nepse.security.types.CompanyHistory(business_date: datetime.date, open_price: int, high_price: int, low_price: int, previous_day_close_price: int, fifty_two_week_high: int, last_traded_price: int, total_traded_quantity: int, close_price: int)

Bases: object

business_date: datetime.date
open_price: int
high_price: int
low_price: int
previous_day_close_price: int
fifty_two_week_high: int
last_traded_price: int
total_traded_quantity: int
close_price: int
class nepse.security.types.TopGainLose(symbol: str, ltp: int, point_change: float, percentage_change: float, security_name: str, security_id: int)

Bases: object

symbol: str
ltp: int
point_change: float
percentage_change: float
security_name: str
security_id: int
class nepse.security.types.Gainer(symbol: str, ltp: int, point_change: float, percentage_change: float, security_name: str, security_id: int)

Bases: nepse.security.types.TopGainLose

symbol: str
ltp: int
point_change: float
percentage_change: float
security_name: str
security_id: int
class nepse.security.types.Loser(symbol: str, ltp: int, point_change: float, percentage_change: float, security_name: str, security_id: int)

Bases: nepse.security.types.TopGainLose

symbol: str
ltp: int
point_change: float
percentage_change: float
security_name: str
security_id: int