Giter Site home page Giter Site logo

hudson-and-thames / portfoliolab Goto Github PK

View Code? Open in Web Editor NEW
145.0 145.0 42.0 36 KB

PortfolioLab is a python library that enables traders to take advantage of the latest portfolio optimisation algorithms used by professionals in the industry.

Home Page: https://hudson-and-thames-portfoliolab.readthedocs-hosted.com/en/latest/

License: Other

algorithmic-trading finance investing machine-learning portfolio-management portfolio-optimization python quantitative-finance research trading

portfoliolab's People

Contributors

jackal08 avatar panpip avatar vlrie 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  avatar  avatar

portfoliolab's Issues

On Colab (interpolate keyerror)

KeyError                                  Traceback (most recent call last)
<ipython-input-19-f1e64dc1b990> in <module>()
      2 # Compute Passive Aggressive Mean Reversion with no given weights and epsilon of 0.3.
      3 pamr = PAMR(optimization_method=0, epsilon=0.3)
----> 4 pamr.allocate(asset_prices=us_equity, resample_by='W', verbose=True)
      5 
      6 # Compute Passive Aggressive Mean Reversion - 1 with given user weights and epsilon of 0.4.

5 frames
/usr/local/lib/python3.7/dist-packages/portfoliolab/online_portfolio_selection/base.py in allocate(self, asset_prices, weights, resample_by, verbose)
     80 
     81         # Initialize all variables.
---> 82         self._initialize(asset_prices, weights, resample_by)
     83 
     84         # Iterate through data and calculate weights.

/usr/local/lib/python3.7/dist-packages/portfoliolab/online_portfolio_selection/pamr.py in _initialize(self, asset_prices, weights, resample_by)
     52                                  'M' for Month. The inputs are based on pandas' resample method.
     53         """
---> 54         super(PAMR, self)._initialize(asset_prices, weights, resample_by)
     55 
     56         # Check that epsilon is greater than 0.

/usr/local/lib/python3.7/dist-packages/portfoliolab/online_portfolio_selection/base.py in _initialize(self, asset_prices, weights, resample_by)
    105         # Resample asset.
    106         if resample_by is not None:
--> 107             asset_prices = asset_prices.resample(resample_by).last()
    108 
    109         # Set asset names.

/usr/local/lib/python3.7/dist-packages/pandas/core/generic.py in resample(self, rule, axis, closed, label, convention, kind, loffset, base, on, level, origin, offset)
   8078         >>> df2 = pd.DataFrame(d2,
   8079         ...                    index=pd.MultiIndex.from_product([days,
-> 8080         ...                                                     ['morning',
   8081         ...                                                      'afternoon']]
   8082         ...                                                     ))

/usr/local/lib/python3.7/dist-packages/pandas/core/resample.py in <module>()
     34 
     35 
---> 36 class Resampler(_GroupBy, ShallowMixin):
     37     """
     38     Class for resampling datetimelike data, a groupby-like operation.

/usr/local/lib/python3.7/dist-packages/pandas/core/resample.py in Resampler()
    782         return self._upsample(method, limit=limit)
    783 
--> 784     @Appender(_shared_docs["interpolate"] % _shared_docs_kwargs)
    785     def interpolate(
    786         self,

KeyError: 'interpolate'

Cannot import Portfoliolab

Hi, I'm rather new in this library
I've pip insalled Portfoliolab as the documentation suggests but when tryng to import the module into a Jupyter notebook I receive the following errors:

import numpy as np
import pandas as pd
import portfoliolab as pl

untimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-764cd2d99591> in <module>

...

**ImportError: numpy.core.multiarray failed to import**

I tried updating Numpy to version 1.20 but Portfoliolab requieres Numpy 1.18.5, so I really don't know what to do.

Can you help fix this?

Thank you and congratulations for these awesome libraries!

Data missing on "Online Portfolio Selection" notebook

On PortfolioLab - I follow the notebook example of Online Portfolio Selection part

msci = pd.read_csv('data/MSCI.csv', parse_dates=True, index_col='Date').dropna()[1:]
us_equity = pd.read_csv('data/US_Equity.csv', parse_dates=True, index_col='Date')
djia = pd.read_csv('data/DJIA.csv', parse_dates=True, index_col='Date')
nyse = pd.read_csv('data/NYSE.csv', parse_dates=True, index_col='Date')
sp500 = pd.read_csv('data/SP500.csv', parse_dates=True, index_col='Date')
tse = pd.read_csv('data/TSE.csv', parse_dates=True, index_col='Date')

Can you share the data which used in the notebook.
The provided link in the notebook is broken
https://github.com/hudson-and-thames/research/blob/master/Online%20Portfolio%20Selection/Data%20Selection.ipynb

DLASCL Parameter Error

ValueError                                Traceback (most recent call last)
<ipython-input-21-c0ce94737fd8> in <module>()
     20 # Compute Confidence Weighted Mean Reversion - Var with given user weights, epsilon of 1, and confidence of 1.
     21 cwmr_var = CWMR(confidence=1, epsilon=1, method='var')
---> 22 cwmr_var.allocate(asset_prices=us_equity)
     23 
     24 # Compute Online Moving Average Reversion - 1 with no given weights, epsilon of 10, and window of 7.

4 frames
<__array_function__ internals> in pinv(*args, **kwargs)

<__array_function__ internals> in svd(*args, **kwargs)

/usr/local/lib/python3.7/dist-packages/numpy/linalg/linalg.py in svd(a, full_matrices, compute_uv, hermitian)
   1659         The matrix whose condition number is sought.
   1660     p : {None, 1, -1, 2, -2, inf, -inf, 'fro'}, optional
-> 1661         Order of the norm:
   1662 
   1663         =====  ============================

ValueError: On entry to DLASCL parameter number 4 had an illegal value

Cannot pip install portfoliolab on google colab

  • portfoliolab
  • Python version: 3.7
  • Operating System: Windows

I tried '!pip install portfoliolab' using google colabs but it returns:

"ERROR: Could not find a version that satisfies the requirement portfoliolab (from versions: none)
ERROR: No matching distribution found for portfoliolab"

It was working for me about 1 week ago, but maybe some update changes have been made which result in this error.

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.