trader is a Python 3 module that provides functions for downloading and processing stock market data.
It is intended to serve as a back-end module for a GUI application that uses its functionality. However, users are free to use the module for other purposes.
- NSE Indices (India)
- NSE Equities (India)
- NSE Futures (India)
This module provides the following public functions:
process_nse_indices()- Download and process NSE Indices data, saving the results as CSV files.
process_nse_equities()- Download and process NSE Equities data, saving the results as CSV files.
process_nse_futures()- Download and process NSE Futures data, saving the results as CSV files.
download_file()- Download files from the internet.
apply_server_timestamp()- Apply the Last-Modified timestamp from the HTTP response headers to files.
to_datetime_date()- Return a
datetime.dateobject when possible; otherwise, returnNone. create_folder()- Create a folder safely.
get_request_headers()- Return the request headers dictionary used by
download_file(). unzip()- Extract the contents of a ZIP archive into the current working directory.
write_csv()- Generate and save a CSV file using the supplied arguments.
See the docstrings of individual private functions for details:
_read_input_as_list()_convert_dash_to_zero()_convert_blank_to_zero()_sanitize_ohlc()_pop_unnecessary_keys()_format_output_data()_finalize_output()_download_nse_indices()_download_nse_equities()_download_nse_futures()_get_nse_indices_fieldnames()_get_nse_equities_fieldnames()_get_nse_futures_fieldnames()_get_nse_indices_filenames()_get_nse_equities_filenames()_get_nse_futures_filenames()_manipulate_nse_indices()_manipulate_nse_equities()_manipulate_nse_futures()_parse_nse_indices()_parse_nse_equities()_parse_nse_futures()_output_nse_indices()_output_nse_equities()_output_nse_futures()
DEBUGGING- When
True, no attempt is made to download files. DOWNLOAD_DIR- Directory used to store downloaded files.
PROCESSED_DIR- Directory used to store processed files.
Clone the repository and change into the repository directory.
Install the build package and build the source distribution and wheel:
python3 -m pip install --upgrade build python3 -m build
The generated distribution files will be available in the dist/
directory.
Install the package from the locally built distribution files:
python3 -m pip install --upgrade --no-index --find-links=dist/ trader
Note that --no-index prevents pip from accessing package indexes.
Any dependencies not already installed must also be available locally.
Import the module:
import trader
The module provides the following primary functions for downloading and processing stock market data:
process_nse_indices()process_nse_equities()process_nse_futures()
Call the appropriate function to download and process data for the required exchange segment. Refer to the function docstrings for details about the required arguments.
The download_file() function can also be used to download files
from the internet.
- Aditya <code.aditya@gmail.com>
trader is free and open-source software distributed under the GNU General Public License, version 3 or (at your option) any later version.
See the GNU General Public License v3.