Skip to content

A Python-based tool for calculating margin values and handling margin calls on futures data from NSE India.

License

Notifications You must be signed in to change notification settings

vineetmehtaa/Futures-Position-and-Margin-Management-Tool

Repository files navigation

Futures Position and Margin Management Tool

This is a Python-based tool for calculating margin values and handling margin calls on futures data from NSE India.

Run Locally

Clone the project

  git clone https://github.com/vineetmehtaa/Futures-Position-and-Margin-Management-Tool.git

Go to the project directory

  cd my-project

Install dependencies

  pip install -r requirements.txt

Download the necessary data from NSE and run the code.

  python3 FuturesPositionAndMarginManagementTool.py

Demo

  1. After downloading the repository, visit the NSE website to find a stock futures contract for a company of your choice. For demonstration, let's use STEEL AUTHORITY OF INDIA LIMITED (INE114A01011).

  2. Under derivatives, find a contract of your choice and note down the Market Lot. NSE Website with SAIL Details

  3. Download the historical data for that contract for your desired time period, and also find the Open Price of the first day of the contract and note it down. SAIL Contract Historical Data

  4. Open the CSV file, convert it to a .xlsx format, rename it to Data.xlsx, and save it in the same folder of the downloaded repository.

  5. Under the equity section, locate the information icon next to Applicable Margin Rate. Click on it to find values of VaR Margin and Applicable Margin Rate, and note it down. Locating necessary rates

  6. You can now run the code using your code editor while loading the folder containing the repository, or execute the following command within the repository:

python3 FuturesPositionAndMarginManagementTool.py
  1. You will see a popup requesting the necessary information you noted earlier. Enter this information and click Submit. Popup Showing Data to be Entered

  2. The following files will be generated: one for the short position, one for the long position, and FSD_Output.xlsx, which combines both workbooks. Generated Files

  3. You will receive raw, unformatted Excel files as output, which will look something like this: Unformatted Output File

However, you can format these files quickly to achieve an output like this or according to your preferences: Final Formatted File

  1. To use the program again, simply run it once more. Note that the existing data in the files will be overwritten, so it’s recommended to move the files to another location or manually delete them to avoid losing any important information.

License

Distributed under the MIT License. See LICENSE.txt for more information.

About

A Python-based tool for calculating margin values and handling margin calls on futures data from NSE India.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages