Solution of the dynamic programming equation for a trading problem