There are two main problems in the existing portfolio decision-making process as follows:
- Many portfolio models are now essentially a static model
- Some current new decision models only focus on a specific type of correlation network or use a specific model for portfolio optimization, and lack the exploration of portfolio optimization
The overall workflow of the HALM model is shown below.
Initial Funding: $1000.00
Funding for 09/10/2021: $14485.35
Earnings Multiple: About 14.49 times
If you want to do a good job, you must first sharpen your tools. It is more important to make the development environment right than anything else.
- It is recommended to use PyCharm or VSCode, please do not use IDE
- It is recommended to use Python 3.8.X or above
- It is recommended to make the working environment coexist with multiple versions and multiple environments, use virtualenv, etc. for isolation, regardless of whether Python 3.8 is used for daily work
- Download the Python 3.8.X installation package and install it, assuming the installation path is C:\Python38, do not set environment variables
pip install virtualenv
- Open the command line prompt, enter the project folder, take C:\Projects\example_project as an example, if the project uses Python 3.8.X, execute the following command to create a virtual environment
cd C:\Projects\example_project
virtualenv -p C:\Python38\python.exe venv
- The command line prompt needs to activate the virtual environment before it can be used, including python, pip, etc.
cd C:\Projects\example_project
.\venv\Scripts\activate.bat
The IDE configures the project's Python Interpreter to C:\Projects\example_project\venv\bin\python.exe
- Install Brew, ignore if already installed
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install python 3.8 with Brew
brew update
brew install python@3.8
- Open the terminal and execute the command to install virtualenv
pip install virtualenv
- Open the command line prompt, enter the project folder, take C:\Projects\example_project as an example, if the project uses Python 3.8.X, execute the following command to create a virtual environment
cd ~/Projects/example_project
virtualenv -p python3 venv
- The command line prompt needs to activate the virtual environment before it can be used, including python, pip, etc.
cd ~/Projects/example_project
source ./venv/bin/activate
The IDE configures the project's Python Interpreter to ~/Projects/example_project/venv/bin/python
sudo pip install virtualenv
B. After the installation is complete, you can use the virtualenv command to create a virtual environment. You only need to specify the name of a virtual environment.
virtualenv venv
source venv/bin/activate
deactivate
pip install -r requirements.txt
from halm import HALM
a = 1000.44 # The closing price of product A on the day
b = 564.11 # The closing price of product B on the day
h_ab = [
{"2020-11-01": [852.59, 485.44]},
{"2020-11-02": [891.38, 933.66]},
{"2020-11-03": [977.14, 996.52]}
] # Historical closing prices for products A and B
portfolio = HALM(
price_a=a, price_b=b, historical_prices=h_ab
).halm_decision() # Portfolio investment strategy for the next trading day