Improving time series and cross-sectional momentum trading strategies using stochastic programming