Esempio n. 1
0
    def comp_daily_returns(self):
        """Computes the daily returns (percentage change) of all
        stocks in the portfolio. See ``finquant.returns.daily_returns``.

        :Output:
         :ret: a ``pandas.DataFrame`` of daily percentage change of Returns
             of given stock prices.
        """
        return daily_returns(self.data)
Esempio n. 2
0
def test_daily_returns():
    orig = [[1.0, 1.0 / 2, 1.0 / 3, 1.0 / 4], [1.0 / 9, 1.0 / 10, 1.0 / 11, 1.0 / 12]]
    l1 = range(1, 6)
    l2 = [10 * 0.2 + i * 0.25 for i in range(1, 6)]
    d = {"1": l1, "2": l2}
    df = pd.DataFrame(d)
    ret = daily_returns(df)
    assert all(abs(ret["1"].values - orig[0]) <= 1e-15)
    assert all(abs(ret["2"].values - orig[1]) <= 1e-15)
Esempio n. 3
0
    def comp_cov(self):
        """Compute and return a ``pandas.DataFrame`` of the covariance matrix
        of the portfolio.

        :Output:
         :cov: a ``pandas.DataFrame`` of the covariance matrix of the portfolio.
        """
        # get the covariance matrix of the mean returns of the portfolio
        returns = daily_returns(self.data)
        return returns.cov()
Esempio n. 4
0
 def comp_daily_returns(self):
     """Computes the daily returns (percentage change).
     See ``finquant.returns.daily_returns``.
     """
     return daily_returns(self.data)