Git Product home page Git Product logo

riskparity.py's Introduction

riskparity.py

PyPI version Downloads codecov

riskparityportfolio provides solvers to design risk parity portfolios. In its simplest form, we consider the convex formulation with a unique solution proposed by Spinu (2013) and use cyclical methods inspired by Griveau-Billion et al. (2013) and Choi & Chen (2022). For more general formulations, which are usually nonconvex, we implement the successive convex approximation method proposed by Feng & Palomar (2015).

Documentation: https://mirca.github.io/riskparity.py

R version: https://mirca.github.io/riskParityPortfolio

Rust version: https://github.com/mirca/riskparity.rs

Talks: slides HKML meetup 2020, tutorial - Data-driven Portfolio Optimization Course (HKUST)

Installation

  • development version
$ git clone https://github.com/dppalomar/riskparity.py.git
$ cd riskparity.py
$ pip install -e .
  • stable version
$ pip install riskparityportfolio

Windows requirements

Make sure to install Microsoft C++ Build Tools prior to riskparityportfolio.

riskparityportfolio depends on jaxlib which can be installed following these instructions.

References

License

Copyright 2022 Ze Vinicius and Daniel Palomar

This project is licensed under the terms of the MIT License.

Disclaimer

The information, software, and any additional resources contained in this repository are not intended as, and shall not be understood or construed as, financial advice. Past performance is not a reliable indicator of future results and investors may not recover the full amount invested. The authors of this repository accept no liability whatsoever for any loss or damage you may incur. Any opinions expressed in this repository are from the personal research and experience of the authors and are intended as educational material.

riskparity.py's People

Contributors

danielpnewman avatar dependabot[bot] avatar dppalomar avatar jaehyukchoi avatar mirca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

riskparity.py's Issues

can't detect GPU

Problem description

WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)

Example

my_portfolio = rp.RiskParityPortfolio(covariance=sigma, budget=b)
my_portfolio.design()

Expected behavior

Is there a way to allow it to detech GPU?

Environment:

  • platform (e.g. Linux, OSX, Windows): Ubuntu 18.04
  • riskparityportfolio version (e.g. 1.1): 0.2
  • installation method (e.g. pip, source): pip

Installation Problem

Hi,
I am trying to install riskparityportfolio using 'pip install riskparityportfolio'. I have installed Visual Studio Build Tools 2022. I am using python 3.10.4 and operating on Windows.

The error I received is:

