{"action":"created","issue":{"url":"https://api.github.com/repos/pmorissette/ffn/issues/35","repository_url":"https://api.github.com/repos/pmorissette/ffn","labels_url":"https://api.github.com/repos/pmorissette/ffn/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/pmorissette/ffn/issues/35/comments","events_url":"https://api.github.com/repos/pmorissette/ffn/issues/35/events","html_url":"https://github.com/pmorissette/ffn/issues/35","id":302043686,"number":35,"title":"after upgrade to pandas 0.22 break ffn, reverting to 0.21 - ffn is OK","user":{"login":"githubbla","id":12095960,"avatar_url":"https://avatars3.githubusercontent.com/u/12095960?v=4","gravatar_id":"","url":"https://api.github.com/users/githubbla","html_url":"https://github.com/githubbla","followers_url":"https://api.github.com/users/githubbla/followers","following_url":"https://api.github.com/users/githubbla/following{/other_user}","gists_url":"https://api.github.com/users/githubbla/gists{/gist_id}","starred_url":"https://api.github.com/users/githubbla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/githubbla/subscriptions","organizations_url":"https://api.github.com/users/githubbla/orgs","repos_url":"https://api.github.com/users/githubbla/repos","events_url":"https://api.github.com/users/githubbla/events{/privacy}","received_events_url":"https://api.github.com/users/githubbla/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-04T00:04:00Z","updated_at":"2018-04-11T19:49:49Z","closed_at":null,"author_association":"NONE","body":"---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\npandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10990)()\r\n\r\npandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6589)()\r\n\r\nTypeError: an integer is required\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nKeyError                                  Traceback (most recent call last)\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/indexes/base.py in get_loc(self, key, method, tolerance)\r\n   1944             try:\r\n-> 1945                 return self._engine.get_loc(key)\r\n   1946             except KeyError:\r\n\r\npandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:11140)()\r\n\r\npandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:11046)()\r\n\r\npandas/index.pyx in pandas.index.DatetimeEngine._date_check_type (pandas/index.c:11210)()\r\n\r\nKeyError: 'next'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTypeError                                 Traceback (most recent call last)\r\npandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:10990)()\r\n\r\npandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6589)()\r\n\r\nTypeError: an integer is required\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nKeyError                                  Traceback (most recent call last)\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/tseries/index.py in get_loc(self, key, method, tolerance)\r\n   1430         try:\r\n-> 1431             return Index.get_loc(self, key, method, tolerance)\r\n   1432         except (KeyError, ValueError, TypeError):\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/indexes/base.py in get_loc(self, key, method, tolerance)\r\n   1946             except KeyError:\r\n-> 1947                 return self._engine.get_loc(self._maybe_cast_indexer(key))\r\n   1948 \r\n\r\npandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:11140)()\r\n\r\npandas/index.pyx in pandas.index.DatetimeEngine.get_loc (pandas/index.c:11046)()\r\n\r\npandas/index.pyx in pandas.index.DatetimeEngine._date_check_type (pandas/index.c:11210)()\r\n\r\nKeyError: 'next'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nValueError                                Traceback (most recent call last)\r\nValueError: Error parsing datetime string \"next\" at position 0\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nSystemError                               Traceback (most recent call last)\r\n<ipython-input-15-f0175af66bae> in <module>()\r\n      1 portshow=port #[port.index < pd.to_datetime(date(2017, 1, 1)) ]\r\n      2 \r\n----> 3 stats = portshow[['close','spy_close','qqq_close']].calc_stats()\r\n      4 print(portshow['close'].calc_total_return()*100)\r\n      5 print(portshow['close'].calc_cagr()*100)\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in calc_stats(prices)\r\n   1040         return PerformanceStats(prices)\r\n   1041     elif isinstance(prices, pd.DataFrame):\r\n-> 1042         return GroupStats(*[prices[x] for x in prices.columns])\r\n   1043     else:\r\n   1044         raise NotImplementedError('Unsupported type')\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in __init__(self, *prices)\r\n    644         self._end = self._prices.index[-1]\r\n    645         # calculate stats for entire series\r\n--> 646         self._update(self._prices)\r\n    647 \r\n    648     def __getitem__(self, key):\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in _update(self, data)\r\n    653 \r\n    654     def _update(self, data):\r\n--> 655         self._calculate(data)\r\n    656         # lookback returns dataframe\r\n    657         self.lookback_returns = pd.DataFrame(\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in _calculate(self, data)\r\n    666         for c in data.columns:\r\n    667             prc = data[c]\r\n--> 668             self[c] = PerformanceStats(prc)\r\n    669 \r\n    670     def _stats(self):\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in __init__(self, prices, rf)\r\n     61         self.rf = rf\r\n     62 \r\n---> 63         self._update(self.prices)\r\n     64 \r\n     65     def set_riskfree_rate(self, rf):\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in _update(self, obj)\r\n     80     def _update(self, obj):\r\n     81         # calc\r\n---> 82         self._calculate(obj)\r\n     83 \r\n     84         # update derived structure\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in _calculate(self, obj)\r\n    189         self.daily_vol = r.std() * np.sqrt(252)\r\n    190         self.daily_sharpe = r.calc_sharpe(rf=self.rf, nperiods=252)\r\n--> 191         self.daily_sortino = calc_sortino_ratio(r, rf=self.rf, nperiods=252)\r\n    192         self.best_day = r.max()\r\n    193         self.worst_day = r.min()\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/ffn/core.py in calc_sortino_ratio(returns, rf, nperiods, annualize)\r\n   1981 \r\n   1982     er = returns.to_excess_returns(rf, nperiods=nperiods)\r\n-> 1983     res = er.mean() / er[er < 0].std()\r\n   1984 \r\n   1985     if annualize:\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/core/series.py in __getitem__(self, key)\r\n    616             raise\r\n    617 \r\n--> 618         if com.is_iterator(key):\r\n    619             key = list(key)\r\n    620 \r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/core/common.py in is_iterator(obj)\r\n   1447 def is_iterator(obj):\r\n   1448     # python 3 generators have __next__ instead of next\r\n-> 1449     return hasattr(obj, 'next') or hasattr(obj, '__next__')\r\n   1450 \r\n   1451 \r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)\r\n   2668             return object.__getattribute__(self, name)\r\n   2669         else:\r\n-> 2670             if name in self._info_axis:\r\n   2671                 return self[name]\r\n   2672             return object.__getattribute__(self, name)\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/tseries/base.py in __contains__(self, key)\r\n    182     def __contains__(self, key):\r\n    183         try:\r\n--> 184             res = self.get_loc(key)\r\n    185             return lib.isscalar(res) or type(res) == slice or np.any(res)\r\n    186         except (KeyError, TypeError, ValueError):\r\n\r\n~/anaconda3/envs/newenv/lib/python3.6/site-packages/pandas/tseries/index.py in get_loc(self, key, method, tolerance)\r\n   1437 \r\n   1438             try:\r\n-> 1439                 stamp = Timestamp(key, tz=self.tz)\r\n   1440                 return Index.get_loc(self, stamp, method, tolerance)\r\n   1441             except (KeyError, ValueError):\r\n\r\npandas/tslib.pyx in pandas.tslib.Timestamp.__new__ (pandas/tslib.c:9203)()\r\n\r\npandas/tslib.pyx in pandas.tslib.convert_to_tsobject (pandas/tslib.c:24653)()\r\n\r\npandas/tslib.pyx in pandas.tslib.convert_str_to_tsobject (pandas/tslib.c:26273)()\r\n\r\npandas/src/datetime.pxd in datetime._string_to_dts (pandas/tslib.c:85631)()\r\n\r\nSystemError: <class 'str'> returned a result with an error set"},"comment":{"url":"https://api.github.com/repos/pmorissette/ffn/issues/comments/380574465","html_url":"https://github.com/pmorissette/ffn/issues/35#issuecomment-380574465","issue_url":"https://api.github.com/repos/pmorissette/ffn/issues/35","id":380574465,"user":{"login":"githubbla","id":12095960,"avatar_url":"https://avatars3.githubusercontent.com/u/12095960?v=4","gravatar_id":"","url":"https://api.github.com/users/githubbla","html_url":"https://github.com/githubbla","followers_url":"https://api.github.com/users/githubbla/followers","following_url":"https://api.github.com/users/githubbla/following{/other_user}","gists_url":"https://api.github.com/users/githubbla/gists{/gist_id}","starred_url":"https://api.github.com/users/githubbla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/githubbla/subscriptions","organizations_url":"https://api.github.com/users/githubbla/orgs","repos_url":"https://api.github.com/users/githubbla/repos","events_url":"https://api.github.com/users/githubbla/events{/privacy}","received_events_url":"https://api.github.com/users/githubbla/received_events","type":"User","site_admin":false},"created_at":"2018-04-11T19:49:48Z","updated_at":"2018-04-11T19:49:48Z","author_association":"NONE","body":"just upgrade to latest pandas 0.22  - it's break it, but 0.21 is OK\r\n[statistics.csv.zip](https://github.com/pmorissette/ffn/files/1900277/statistics.csv.zip)\r\n\r\nstatistics = pd.DataFrame()\r\n\r\nstatistics=pd.read_csv('~/statistics.csv', date_parser = lambda x: pd.to_datetime(x),parse_dates=['Date'], index_col='Date')\r\n\r\nstats = statistics.calc_stats()\r\n\r\n\r\nstats.display()\r\n"}}
{"actor":{"display_login":"githubbla"}}