Likelihood-based inference and forecasting for trawl processes: a stochastic optimization approach