Financial script for calculating Sharpe value from monthly Bloomberg price data.
Create a portfolio of stocks or any financial instruments that can be found on The Bloomberg Terminal, it can be made from 1 or a lot of different stocks. It has to maximize The Sharpe Ratio:
-
The instrument return and all other parameters (variance, portfolio returns and so on) is measured from 2015-11-30 to 2025-09-30.
-
We have to examine the past and make the best choice of instruments that should have been bought in 2015-11-30 and held to 2015-09-30, the easiest way to attempt do this task (as I understand).
-
We have to calculate the monthly returns of our instruments over the ten years, from this we then calculate the other parameters.
-
We will have to present our portfolio in 2 or 3 minutes, we will compete with other teams and the rest of the class will decide which portfolio they would like to invest in. The team with the most votes wins 0.5 points to the final grade. Therefore the portfolio should seem reasonable, not incredibly risky.
Any of the contributors can change or add more content to this repository.
.
├── input_data/ # Input data files
│ └── Sharpe-ratio-picked-instruments-data.csv
├── src/ # Source code
│ ├── data_processing/ # Data cleaning and preparation
│ │ ├── __init__.py
│ │ └── data_cleaning.py
│ ├── calculations/ # Financial calculations
│ │ ├── __init__.py
│ │ └── financial_metrics.py
│ ├── optimization/ # Portfolio optimization
│ │ ├── __init__.py
│ │ └── portfolio_optimization.py
│ ├── visualization/ # Data visualization
│ │ ├── __init__.py
│ │ └── portfolio_plots.py
│ ├── __init__.py
│ └── main.py # Main entry point
├── XLSX files/ # Excel output files
├── Visualization Graphs/ # Plot output files
├── config.json # Configuration file
├── requirements.txt # Python dependencies
└── README.md # Project documentation
- Clone the repository
- Install dependencies:
pip install -r requirements.txtRun the main script:
python src/main.pyEdit config.json to modify:
- Input data path
- Output directories for Excel files and plots
The script generates:
- Excel workbook with the portfolio allocation and metrics in
XLSX files/directory - Portfolio allocation plots in
Visualization Graphs/directory
- The script maximizes the Sharpe Ratio, but it does not take into account any other risk-factor such as market volatility, inflation, or other market factors.
- The script assumes that the input data in the template format of the Bloomberg Terminal HP Data, like in the
input_data/directory.
It removes any columns with missing data, the price data dates must match. - The script does not take into account any transaction costs or slippage.