Teruo Nakatsuma (Faculty of Economics, Keio University, Japan)
- How to set up Python and necessary packages
- Tips for Troubleshooting
- How to start JupyterLab
- Jupyter Notebooks and related files in
notebook
- Python codes and related files in
python
I strongly recommend using Anaconda. It can install Python along with numerous essential packages at once and allows us to manage those packages flexibly.
-
If you have an older Anaconda on your PC, uninstall it completely by folloiwng instructions.
-
Download an Anaconda installer (Windows, macOS or Linux) from here. Choose a Python 3 installer.
-
Doubleclick the installer and follow the instructions on the screen. Do not change the default settings.
-
Download the installer for
Microsoft Visual Studio Build Tools
from here. -
Doubleclick the installer and follow the instructions on the screen. It is sufficient to install
C++ build tools
. See this link for the install instructions.
-
Install
Xcode
from App Store. -
Start
Xcode
. If a pop-up window asks you to install additional tools, follow the instruction. QuitXcode
. -
Start
Terminal
and installCommand Line Tools for Xcode
by typing
sudo xcode-select --install
If asked, type your login password.
Start Anaconda Powershell Prompt
(Windows) or Terminal
(macOS, Linux) and type
conda update conda
This will update conda (package manager) in Anaconda. Then type
conda create -n finance jupyterlab seaborn
This will create a new enviromnemt named finance
. Then type
conda activate finance
To install CVXPY
, type
conda install -c conda-forge cvxpy
Finally type
python -m ipykernel install --user --name finance --display-name "Python (Finance)"
Now you are ready for Python!
If you encounter any errors during the installation process, go back to the default environment by typing
conda deactivate
and remove finance
by typing
conda env remove -n finance
Then retry Step 3.
Start Anaconda Powershell Prompt
(Windows) or Terminal
(macOS, Linux) and type
conda activate finance
Then type
jupyter lab
Your default browser will pop up. Click the Python (Finance)
button to create a Jupyter notebook.
file name | description |
---|---|
asset_return_data.csv | simulated asset returns |
capm.csv | market capitalization data |
ges_alt_risk.ipynb | portfolio with alternative risk measures |
ges_bond.ipynb | yield, duration and convexity of bond |
ges_interst.ipynb | interest rate |
ges_mvf.ipynb | mean-variance portfolio |
ges_mvf_sample.ipynb | mean-variance portfolio with data |
ges_npv_irr.ipynb | present value, internal rate of return |
ges_portfolio.ipynb | introduction to portfolio analysis |
ges_riskparity.ipybn | risk parity portfolio |
ges_tracking_error.py | traking error minimization problem |
stock_market_cap.csv | market capitalization data |
file name | description |
---|---|
asset_return_data.csv | simulated asset returns |
capm.csv | market capitalization data |
ges_ad_portfolio.py | mean absolute deviation portfolio |
ges_asset_return_simulation.py | simulation of asset returns |
ges_black_scholes.py | Black-Scholes formula for option pricing |
ges_bond_duration_convexity.py | duration and convexity of bond |
ges_bond_yield_curve.py | yield curve of bond |
ges_bond_yield_price.py | price-yield relationship |
ges_capm.py | CAPM beta estimation |
ges_es_portfolio.py | expected shortfall portfolio |
ges_interest.py | interest rate |
ges_min_tracking_error.py | tracking-error minimization |
ges_mvf_example1.py | mean-variance portfolio |
ges_mvf_example2.py | mean-variance portfolio w/o short selling |
ges_mvf_example3.py | mean-variance portfolio with data |
ges_npv_irr.py | present value, internal rate of return |
ges_option_pricing.py | option pricing with binomial tree model |
ges_risk_parity.py | risk parity portfolio |
ges_sv_portfolio.py | semivariance portfolio |