def test_periods(self): y = period_returns(ts.pct_change(), offset=periods(ts.index[-1])) pdt.assert_series_equal(y, read_series("periods.csv", parse_dates=False), check_names=False)
def test_period_returns(returns): p = periods(today=pd.Timestamp("2015-05-01")) x = 100 * period_returns(returns=returns, offset=p) assert x["Three Years"] == pytest.approx(1.1645579858904798, 1e-10)
def period_returns(self): n = self.__nav.pct_change() return period_returns(n, periods(today=n.index[-1]))
def test_periods(): p = periods(today=pd.Timestamp("2015-05-01")) assert p["Two weeks"].start == pd.Timestamp("2015-04-17") assert p["Two weeks"].end == pd.Timestamp("2015-05-01")