marketmoodring
Python implementation for regime-dependent portfolio optimization
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.0%) to scientific vocabulary
Repository
Python implementation for regime-dependent portfolio optimization
Basic Info
- Host: GitHub
- Owner: yvesdhondt
- License: mit
- Language: Python
- Default Branch: main
- Size: 3.45 MB
Statistics
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
MarketMoodRing🎭
Description
MarketMoodRing🎭 is a Python package designed for testing different regime detection models and portfolio optimizers. This tool is a product of research conducted by the UC Berkeley, Haas School of Business, Master of Financial Engineering, 2023. It aims to provide a framework for financial market regime analysis and portfolio management testing.
Collaborators
Reference
The \reference folder contains the project paper from where this library originated.
Features
- Regime Detection Models: Currently includes Hidden Markov Models (HMM) and Wasserstein K-Means clustering (WKM).
- Portfolio Optimizers: Implements different portfolio optimization strategies, including stochastic programming and factor-based optimization.
Installation
As of now, the MarketMoodRing package is not available on PyPI. To install and use this package, you need to clone the repository and reference it locally. Here are the steps to do so:
- Clone the repository:
bash
git clone https://github.com/yvesdhondt/MarketMoodRing.git
- Navigate to the cloned directory:
bash
cd MarketMoodRing
- Now, you can import and use the package in your Python scripts. Make sure your script is in the same directory as the cloned repository or adjust the Python path accordingly.
```python import sys sys.path.insert(0, '/path/to/MarketMoodRing')
from marketmoodring.regime_detection import HiddenMarkovRegimeDetection ```
Please replace /path/to/MarketMoodRing with the actual path to the cloned repository on your system.
Remember to keep the repository updated with:
bash
git pull origin main
Dependencies
The MarketMoodRing package requires several dependencies to function properly. These dependencies can be installed using either conda (recommended) or pip.
Using Conda
If you're using Conda, you can create a new environment and install all dependencies using the environment.yml file located in the root directory. Run the following command in your terminal / Anaconda Prompt once you've navigated to the cloned repository:
bash
conda env create -f environment.yml
This will create a new Conda environment called marketmoodring-env and install all necessary packages. To activate the environment, use:
bash
conda activate marketmoodring-env
Using pip
If you prefer using pip, you can install all dependencies using the requirements.txt file also located in the root directory. Run the following command in your terminal:
bash
pip install -r requirements.txt
This will install all the necessary packages listed in the requirements.txt file. Please note that this will install the packages globally on your system, which can result in unexpected behavior. If you want to install the packages in a virtual environment, please refer to the Python documentation, or use the Conda environment as described above.
Usage
```python from marketmoodring.regimedetection import HiddenMarkovRegimeDetection from marketmoodring.portfoliooptimization import JointStochasticProgOptimization
Read in your data
indexdata = pd.readcsv('path/to/index_data.csv')
Initialize regime detection model
hmmmodel = HiddenMarkovRegimeDetection(nregimes=2, hmmtype='GMMHMM', covartype="diag", n_iter=100)
Fit the model to your data and predict regimes
fittedstates, fittedstatesproba = regimemodel.fittransform(indexdata)
Initialize portfolio optimizer
optmodel = JointStochasticProgOptimization(nregimes=2, objective="maxavgsharpe")
Fit the optimizer to your data and regime predictions and calculate portfolio weights
weights = optmodel.calculateweights( fittedstates = fittedstates, transmat = hmmmodel.gettransmat() indexdata = indexdata, ) ```
License
This project is licensed under the MIT License. See LICENSE for more details.
Owner
- Name: Yves D'hondt
- Login: yvesdhondt
- Kind: user
- Location: Berkeley, California, USA
- Website: https://www.linkedin.com/in/yvesdhondt/
- Repositories: 4
- Profile: https://github.com/yvesdhondt
M.Sc. Financial Engineering at Berkeley Haas | M.Sc. Management at ESMT Berlin | B.Sc. Informatics at KU Leuven
Citation (CITATION.cff)
cff-version: 1.2.0 message: "If you use this software, please cite it as below." authors: - family-names: "D'hondt" given-names: "Yves Alexander" - family-names: "Di Venti" given-names: "Matteo Mario" - family-names: "Rishi" given-names: "Rohan" - family-names: "Walker" given-names: "Jackson" title: "MarketMoodRing" version: 1.0.0 date-released: 2023-07-27 url: "https://github.com/yvesdhondt/MarketMoodRing"
GitHub Events
Total
- Watch event: 2
- Fork event: 1
Last Year
- Watch event: 2
- Fork event: 1
Dependencies
- hmmlearn ==0.3.
- numpy *
- pandas *
- pot ==0.9.
- pyportfolioopt *
- statsmodels *