Given the return series for a set of instruments, a trading strategy is a switching function that transfers wealth from one instrument to another at specified times. We present efficient algorithms for constructing (ex-post) trading strategies that are optimal with respect to the total return, the Sterling ratio and the Sharpe ratio. Such optimal strategies are useful as benchmarks, and for identifying the optimal trades that can be used to to teach (ex-ante) predictors within a learning framework.