Skip to content

richasingh-16/portfolio-constraint-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Portfolio Constraint Engine

A quantitative portfolio constraint engine that enforces market cap and sector diversification rules on investment strategies using structured financial datasets.

Overview

This project applies constraints to investment portfolios based on historical market capitalization (MCap) and sector data. It processes raw portfolio selections and outputs constrained portfolios ensuring exposure limits and MCap thresholds are respected.

Features

  • MCap Filtering: Removes bottom 20% of companies by Market Capitalization for each corresponding year. Also drops stocks with missing data.
  • Sector Limits: Caps the weight of any single sector in the portfolio to a maximum of 25% (or 1 stock, whichever is larger). This mechanism drops the lowest MCap companies from the sector until the threshold is met.

Portfolio Constraint Engine

A quantitative portfolio constraint engine that enforces market cap and sector diversification rules on investment strategies using structured financial datasets.

Overview

This project applies constraints to investment portfolios based on historical market capitalization (MCap) and sector data. It processes raw portfolio selections and outputs constrained portfolios ensuring exposure limits and MCap thresholds are respected.

Features

  • MCap Filtering: Removes bottom 20% of companies by Market Capitalization for each corresponding year. Also drops stocks with missing data.
  • Sector Limits: Caps the weight of any single sector in the portfolio to a maximum of 25% (or 1 stock, whichever is larger). This mechanism drops the lowest MCap companies from the sector until the threshold is met.

Directory Structure

  • data/ - Put your input CSV files here:
    • assignment_investment_rules.csv: Historical portfolio holdings
    • assignment_mcap.csv: Market capitalization data over time
    • assignment_sector_data.csv: Sector classification for companies
  • src/
    • portfolio_constraint.py: Main python script to process the data
  • output/ - Intended for the resulting constrained strategies (output.csv).

Requirements

Install required dependencies via:

pip install pandas

Setup & Execution

1. Preparation

Download or copy the 3 required input files (assignment_investment_rules.csv, assignment_mcap.csv, assignment_sector_data.csv) into the directory where you run the script. Note: Depending on how you run the code, you might want to place the CSVs in the src/ folder alongside the script or adjust the pandas read_csv paths in the source files so they point to the data/ folder.

2. Running via Python Script

  1. Open a terminal.
  2. Navigate to the folder containing the .py script and the .csv files.
  3. Run the script:
    python portfolio_constraint.py
  4. A new output.csv file will be generated in the same folder.

Constraints Details

  • Input Data Format: The assignment_investment_rules.csv file contains strategies as strings evaluated to Python lists on execution using ast.literal_eval.
  • Handling missing MCap values: Stocks that explicitly have no MCap values for a specific year are filtered out with warnings printed into standard output.
  • Sector Tie-breaking: When limiting sectors, the stocks representing the lowest MCap within that specific sector are the ones eliminated first.

About

A quantitative portfolio constraint engine that enforces market cap and sector diversification rules on investment strategies using structured financial datasets.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages