Package tech.nmfin.returns
Class Returns
- java.lang.Object
-
- tech.nmfin.returns.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Vector
getMeanReturns(double[][] returns)
Computes a vector of mean returns of the input returns (one column for one asset).static Vector
getMeanReturns(Matrix returns)
Computes a vector of mean returns of the input returns (one column for one asset).static double[]
getPricesFromReturns(double price0, double[] returns, ReturnsCalculator calc)
Gets the price series from a return series.static double[]
getReturns(double[] lastPrices, double[] currentPrices, ReturnsCalculator calc)
static double[]
getReturnsFromPrices(double[] prices, ReturnsCalculator calc)
Computes returns series from prices.static double[][]
getVectorReturnsFromPrices(double[][] prices, ReturnsCalculator calc)
Computes returns for a 2D array of prices (one column for one asset), with the given ReturnsCalculator.
-
-
-
Method Detail
-
getReturnsFromPrices
public static double[] getReturnsFromPrices(double[] prices, ReturnsCalculator calc)
Computes returns series from prices.- Parameters:
prices
- a series of pricescalc
- 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 pricereturns
- a return seriescalc
- 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 arraycalc
- 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
-
-