Unofficial Python Api for NSE India stock exchange
Project description
💰 NseIndiaApi
An unofficial Python API for the NSE India stock exchange.
Python version: >= 3.8
If you ❤️ my work so far, please 🌟 this repo.
👽 Documentation
https://bennythadikaran.github.io/NseIndiaApi
Updates
- Prior to v0.2.6, NSE class would exit on unhandled errors. This undesirable behavior has changed. It is left to the user to catch and handle these errors.
- Added a new method: NSE.getFuturesExpiry (See Documentation for details)
🔥 Usage
Install with Pip
pip install -U nse
The class accepts a single argument download_folder
, a str
filepath, or a pathlib object
. The folder stores cookie and any downloaded files.
Simple example
from nse import NSE
from pathlib import Path
# Working directory
DIR = Path(__file__).parent
nse = NSE(download_folder=DIR)
status = nse.status()
advDec = nse.advanceDecline()
nse.exit() # close requests session
Using with statement
with NSE(download_folder=DIR) as nse:
status = nse.status()
advDec = nse.advanceDecline()
Catching errors
from nse import NSE
from datetime import datetime
with NSE('./') as nse:
try:
bhavFile = nse.equityBhavcopy(date=datetime.now())
dlvFile = nse.deliveryBhavcopy(date=datetime.now())
raise RuntimeError('Some error') # force an exception
except RuntimeError as e:
# continue execution or exit the script
print(repr(e))
# execution continues if handled without exit
actions = nse.actions()
# NSE request session closed - continue processing
Samples folder
The src/samples
folder contains sample outputs of various methods. The filenames match the method names. The output has been truncated in some places but demonstrates the overall structure of responses.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nse-0.2.7.post2.tar.gz
(33.4 kB
view hashes)
Built Distribution
nse-0.2.7.post2-py3-none-any.whl
(21.5 kB
view hashes)
Close
Hashes for nse-0.2.7.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62656ec0635f183bccc3adb55827cd23e59bba047eaa07ce68e21a0688ae6c5f |
|
MD5 | 6fe9a6938861615c25d1e00e4303e2ba |
|
BLAKE2b-256 | 77a3e2a25c9234fa95c7ec67360aa0a0a2ad2577800591dfc57d0e2e6b87da91 |