Skip to content

Volatility weighting NB seems to fail #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
twiecki opened this issue Oct 15, 2015 · 8 comments
Closed

Volatility weighting NB seems to fail #172

twiecki opened this issue Oct 15, 2015 · 8 comments
Assignees
Labels
Milestone

Comments

@twiecki
Copy link
Contributor

twiecki commented Oct 15, 2015

--------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-3ab88e0b88b5> in <module>()
      2                                                                        weight_function=np.std,
      3                                                                        weight_function_window=126,
----> 4                                                                        inverse_weight=True
      5                                                                       )
      6 to_plot = ['SPY', 'GLD', 'FXE'] + ["port_ret"]

/home/wiecki/working/projects/quant/pyfolio/pyfolio/timeseries.py in portfolio_returns_metric_weighted(holdings_returns, exclude_non_overlapping, weight_function, weight_function_window, inverse_weight, portfolio_rebalance_rule, weight_func_transform)
   1251             holdings_df_weights = holdings_df[transform_columns] / \
   1252                 holdings_df[transform_columns].sum(axis=1)
-> 1253         holdings_df_weights.columns = holdings_cols
   1254         holdings_df = holdings_df.join(holdings_df_weights, rsuffix='_w')
   1255         holdings_df_weighted_rets = np.multiply(

/home/wiecki/miniconda3/lib/python3.4/site-packages/pandas/core/generic.py in __setattr__(self, name, value)
   2255         try:
   2256             object.__getattribute__(self, name)
-> 2257             return object.__setattr__(self, name, value)
   2258         except AttributeError:
   2259             pass

pandas/src/properties.pyx in pandas.lib.AxisProperty.__set__ (pandas/lib.c:44611)()

/home/wiecki/miniconda3/lib/python3.4/site-packages/pandas/core/generic.py in _set_axis(self, axis, labels)
    422 
    423     def _set_axis(self, axis, labels):
--> 424         self._data.set_axis(axis, labels)
    425         self._clear_item_cache()
    426 

/home/wiecki/miniconda3/lib/python3.4/site-packages/pandas/core/internals.py in set_axis(self, axis, new_labels)
   2458         if new_len != old_len:
   2459             raise ValueError('Length mismatch: Expected axis has %d elements, '
-> 2460                              'new values have %d elements' % (old_len, new_len))
   2461 
   2462         self.axes[axis] = new_labels

ValueError: Length mismatch: Expected axis has 2342 elements, new values have 3 elements
@twiecki twiecki added the bug label Oct 15, 2015
@twiecki twiecki added this to the 0.2 release milestone Oct 15, 2015
@justinlent
Copy link
Contributor

This is working for me on my local branch. are you trying on Master? any package updates that you've done (like the new pandas?) that may be causing it? i'm still on this pandas:
image

@twiecki
Copy link
Contributor Author

twiecki commented Oct 15, 2015

I'm on 0.17.0 which might be the issue. Can you try upgrading and see if you can reproduce that way?

@justinlent
Copy link
Contributor

cool, yea., I'll clone my current virtual env, and then just update to pandas 0.17.0 to try and isolate it to pandas

@justinlent
Copy link
Contributor

(but i probably won't get to trying this untill later today in the afternoon as I have some meetings in the morning)

@justinlent
Copy link
Contributor

confirmed. It fails on me when upgrading to pandas 0.17.0. ohhh pandas and how you consistently break backcompat... ;)

i think they messed around with how indexes should be set in this new release. let me see if its a quick fix

@twiecki
Copy link
Contributor Author

twiecki commented Oct 15, 2015

Related: pandas-dev/pandas#11336

@justinlent
Copy link
Contributor

@twiecki PR for your review
#173

@twiecki
Copy link
Contributor Author

twiecki commented Oct 15, 2015

@twiecki twiecki closed this as completed Oct 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants