General Pairs Trading