The article studies stochastic optimization of an intertemporal consumption model to allocate financial assets between risky and risk-free assets. We use a stochastic optimization technique, in which utility is maximized subject to a self-financing portfolio constraint. The papers in literature have estimated the errors of Euler equations using data from financial markets. It has been shown that it is sufficient to test the first order Euler equation implied by the model. However, they all assume a constant consumption-wealth ratio that constrains the boundary conditions, hence influencing the coefficient of the risk premium. The main contribution of our article is that we drop the assumption of a constant consumption-wealth ratio. We have an analytical solution using a utility maximization model with a stochastic self-financing portfolio. We introduce a terminal condition of wealth with and without bequests. We also simulate the stochastic optimization with a self-financing portfolio, distinguishing risk neutral investors (-low) from high risk averse investors (-high). We show that the model with bequest has a higher level of wealth and a smoother decline of consumption over time than the model with no bequest at the end of the period. The model with no bequest has the same level of consumption and a sharp fall at the end of the period. Risk averse agents with high return assets have a higher amount of wealth than risk-neutral agents with lower return assets.