# Where this HJB equation comes from?

On top of page 6, there is a HJB equation I don't know where it is from and how to understand it. I am new to this topic so I searched many books regarding to optimal control and HJB but still couldn't figure it out. Could you help please? By bellman's principal of optimality, at each time step we want to minimize (or maximize when we have utility gain instead of cost function) value function update + utility loss (or gain). Value function update from time $$t$$ to $$t+dt$$ is first two items of taylor series expansion of value function;
For gain, think of at each time $$t$$, if your inventory didn't hit upper and lower limit $$Q$$, you can either sell or buy from market participants, and earn that spread accordingly. By doing each, your cash inventory, would decrease or increase by $$s$$, and increase by the bid/offer spread you earned. Since incoming orders on both sides have different arrival intensity (probability of occurrence), you "discount" your utility gain by the probability.