Quickstart¶
This page gives a brief introduction to the library. It assumes you have the library installed, if you don’t check the Installing portion.
Let’s get today’s highest price of Upper Tamakoshi Hydropower Ltd It looks something like this:
1import asyncio
2import httpx
3from nepse import Client
4
5async def main():
6
7 # Initializes the client
8 client = Client()
9
10 # Gets the data
11 data = await client.security_client.get_company(symbol="UPPER")
12
13 # Prints the highest price for that company today
14 print(data.high_price)
15
16 # Closes the session
17 await client.close()
18
19# Run the function
20loop = asyncio.get_event_loop()
21loop.run_until_complete(main())
Let’s name this file nepse_upper.py
. Make sure to not name it nepse.py
as that’ll conflict
with the library
There is not a log going on here. So lets walk you through step by step.
The first line just imports the library and other dependencies, if this raises a ModuleNotFoundError or ImportError then head on over to Installing section to properly install.
Next, we create an instance of a
Client
. This client is the way through which we interact with the NEPSE API.Now, we get the company with symbol UPPER.
We print its highest price for today.
We close the client for cleaning up.
We get the event_loop using asyncio and run the async function in that event_loop.
On Windows:
$ py -3 nepse_upper.py
On other systems:
$ python3 nepse_upper.py