This repository contains a Python script for margin validation in financial data.
The validate_margin_transfer.py
script is designed to validate margins in financial data stored in a database.
It performs two checks: it ensures that the previous day end-of-day margins match the last intraday margins of the previous day.
It also checks that the previous day end-of-day margins match the first intraday margins of the following day.
If any discrepancies are found, the script logs them and sends alert emails to stakeholders.
- Validates end-of-day margins against respective intraday margins of the previous and following day.
- Logs discrepancies to a log file (
margin_validation.log
). - Sends alert emails if discrepancies are found.
- Ensure Python 3.x is installed on your system.
- Install required dependencies listed in
requirements.txt
. When using pip:pip install -r requirements.txt
- Create locally the
credentials.py
file with your email sender and receiver credentials. Seecredentials_example.py
. - Run the script to populate the SQLite database with example data:
This script (
python plain_script_version/populate_database.py
populate_database.py
) populates the SQLite database (LZDB_dummy.db
) with example data provided. - Run the script:
python plain_script_version/validate_margin_transfer.py
- Check the standard output, the log file (
margin_validation.log
) and alert emails for notifications.
plain_script_version/
: Contains the main Python scriptvalidate_margin_transfer.py
and the helper scriptpopulate_database.py
.jupyter_notebook/
: Contains the JuPyTer notebook version of the script. With long comments regarding the code it is useful for understanding.credentials.py
: File to store email credentials (not included in the public repository).README.md
: This file providing an overview of the project.
This project is licensed under the MIT License. See the LICENSE file for details.