Class TradingPair
- java.lang.Object
-
- tech.nmfin.meanreversion.cointegration.TradingPair
-
public class TradingPair extends Object
-
-
Constructor Summary
Constructors Constructor Description TradingPair(String symbol1, String symbol2, Vector price1, Vector price2, double beta)Constructs a related pair for trading, e.g., cointegrated pair.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublebeta()doublecor(double tailed)doublemean()Computes the sample mean of the in-sample spread.Vectorspread()S = A - bBdoublestdev()Gets the stdev of the spread.doublestdev(double tailed)Gets the stdev of the last % portion in the spread.Stringsymbol1()Stringsymbol2()StringtoString()
-
-
-
Constructor Detail
-
TradingPair
public TradingPair(String symbol1, String symbol2, Vector price1, Vector price2, double beta)
Constructs a related pair for trading, e.g., cointegrated pair.- Parameters:
symbol1- symbol for the first assetsymbol2- symbol for the second assetprice1- price for the first assetprice2- price for the second assetbeta- the (e.g., cointegrated) beta to form a spread
-
-
Method Detail
-
symbol1
public String symbol1()
-
symbol2
public String symbol2()
-
beta
public double beta()
-
spread
public Vector spread()
S = A - bB- Returns:
- the spread
-
mean
public double mean()
Computes the sample mean of the in-sample spread.- Returns:
- the sample mean of the spread
-
stdev
public double stdev(double tailed)
Gets the stdev of the last % portion in the spread.- Parameters:
tailed- the last % portion in the data- Returns:
- the standard deviation
-
stdev
public double stdev()
Gets the stdev of the spread.- Returns:
- the standard deviation
-
cor
public double cor(double tailed)
-
-