nse_workday
A library to calculate holidays, workdays and some other functions based on NSE trading holidays from 2010 - 2025.
**Added option to exclude exceptional trading days**
It can be installed by:
pip install nse-workday
from nse_workday import *
get_new_holidays(mode='test')
Retrieves list of latest holidays from nse and save it if fetched list year > last available holidays year in library
Args::
mode = 'test' / 'normal' . Default 'test' (will not save data.).
get_new_holidays(mode='normal')
No Dates to Exclude
Exceptional Trading Dates (Saturday/Sunday):: ['12-11-2023']
Holidays list :: ['26-01-2023', '07-03-2023', '30-03-2023', '04-04-2023', '07-04-2023', '14-04-2023', '01-05-2023', '29-06-2023', '15-08-2023', '19-09-2023', '02-10-2023', '24-10-2023', '14-11-2023', '27-11-2023', '25-12-2023']
Data already exists
update_holiday(dates_set = 'holidays')
Modify / Add / Remove a date from holidays or exceptions list ( Exception :: Trading days in Saturday/ Sunday)
Args::
dates_set : 'holidays' / 'exceptions' . Default 'holidays'
The date should be entered in dd-mm-yyyy format.
update_holiday()
Select an option:
1. Modify a date
2. Add a date
3. Remove a date
Enter option number: 1
Enter old Date to remove (dd-mm-yyyy): 28-06-2023
Enter the new Date to add (dd-mm-yyyy): 29-06-2023
Do you want to save modified date list? (Y/N): y
Data saved successfully
isHoliday(input_date)
Check the given date is holiday or not . Return Boolean.
Args::
input_date : date in %d-%m-%Y/ datetime.date / datetime.datetime format
isHoliday(input_date="29-06-2023")
True
All below functions returns datetime.datetime item / list.
workday(input_date, direction)
Will return the nearest workday in the given direction if the input_date is holiday. If not, will return the same
Args ::
input_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
direction : 'next' / 'prev'
workday(input_date="29-06-2023",direction='prev')
datetime.datetime(2023, 6, 28, 0, 0)
get_holidays_list(start_date, end_date)
Returns all holidays as a list within the given range
Args::
start_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
end_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
get_holidays_list(start_date="20-6-2023", end_date="30-6-2023")
[datetime.datetime(2023, 6, 24, 0, 0),
datetime.datetime(2023, 6, 25, 0, 0),
datetime.datetime(2023, 6, 29, 0, 0)]
get_workdays_list(start_date, end_date)
Returns all workdays as a list within the given range
Args::
start_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
end_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
get_workdays_list(start_date="20-6-2023", end_date="30-6-2023")
[datetime.datetime(2023, 6, 20, 0, 0),
datetime.datetime(2023, 6, 21, 0, 0),
datetime.datetime(2023, 6, 22, 0, 0),
datetime.datetime(2023, 6, 23, 0, 0),
datetime.datetime(2023, 6, 26, 0, 0),
datetime.datetime(2023, 6, 27, 0, 0),
datetime.datetime(2023, 6, 28, 0, 0),
datetime.datetime(2023, 6, 30, 0, 0)]
get_month_weekdays(input_date, required_weekday, filtered=True)
Return all occurences of the required weekday from the given date month
Args::
input_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
required_weekday : Weekday name (eg. 'Sunday'/'sunday').
filtered : bool . Default True ( Will return the previous work day if a required weekday is holiday.)
get_month_weekdays(input_date="21-6-2023", required_weekday='thursday')
[datetime.datetime(2023, 6, 1, 0, 0),
datetime.datetime(2023, 6, 8, 0, 0),
datetime.datetime(2023, 6, 15, 0, 0),
datetime.datetime(2023, 6, 22, 0, 0),
datetime.datetime(2023, 6, 28, 0, 0)]
month_last_weekday(input_date, last_weekday, filtered=True)
Return last occurence of the required weekday from the given date month
Args::
input_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
last_weekday : Weekday name (eg. 'Sunday'/'sunday').
filtered : bool . Default True (Will return the previous work day if a last weekday is holiday.)
month_last_weekday(input_date="21-6-2023", last_weekday='thursday')
datetime.datetime(2023, 6, 28, 0, 0)
get_weekdays(start_date, end_date, required_weekday, filtered=True)
Return all occurences of the required weekday from the given range
Args::
start_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
end_date : date in %d-%m-%Y / datetime.date / datetime.datetime format
required_weekday : Weekday name (eg. 'Sunday'/'sunday').
filtered : bool . Default True ( Will return the previous work day if a required weekday is holiday.)
get_weekdays(start_date="21-3-2023", end_date="30-6-2023", required_weekday='friday')
[datetime.datetime(2023, 3, 24, 0, 0),
datetime.datetime(2023, 3, 31, 0, 0),
datetime.datetime(2023, 4, 6, 0, 0),
datetime.datetime(2023, 4, 13, 0, 0),
datetime.datetime(2023, 4, 21, 0, 0),
datetime.datetime(2023, 4, 28, 0, 0),
datetime.datetime(2023, 5, 5, 0, 0),
datetime.datetime(2023, 5, 12, 0, 0),
datetime.datetime(2023, 5, 19, 0, 0),
datetime.datetime(2023, 5, 26, 0, 0),
datetime.datetime(2023, 6, 2, 0, 0),
datetime.datetime(2023, 6, 9, 0, 0),
datetime.datetime(2023, 6, 16, 0, 0),
datetime.datetime(2023, 6, 23, 0, 0),
datetime.datetime(2023, 6, 30, 0, 0)]
Metadata
Release files for nse-workday 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nse_workday-0.0.9.tar.gz | 10.5 kB | Without provenance | Details for nse_workday-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nse_workday-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for nse_workday-0.0.9-py3-none-any.whl |
Total release size: 20.2 kB
Release files / nse_workday-0.0.9.tar.gz
| Download URL | nse_workday-0.0.9.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c33747e04f9b507767bbe3e99dd04cb0a8f7fd3c9e060a626dec7ec18ef2e56d
|
|
BLAKE2b-256 checksum How to use checksums |
56723fc66a9a06e0c6de5fe8e55403926eb018480dafcce7149e889daf62a6bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / nse_workday-0.0.9-py3-none-any.whl
| Download URL | nse_workday-0.0.9-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c5bdf77d8d942192d531fa13c4bae17c977078a314c885b860c1f3708c78d623
|
|
BLAKE2b-256 checksum How to use checksums |
52139fc549ab65a10b865f69655aa9b2cef9ff5d78ed8c17a516e6fc1d8f2885
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Security for nse-workday 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.