This project showcases a factor-based risk parity model that combines Python and web technologies for data analysis and visualization. The system automatically adjusts asset allocation ratios in response to market volatility, achieving dynamic portfolio optimization.
https://www.youtube.com/watch?v=1pOkVJSxbNI&t=2s
https://www.graphen.ai/course/bigdata/reports/202412-8.pdf
- Use API with Excel or manually download the required data from platforms such as Yahoo Finance or Wind.
- Save the Excel files from API or downloaded data in the Risk_Factor_Model_Data folder.
- Open the
Risk_Factor_Model_Code
folder. - Update the file paths in the relevant code blocks to point to the data files in
Risk_Factor_Model_Data
. - Adjust the
factor_risk_parity_model
function as needed:- Function Usage:
factor_risk_parity_model(dataframes["Asset"], dataframes["Factor"], "Factor_Risk_Parity", 1)
- The last parameter in the function (
1
in the example above) specifies how often (in months) the portfolio weights are recalculated. You can freely modify this parameter to change the recalibration interval.
- The last parameter in the function (
- Data Flexibility:
The system allows for flexible inclusion of any number of asset and factor data, as long as they adhere to the format demonstrated in the dataset examples (Risk_Factor_Model_Data
). Simply extend the dataset and update the paths in the script to incorporate additional data.
- Function Usage:
- Run the Python scripts to process the data and generate the necessary outputs (e.g., factor exposure matrices, optimized weights).
- Move the output files generated from the Python scripts into the
Risk_Factor_Web_Demo
folder. - Navigate to the folder containing
index.html
in a terminal. - Start a local server by running the following command:
python -m http.server 8000
- Open your web browser and visit
http://localhost:8000
to view the interactive visualization of your results.
- The system currently uses an API with Excel or CSV files for data storage and processing.
- Future updates may include data retrieval in the background.
- Ensure all dependencies are installed before running the Python scripts. Dependencies include libraries like
Pandas
,Numpy
, andScikit-learn
.