# How to determine components of Affine Term Structure for an Ohrnstein-Uhlenbeck process?

I wonder how I can determine the components $$A(t,T)$$ and $$B(t,T)$$ for the zero-coupon bond price process $$p(t,T)=e^{A(t,T)-r(t)B(t,T)}$$? The components are defined in the following link: https://en.wikipedia.org/wiki/Affine_term_structure_model

The short rate dynamics follows a Ohrnstein-Uhlenbeck process, $$dr(t)=(b-ar(t))dt+dW^Q(t)$$

Solution so far:

Explicit solution for Ohrnstein-Uhlenbeck process is,

$$r(T)=r(t)e^{-a(T-t)}+\frac{b}{a}(1-e^{-a(T-t)})+\sigma \int_{t}^{T} e^{-a(T-t-u)} dW_u^Q$$

By risk-neutral valuation,

$$\Pi = E^Q_t[\frac{B(t)}{B(T)}r(T)B(T)]=B(t)(r(t)e^{-a(T-t)}+\frac{b}{a}(1+e^{-a(T-t)}))$$

$$B(t)=e^{-\int_{0}^{t} r(u)du}$$

From here I do not know how to solve $$A(t,T)$$ or $$B(t,T)$$. It might be that I am tired. I would appreciate some guidance. Thank you.

Let $$\mathrm{d}r_t=\mu(t,r_t)\mathrm{d}t+\sigma(t,r_t)\mathrm{d}W_t$$ be a model for the short rate under the risk-neutral measure $$\mathbb{Q}$$. Starting from the bond PDE \begin{align*} P_t + \mu(t,r) P_r + \frac{1}{2}\sigma(t,r)^2P_{rr} -rP=0, \end{align*} subject to $$P(T,T)=1$$ whose general solution is $$P(t,T)=\mathbb{E}^\mathbb{Q}\left[e^{-\int_t^T r_u\mathrm{d}u}\mid\mathcal{F}_t\right]$$ (siehe Feynman Kac).
To get an ATS model, you now guess'' that $$P(t,T)=e^{A(t,T)+r_tB(t,T)}$$ with \begin{align*} P_t(t,T) &=\big(A_t(t,T)+r_tB_t(t,T)\big)\cdot P(t,T), \\ P_r(t,T) &= B(t,T)\cdot P(t,T), \\ P_{rr}(t,T) &= B(t,T)^2\cdot P(t,T). \end{align*} Pluggig this into the above PDE, you get \begin{align*} A_t(t,T) + \mu(t,r) B(t,T) + \frac{1}{2}\sigma(t,r)^2B(t,T)^2 +(B_t(t,T)-1)r &=0. \end{align*} The terminal boundary condition becomes $$A(T,T)=B(T,T)=0$$.
In the Vasicek case, $$\mu(t,r_t)=\kappa(\theta-r_t)$$ and $$\sigma(t,r_t)=\sigma$$. Thus, \begin{align*} A_t(t,T) + \kappa \theta B(t,T) - \kappa r B(t,T) + \frac{1}{2}\sigma^2B(t,T)^2 +(B_t(t,T)-1)r &=0 \\ \implies A_t(t,T) + \kappa \theta B(t,T) + \frac{1}{2}\sigma^2B(t,T)^2-(1-B_t(t,T)+\kappa B(t,T))r &=0. \end{align*}
This equation needs to be satisfies for all $$r$$. Thus, you obtain the following system of (first-order ordinary differential) equations \begin{align*} \begin{cases} A_t(t,T) + \kappa \theta B(t,T) + \frac{1}{2}\sigma^2B(t,T)^2 &= 0, \\ 1-B_t(t,T)+\kappa B(t,T) &= 0, \end{cases} \end{align*} subject to $$A(T,T)=B(T,T)=0$$. You now solve the second equation first in closed form and then, with this result, you can solve the first equation. You then arrive at the standard Vasicek bond price formula.