The Elements of Pairs Trading