Dynamic Stochastic Optimization with Applications in Finance