/Margin-Validation-Tool

margin check for Intraday and end of day reports

Primary LanguageJupyter NotebookMIT LicenseMIT

Margin Validation Tool

This repository contains a Python script for margin validation in financial data.

Overview

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.

Features

  • 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.

Usage

  1. Ensure Python 3.x is installed on your system.
  2. Install required dependencies listed in requirements.txt. When using pip:
    pip install -r requirements.txt
  3. Create locally the credentials.py file with your email sender and receiver credentials. See credentials_example.py.
  4. Run the script to populate the SQLite database with example data:
    python plain_script_version/populate_database.py
    This script (populate_database.py) populates the SQLite database (LZDB_dummy.db) with example data provided.
  5. Run the script:
    python plain_script_version/validate_margin_transfer.py
  6. Check the standard output, the log file (margin_validation.log) and alert emails for notifications.

Folder Structure

  • plain_script_version/: Contains the main Python script validate_margin_transfer.py and the helper script populate_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.

License

This project is licensed under the MIT License. See the LICENSE file for details.