Collecting riskparityportfolio
  Using cached riskparityportfolio-0.3.tar.gz (2.3 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [35 lines of output]
      C:\Users\me\anaconda3\envs\rp\lib\site-packages\setuptools\installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        warnings.warn(
      ERROR: Could not find a version that satisfies the requirement jaxlib (from versions: none)
      ERROR: No matching distribution found for jaxlib
      Traceback (most recent call last):
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\setuptools\installer.py", line 82, in fetch_build_egg
          subprocess.check_call(cmd)
        File "C:\Users\me\anaconda3\envs\rp\lib\subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['C:\\Users\\me\\anaconda3\\envs\\rp\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\me\\AppData\\Local\\Temp\\tmpymv4g9nz', '--quiet', 'jaxlib']' returned non-zero exit status 1.

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\me\AppData\Local\Temp\pip-install-yuxufr_s\riskparityportfolio_396a937d29af4587adae9b529b583849\setup.py", line 124, in <module>
          setup(
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\setuptools\__init__.py", line 86, in setup
          _install_setup_requires(attrs)
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\setuptools\__init__.py", line 80, in _install_setup_requires
          dist.fetch_build_eggs(dist.setup_requires)
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\setuptools\dist.py", line 875, in fetch_build_eggs
          resolved_dists = pkg_resources.working_set.resolve(
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\pkg_resources\__init__.py", line 789, in resolve
          dist = best[req.key] = env.best_match(
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\pkg_resources\__init__.py", line 1075, in best_match
          return self.obtain(req, installer)
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\pkg_resources\__init__.py", line 1087, in obtain
          return installer(requirement)
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\setuptools\dist.py", line 945, in fetch_build_egg
          return fetch_build_egg(self, req)
        File "C:\Users\me\anaconda3\envs\rp\lib\site-packages\setuptools\installer.py", line 84, in fetch_build_egg
          raise DistutilsError(str(e)) from e
      distutils.errors.DistutilsError: Command '['C:\\Users\\me\\anaconda3\\envs\\rp\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\me\\AppData\\Local\\Temp\\tmpymv4g9nz', '--quiet', 'jaxlib']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Do you have any advice on how to fix this and successfully install your great riskparityportfolio package?

Thank you

Need to download MS Visual Build Tools

FYI. To install Python version of riskparityportfolio library, you need to install MS Visual Build Tools. This is a requirement to install quadprog library.

windows platform can not install riskparityportfolio

Problem description

windows platform
pip install riskparityportfolio failed, because
ERROR: Could not find a version that satisfies the requirement jaxlib (from versions: none)
ERROR: No matching distribution found for jaxlib

Expected behavior

can you fixed it ?

Environment:

  • platform (Windows):
  • riskparityportfolio version (e.g. 1.1):
  • installation method (e.g. pip, source):

mac install

Problem description

pip install fails

Example

pip install riskparityportfolio

Environment:

  • OSX
  • riskparityportfolio current ver on PyPI
  • installation method (e.g. pip, source): pip

Errror

        The package setup script has attempted to modify files on your system
          that are not within the EasyInstall build area, and has been aborted.
          
          This package cannot be safely installed by EasyInstall, and may not
          support alternate installation locations even if you run its setup
          script by hand.  Please inform the package's author and the EasyInstall
          maintainers to find out if a fix or workaround is available.

win10 python39 has install problem

has the installation problem,win10,python 3.9

文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
riskparityportfolio/vanilla.cpp(21): warning C4244: “初始化”: 从“Eigen::EigenBase::Index”转换到“unsigned int”,可能丢失数据
with
[
Derived=Eigen::Matrix<double,-1,1,0,-1,1>
]
riskparityportfolio/vanilla.cpp(21): warning C4244: “初始化”: 从“Eigen::EigenBase::Index”转换到“const unsigned int”,可能丢失数据
with
[
Derived=Eigen::Matrix<double,-1,1,0,-1,1>
]
riskparityportfolio/vanilla.cpp(50): warning C4244: “初始化”: 从“Eigen::EigenBase::Index”转换到“unsigned int”,可能丢失数据
with
[
Derived=Eigen::Matrix<double,-1,1,0,-1,1>
]
riskparityportfolio/vanilla.cpp(50): warning C4244: “初始化”: 从“Eigen::EigenBase::Index”转换到“const unsigned int”,可能丢失数据
with
[
Derived=Eigen::Matrix<double,-1,1,0,-1,1>
]
riskparityportfolio/vanilla.cpp(166): error C2017: 非法的转义序列
riskparityportfolio/vanilla.cpp(166): error C2001: 常量中有换行符
riskparityportfolio/vanilla.cpp(170): error C2143: 语法错误: 缺少“;”(在“}”的前面)
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe' failed with exit code 2

ERROR: Command errored out with exit status 1: 'C:\myprogram\Anaconda37\envs\py39\python.exe' -u -c 'import io, os, sys,

[bug] python installation

Problem description

It would be great to support latest python >3.10
When doing "pip3 install riskparityportfolio" in python >= 3.11 in ubuntu (i.e. docker image = python:3.11-slim), there is a compilation error:
error: subprocess-exited-with-error

    × Building wheel for quadprog (pyproject.toml) did not run successfully.
    │ exit code: 1
    ╰─> [15 lines of output]
        running bdist_wheel
        running build
        running build_ext
        building 'quadprog' extension
        creating build
        creating build/temp.linux-x86_64-cpython-312
        creating build/temp.linux-x86_64-cpython-312/quadprog
        gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.12 -c quadprog/linear-algebra.c -o build/temp.linux-x86_64-cpython-312/quadprog/linear-algebra.o
        gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.12 -c quadprog/qr-update.c -o build/temp.linux-x86_64-cpython-312/quadprog/qr-update.o
        gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.12 -c quadprog/quadprog.c -o build/temp.linux-x86_64-cpython-312/quadprog/quadprog.o
        quadprog/quadprog.c:198:12: fatal error: longintrepr.h: No such file or directory
          198 |   #include "longintrepr.h"
              |            ^~~~~~~~~~~~~~~
        compilation terminated.
        error: command '/usr/bin/gcc' failed with exit code 1
        [end of output]

The issue does not exist in python 3.10

Environment:

  • platform (e.g. Linux, OSX, Windows): Linux
  • riskparityportfolio version (e.g. 1.1): latest (0.4)
  • installation method (e.g. pip, source): pip

Cannot Import riskparityportfolio in Jupyter Notebook or Lab: Undefined Symbol error

Problem description

Hi! I'm getting the following error when importing riskparityportfolio in Jupyter Notebooks or in Jupyter Lab.

ImportError: /home//riskparity.py/riskparityportfolio/vanilla.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNSt15__exception_ptr13exception_ptr10_M_releaseEv

Screenshot from 2021-11-22 17-13-45

Example

import riskparityportfolio as rp

or

from riskparityportfolio import vanilla

...as was advised in another issue.

Expected behavior

I would expect riskparityportfolios to work in jupyter notebooks and in lab as it has done before. Oddly I have found in the past that if I make import riskparityportfolio as rp the first line in the notebook, it works. But this is no longer reliable (seems to no longer work). Using it in a script works fine.

Environment:

  • platform (e.g. Linux, OSX, Windows): Ubuntu 21.10
  • riskparityportfolio version (e.g. 1.1): riskparityportfolio 0.2
  • Python: Conda Python 3.9
  • installation method (e.g. pip, source): pip and the dev version via git clone (as advised in another issue)
  • Jupyter versions:
  • jupyter-client 7.0.6
  • jupyter-core 4.8.1
  • jupyter-server 1.11.2
  • jupyterlab 3.2.1
  • jupyterlab-pygments 0.1.2
  • jupyterlab-server 2.8.2

Thanks in advance for taking a look!

quadprog issue mac

Just a note that I think this PR may fix install issues here too.

Problem description

Fails to pip install riskparityportfolio

Example

   pip install riskparityportfolio

Environment:

  • OSX
  • riskparityportfolio latest
  • installation method: pip

Can't pip install

Problem description

Cannot pip install package.

Example

pip install riskparityportfolio
# insert code here ...

which returns

Collecting riskparityportfolio
  Using cached https://files.pythonhosted.org/packages/4c/b0/d24ca75f3c28a31872d2efd191f2aada634bbf55101675bd5363f3fe6c0d/riskparityportfolio-0.2.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR:   ERROR: Complete output from command /Users/kingf.wong/.conda/envs/FinanceML/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/24/940nh5796kl2kb647xg2_m_00000gn/T/pip-wheel-443i6gz2/quadprog/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/24/940nh5796kl2kb647xg2_m_00000gn/T/pip-wheel-2l5m_62k:
      ERROR: running bdist_wheel
      running build
      running build_ext
      cythoning quadprog/quadprog.pyx to quadprog/quadprog.cpp
      /Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/24/940nh5796kl2kb647xg2_m_00000gn/T/pip-wheel-443i6gz2/quadprog/quadprog/quadprog.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      building 'quadprog' extension
      creating build
      creating build/temp.macosx-10.7-x86_64-3.7
      creating build/temp.macosx-10.7-x86_64-3.7/quadprog
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/quadprog.cpp -o build/temp.macosx-10.7-x86_64-3.7/quadprog/quadprog.o
      warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
      quadprog/quadprog.cpp:2523:28: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
        __pyx_t_3 = ((__pyx_t_11 != __pyx_v_n1) != 0);
                      ~~~~~~~~~~ ^  ~~~~~~~~~~
      quadprog/quadprog.cpp:2636:28: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Wsign-compare]
        __pyx_t_3 = ((__pyx_t_11 != __pyx_v_m1) != 0);
                      ~~~~~~~~~~ ^  ~~~~~~~~~~
      3 warnings generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/aind.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/aind.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/solve.QP.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/solve.QP.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/util.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/util.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/dpofa.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/dpofa.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/daxpy.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/daxpy.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/ddot.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/ddot.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/dscal.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/dscal.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -I/Users/kingf.wong/.conda/envs/FinanceML/include -arch x86_64 -Iquadprog -I/Users/kingf.wong/.conda/envs/FinanceML/include/python3.7m -c quadprog/f2c_lite.c -o build/temp.macosx-10.7-x86_64-3.7/quadprog/f2c_lite.o
      creating build/lib.macosx-10.7-x86_64-3.7
      g++ -bundle -undefined dynamic_lookup -L/Users/kingf.wong/.conda/envs/FinanceML/lib -arch x86_64 -L/Users/kingf.wong/.conda/envs/FinanceML/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.7/quadprog/quadprog.o build/temp.macosx-10.7-x86_64-3.7/quadprog/aind.o build/temp.macosx-10.7-x86_64-3.7/quadprog/solve.QP.o build/temp.macosx-10.7-x86_64-3.7/quadprog/util.o build/temp.macosx-10.7-x86_64-3.7/quadprog/dpofa.o build/temp.macosx-10.7-x86_64-3.7/quadprog/daxpy.o build/temp.macosx-10.7-x86_64-3.7/quadprog/ddot.o build/temp.macosx-10.7-x86_64-3.7/quadprog/dscal.o build/temp.macosx-10.7-x86_64-3.7/quadprog/f2c_lite.o -o build/lib.macosx-10.7-x86_64-3.7/quadprog.cpython-37m-darwin.so
      clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
      ld: library not found for -lstdc++
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      error: command 'g++' failed with exit status 1
      ----------------------------------------
      ERROR: Failed building wheel for quadprog
    ERROR: Failed to build one or more wheels
    Traceback (most recent call last):
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/setuptools/installer.py", line 126, in fetch_build_egg
        subprocess.check_call(cmd)
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/subprocess.py", line 347, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/Users/kingf.wong/.conda/envs/FinanceML/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/24/940nh5796kl2kb647xg2_m_00000gn/T/tmp7hkzyq3z', '--quiet', 'quadprog']' returned non-zero exit status 1.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/24/940nh5796kl2kb647xg2_m_00000gn/T/pip-install-mgb8ijkt/riskparityportfolio/setup.py", line 141, in <module>
        include_package_data=True,
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/setuptools/__init__.py", line 152, in setup
        _install_setup_requires(attrs)
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/setuptools/__init__.py", line 147, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/setuptools/dist.py", line 676, in fetch_build_eggs
        replace_conflicting=True,
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/pkg_resources/__init__.py", line 766, in resolve
        replace_conflicting=replace_conflicting
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1049, in best_match
        return self.obtain(req, installer)
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1061, in obtain
        return installer(requirement)
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/setuptools/dist.py", line 732, in fetch_build_egg
        return fetch_build_egg(self, req)
      File "/Users/kingf.wong/.conda/envs/FinanceML/lib/python3.7/site-packages/setuptools/installer.py", line 128, in fetch_build_egg
        raise DistutilsError(str(e)) from e
    distutils.errors.DistutilsError: Command '['/Users/kingf.wong/.conda/envs/FinanceML/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/24/940nh5796kl2kb647xg2_m_00000gn/T/tmp7hkzyq3z', '--quiet', 'quadprog']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/24/940nh5796kl2kb647xg2_m_00000gn/T/pip-install-mgb8ijkt/riskparityportfolio/

Expected behavior

Expeted to be installed

Environment:

  • platform (e.g. Linux, OSX, Windows): OSX
  • riskparityportfolio version (e.g. 1.1): 0.2
  • installation method (e.g. pip, source): pip

Vanilla Attribute Error

Problem description

I have been trying to use your package to make risk parity portfolios with ease. Although, I have been facing some issues running the first tutorial. At first I've tried running it with a local installation, then I've moved to Colab environment. Faced the same issue on both situations.

Example

!pip check
!pip install pybind11
!pip install riskparityportfolio

import riskparityportfolio as rp

b = df_portfolio_prices_parity

optimum_weights = rp.vanilla.design(cov, b)

Behavior

Since it was a simple example provided on the documentation, I thought it would be straight-forward execution, but I'm facing the error below:

AttributeError                            Traceback (most recent call last)
<ipython-input-12-0745d4c9a058> in <module>()
      8 b = df_portfolio_prices_parity
      9 
---> 10 optimum_weights = rp.vanilla.design(cov, b)

AttributeError: module 'riskparityportfolio' has no attribute 'vanilla'

Environment:

  • Colab environment: running Ubuntu 18.04.3 LTS
  • installation method: pip

[feature]prebuilt binary

Hi,
Is there a plan to build a binary so the installation does not need to go through gcc compilations, ideally in linux?
Thanks for the great library.

Possible bug, different result compare to vanila

Problem description

Example

import numpy as np
import riskparityportfolio as rp


covar = """
0.000083	-0.000086	-0.000038	-0.000017	0.000024	0.000047	-0.000064
-0.000086	0.000124	0.000045	0.000026	-0.000031	-0.000068	0.000085
-0.000038	0.000045	0.000032	0.000013	-0.000014	-0.000012	0.000035
-0.000017	0.000026	0.000013	0.000010	-0.000006	-0.000008	0.000021
0.000024	-0.000031	-0.000014	-0.000006	0.000017	0.000017	-0.000021
0.000047	-0.000068	-0.000012	-0.000008	0.000017	0.000081	-0.000037
-0.000064	0.000085	0.000035	0.000021	-0.000021	-0.000037	0.000069
""" # 2020/01/15 ~ 2020/02/12 (5 days before crona virus hit NASDAQ)

covar_list = []
for line in covar.strip().split("\n"):
    covar_list.append(
        list(map(lambda x: float(x), line.strip().split("\t")))
    )

covar_arr = np.array(covar_list)
print(covar_arr)

b = np.array([1/len(covar_list)]*len(covar_list))
print(b)

print()
w = rp.vanilla.design(covar_arr, b)
print("\n".join(map(lambda x: str(x), w.tolist())))
rc = w @ (covar_arr * w)
rc_normalized = rc/np.sum(rc)
print(rc_normalized)
"""
0.202179258153996
0.1237214037319422
0.1288441343566357
0.13543299451241167
0.23510939114299298
0.07660294250377662
0.09810987559824495
[0.14285713 0.14285712 0.14285714 0.14285714 0.14285716 0.14285715
 0.14285715]
"""


my_portfolio = rp.RiskParityPortfolio(covariance=covar_arr, budget=b)
my_portfolio.design()

w = my_portfolio.weights.numpy()
print("\n".join(map(lambda x: str(x), w.tolist())))
rc_normalized = my_portfolio.risk_contributions.numpy()
print(rc_normalized)

"""
6.307443483830658e-18
0.09064130267494935
0.10656156297588494
0.17508508791969957
0.42438638805721507
0.1259451923875678
0.07738046598468734
[-5.91319667e-18  1.26101827e-01  1.36715334e-01  1.59458863e-01
  2.57937824e-01  1.83776194e-01  1.36009958e-01]
"""

Expected behavior

same weight from both vanila and this library's implementation.

Environment:

  • platform (e.g. Linux, OSX, Windows): Windows
  • riskparityportfolio version (e.g. 1.1): I installed current master which seems 0.1.5, but rp.__version__ gives me 0.1.3.
  • installation method (e.g. pip, source): pip install -e . from source

add windows support

Dear all. While using the package in windows, when importing the module, I encounter the folllowing issue:

ModuleNotFoundError: No module named 'jaxlib'

After searching for the package installation I found this thread saying that jaxlib has no windows support.

Is it possible to find alternatives?

thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.