Design, Testing, and Optimization of Trading Systems