Class TradingPair


  • public class TradingPair
    extends Object
    • Field Detail

      • symbol1

        protected final String symbol1
      • symbol2

        protected final String symbol2
      • price1

        protected final Vector price1
      • price2

        protected final Vector price2
      • beta

        protected final double beta
      • returns

        protected Matrix returns
      • spread

        protected Vector spread
    • 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 asset
        symbol2 - symbol for the second asset
        price1 - price for the first asset
        price2 - price for the second asset
        beta - 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)