Class Returns


  • public final class Returns
    extends Object
    Contains utility methods related to returns computation. We avoid the class name 'ReturnsUtils' because that is already used in AQ.
    • Method Detail

      • getReturnsFromPrices

        public static double[] getReturnsFromPrices​(double[] prices,
                                                    ReturnsCalculator calc)
        Computes returns series from prices.
        Parameters:
        prices - a series of prices
        calc - the type of returns calculation
        Returns:
        an array of returns
      • getPricesFromReturns

        public static double[] getPricesFromReturns​(double price0,
                                                    double[] returns,
                                                    ReturnsCalculator calc)
        Gets the price series from a return series.
        Parameters:
        price0 - the initial price
        returns - a return series
        calc - a type of returns calculation
        Returns:
        the price series
      • getVectorReturnsFromPrices

        public static double[][] getVectorReturnsFromPrices​(double[][] prices,
                                                            ReturnsCalculator calc)
        Computes returns for a 2D array of prices (one column for one asset), with the given ReturnsCalculator.
        Parameters:
        prices - the price array
        calc - the type of returns calculation
        Returns:
        a 2D array of returns
      • getReturns

        public static double[] getReturns​(double[] lastPrices,
                                          double[] currentPrices,
                                          ReturnsCalculator calc)
      • getMeanReturns

        public static Vector getMeanReturns​(double[][] returns)
        Computes a vector of mean returns of the input returns (one column for one asset).
        Parameters:
        returns - the returns
        Returns:
        the mean returns
      • getMeanReturns

        public static Vector getMeanReturns​(Matrix returns)
        Computes a vector of mean returns of the input returns (one column for one asset).
        Parameters:
        returns - the returns
        Returns:
        the mean returns