Bond Prices
Assume that the short rate $r_t$ follows the Ito process as described by the following stochastic differential equation
\begin{align}
d{{r}_{t}}=\mu ({{r}_{t}},t)dt+\sigma ({{r}_{t}},t)d{{W}_{t}^{P}}
\end{align}
we assume the bond price to be dependent on $r_t$ only, independent of default risk, liquidity and other factors. If we write the bond price as $P(r_t, t)=V(t,r_t,T)$ such that $V(t,r_t,t)=1$ then
\begin{align}
dV=({{V}_{t}}+\mu \,{{V}_{r}}\,+\frac{1}{2}{{\sigma }^{2}}{{V}_{rr}})dt+\sigma {{V}_{r}}d{{W}_{t}}
\end{align}
for simplicity let
\begin{align}
& {{\mu }_{V}}=\frac{{{V}_{t}}+\mu {{V}_{r}}\,+\frac{1}{2}{{\sigma }^{2}}{{V}_{rr}}}{V} \\
& {{\sigma }_{V}}=\frac{\sigma {{V}_{r}}\,}{V} \\
\end{align}
thus we have
\begin{align}
dV={{\mu }_{V}}\,Vdt+{{\sigma }_{V}}\,V\,d{{W}_{t}}
\end{align}
The following portfolio is constructed: we buy a bond of dollar value V1 with maturity $T_1$ and sell another bond of dollar
value $V_2$ with maturity $T_2$. The portfolio value $\Pi$ is given by
\begin{align}
\Pi ={{V}_{1}}-{{V}_{2}}
\end{align}
According to the bond price dynamics,we have
\begin{align}
\Pi =({{\mu }_{{{V}_{1}}}}{{V}_{1}}-{{\mu }_{{{V}_{2}}}}{{V}_{2}})\,dt+({{\sigma }_{{{V}_{1}}}}{{V}_{1}}-{{\sigma }_{{{V}_{2}}}}{{V}_{2}})\,d{{W}_{t}}
\end{align}
Suppose $V_1$ and $V_2$ are chosen such that
\begin{align}
& {{V}_{1}}=\frac{{{\sigma }_{{{V}_{2}}}}}{{{\sigma }_{{{V}_{2}}}}-{{\sigma }_{{{V}_{1}}}}}\Pi \\
& {{V}_{2}}=\frac{{{\sigma }_{{{V}_{1}}}}}{{{\sigma }_{{{V}_{2}}}}-{{\sigma }_{{{V}_{1}}}}}\Pi \\
\end{align}
then the stochastic term in $d\Pi$ vanishes and the equation becomes
$$d\Pi =\left( \frac{{{\mu }_{{{V}_{1}}}}{{\sigma }_{{{V}_{2}}}}-{{\mu }_{{{V}_{2}}}}{{\sigma }_{{{V}_{1}}}}}{{{\sigma }_{{{V}_{2}}}}-{{\sigma }_{{{V}_{1}}}}} \right)\Pi \,dt$$
Since the portfolio is instantaneously riskless, in order to avoid arbitrage opportunities,it must earn the riskless short rate so that $d\Pi =r(t)\Pi dt$ ,then
$$\frac{{{\mu }_{{{V}_{1}}}}-r(t)}{{{\sigma }_{{{V}_{1}}}}}=\frac{{{\mu }_{{{V}_{2}}}}-r(t)}{{{\sigma }_{{{V}_{2}}}}}$$
The above relation is valid for arbitrary maturity dates $T_1$ and $T_2$, so the ratio should be independent of maturity $T$.Let the common ratio be defined
by $\lambda$, that is,
$$\frac{{{\mu }_{V}}-r(t)}{{{\sigma }_{V}}}=\lambda \,({{r}_{t}},t)$$
The quantity $\lambda$ is called the market price of risk of the short rate.If we substitute $μ_V(r, t)$ and $σ_V(r, t)$ into above Equation, we obtain the following governing differential equation for the price of a zero-coupon bond
$${{V}_{t}}+(\mu -\lambda \sigma \,){{V}_{r}}\,+\frac{1}{2}{{\sigma }^{2}}{{V}_{rr}}-{{r}_{t}}\,V=0$$
Change Measure
we assume $Q$ be a martingale measure such that
$$dW_{t}^{P}=-\lambda(r,t)dt+dW_{t}^{Q}$$
thus we have
$$d{{r}_{t}}=\mu^*(r_t,t)dt+\sigma ({{r}_{t}},t)dW_{t}^{Q}$$
where
$$\mu^*(r_t,t)=\mu({{r}_{t}},t)-\lambda ({{r}_{t}},t)\sigma ({{r}_{t}},t)$$
Affine Term Structure Models
A short rate model that generates the bond price solution of the form
$$P(t\,,T)=V(t,r_t,T)={{e}^{A(t,T)\,-\,B(t,T){{r}_{t}}\,}}$$
Suppose the dynamics of the short rate $r_t$ under the risk neutral measure $Q$ is governed by
\begin{align}
d{{r}_{t}}=\mu^* ({{r}_{t}},t)dt+\sigma ({{r}_{t}},t)d{{W}_{t}^{Q}}
\end{align}
where
\begin{align}
&\mu^* ({{r}_{t}},T)=\alpha (t)\,{{r}_{t}}+\beta (t) \\
&{{\sigma }^{2}}({{r}_{t}},T)=\gamma (t)\,{{r}_{t}}+\delta (t) \\
\end{align}
We show the governing equation for $P(t, T )=V(t,r,T)$ is given by
$${{V}_{t}}+\mu ^*{{V}_{r}}\,+\frac{1}{2}{{\sigma }^{2}}{{V}_{rr}}-{{r}_{t}}\,V=0$$
Substituting the assumed affine solution of bond price into this equation, we obtain
\begin{align}
& {{B}_{t}}(t,T)+\alpha (t)B(t,T)-\frac{1}{2}\gamma (t){{B}^{2}}(t,T)=-1 \\
&B(T,T)=0 \\
\end{align}
and
\begin{align}
& {{A}_{t}}(t,T)=\beta (t)B(t,T)-\frac{1}{2}\delta (t){{B}^{2}}(t,T) \\
& A(T,T)=0 \\
\end{align}
Vasicek Model
Vasicek (1977) proposed the stochastic process for the short rate $r_t$ under the Martingle measure to be governed by the Ornstein–Uhlenbeck process:
$$d{{r}_{t}}=a(b-r_t)dt+\sigma d{{W}_{t}^{Q}}$$
hence
\begin{align}
& \alpha (t)=-a\,\,\,\,\,\,,\,\,\,\,\,\,\,\beta (t)=ab \\
& \gamma (t)=\,0\,\,\,\,\,\,\,\,\,\,\,,\,\,\,\,\,\,\,\,\delta (t)={{\sigma }^{2}} \\
\end{align}
thus we have
$$ B(t,T)= \frac{1 - e^{-a(T-t)}}{a}\\$$
and
$$ A(t,T)= exp\left((b + \frac{\sigma\phi}{a}-\frac{\sigma^2}{a^2})(B(t,T) - T + t) + \frac{B(t,T)^2\sigma^2}{4a}\right)$$