For a long investment time horizon, it is preferable to rebalance the portfolio weights at intermediate times. This necessitates a multi-period market model. Usually, dynamic programming techniques are applied to optimize the portfolio for the multi-period model. However, this assumes a known distribution for the parameters of the financial time series. We consider the situation where the distribution of parameters is unknown and is estimated directly from the dynamically arriving data. We implement the Bayesian filtering method through dynamic linear models to sequentially update the parameters. We also acknowledge the uncertain investment lifetime to make the model more adaptive to the market conditions. These updated parameters are put into the dynamic mean–variance problem to arrive at optimal efficient portfolios. Implementing this model to the S&P500 illustrates that the data strongly favor the Bayesian updating and is practically implementable. © 2021, Grace Scientific Publishing.