ajdmom.ito_mom

Itô process moments under Single Square-Root Diffusion Process

The content has also been explained in Program Design page.

Insights

All \(\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\) can be represented as a “Polynomial” of the following form

\[\begin{split}&\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\\ &= \sum_{n_3,i,j,l,o,p,q} b_{n_3ijlopq} e^{n_3k(n-1)h} e^{ik[t-(n-1)h]} [t-(n-1)h]^jv_{n-1}^l k^{-o}\theta^p\sigma_v^q\end{split}\]

where \(b_{ijlopq}\) is the coefficient.

To facilitate the representation and corresponding operations, I designed a new class Poly which is derived from UserDict in the Python Standard Library collections.

Integrals

The essential computation in recursive equation (3) of Theory is that of the following integral

\[\int_{(n-1)h}^t e^{ik[s-(n-1)h]} [s-(n-1)h]^j ds.\]

For the indefinite integral, we have

\[\begin{split}\int e^{nkt} t^m dt = \begin{cases} \sum_{i=0}^m c_{nmi} \frac{1}{k^{i+1}}e^{nkt} t^{m-i} & \text{if } n\neq 0, m \neq 0,\\ \frac{1}{nk}e^{nkt}t^0 & \text{if } n\neq 0, m = 0,\\ \frac{1}{m+1}e^{0kt}t^{m+1} & \text{if } n = 0, m \neq 0,\\ e^{0kt}t^1 & \text{if } n =0 , m=0, \end{cases}\end{split}\]

where \(c_{nm0} \triangleq \frac{1}{n}\) and

\[c_{nmi} \triangleq \frac{(-1)^{i}}{n^{i+1}} \prod_{j=m-i+1}^{m} j, \quad 1\le i \le m.\]

The coefficient \(c_{nmi}\) is implemented in function c_nmi() which returns a fractions.Fraction instead of a decimal (float number).

For the definite integral,

\[\int_{(n-1)h}^t e^{ik[s-(n-1)h]}[s-(n-1)h]^jds = F(t-(n-1)h) - F(0)\]

where \(F(t) = \int e^{nkt} t^m dt\). The definite integral is implemented in int_et().

Polynomial Representation

The result of the integral, returned by int_et(), is represented as a “polynomial” of the following form

\[\int_{(n-1)h}^t e^{ik[s-(n-1)h]} [s-(n-1)h]^j ds = \sum_{i,j^{'},l}c_{ij^{'}l}e^{ik[t-(n-1)h]}[t-(n-1)h]^{j^{'}}k^{-l}\]

which is encoded in a Poly, derived from collections.UserDict, with keyfor = ('e^{k[t-(n-1)h]}','[t-(n-1)h]','k^{-}'), key = \((i,j^{'},l)\) and value = \(c_{ij^{'}l}\).

Code Design

Itô process moment - I

With \(\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}|v_{n-1}]\) represented as a “polynomial” of the following form

\[\begin{split}&\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\\ &= \sum_{n_3,i,j,l,o,p,q} b_{n_3ijlopq} e^{n_3k(n-1)h} e^{ik[t-(n-1)h]} [t-(n-1)h]^jv_{n-1}^l k^{-o}\theta^p\sigma_v^q,\end{split}\]

consequently, we have

\[\begin{split}&e^{-kt}\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\\ &= \sum_{n_3,i,j,l,o,p,q} b_{n_3ijlopq} e^{(n_3-1)k(n-1)h} e^{(i-1)k[t-(n-1)h]}[t-(n-1)h]^jv_{n-1}^l k^{-o}\theta^p\sigma_v^q,\\ &e^{kt}\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\\ &= \sum_{n_3,i,j,l,o,p,q} b_{n_3ijlopq} e^{(n_3+1)k(n-1)h} e^{(i+1)k[t-(n-1)h]}[t-(n-1)h]^jv_{n-1}^l k^{-o}\theta^p\sigma_v^q,\\ &e^{2kt}\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\\ &= \sum_{n_3,i,j,l,o,p,q} b_{n_3ijlopq} e^{(n_3+2)k(n-1)h} e^{(i+2)k[t-(n-1)h]}[t-(n-1)h]^jv_{n-1}^l k^{-o}\theta^p\sigma_v^q.\end{split}\]

Therefore, it’s profitable to consider the following generic integral

\[\begin{split}&\int_{(n-1)h}^t e^{mks}\mathbb{E}[I\!E_{n-1,s}^{n_3}I_{n-1,s}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]ds\\ &= \sum_{n_3,i,j,l,o,p,q} b_{n_3ijlopq} e^{(n_3+m)k(n-1)h} \cdot int\_et(i+m,j)\cdot v_{n-1}^l k^{-o}\theta^p\sigma_v^q\\ &= \sum_{n_3+m,i+m,j^{'},l,o^{'},p,q} b_{(n_3+m)(i+m)j^{'}l o^{'}pq} e^{(n_3+m)k(n-1)h} e^{(i+m)k[t-(n-1)h]} [t-(n-1)h]^{j^{'}}\\ &\qquad \cdot v_{n-1}^{l} k^{-o^{'}}\theta^{p}\sigma_v^{q}\end{split}\]

where

\[int\_et(i+m,j) =\sum_{i+m,j^{'},l^{'}} c_{(i+m)j^{'}l^{'}}e^{(i+m)k[t-(n-1)h]} [t-(n-1)h]^{j^{'}} k^{-l^{'}}.\]

Implementation:

  1. Function int_e_poly() in module ito_mom is defined to accomplish the computation in equation (2) of Program Design.

  2. Function recursive_IEII() in module ito_mom is defined to realize the recursive step in equation (3) of Theory.

  3. Function moment_IEII() in module ito_mom is implemented to calculate \(\mathbb{E}[I\!E_n^{n_3}I_n^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\).

For demonstration, I re-write the following initial three moments in Itô process Moments - I in Theory according to the “polynomial” representation

\[\begin{split}\mathbb{E}[I\!E_{n-1,t}^2|v_{n-1}] &=& \frac{1}{2}&e^{2k(n-1)h} e^{2k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^0 k^{-1}\theta^1\sigma_v^0\\ && + &e^{2k(n-1)h}e^{k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^1 k^{-1}\theta^0\sigma_v^0\\ && - &e^{2k(n-1)h}e^{k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^0 k^{-1}\theta^1\sigma_v^0\\ && - &e^{2k(n-1)h}e^{0k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^1 k^{-1}\theta^0\sigma_v^0\\ && + \frac{1}{2} &e^{2k(n-1)h}e^{0k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^0 k^{-1}\theta^1\sigma_v^0,\\ % \mathbb{E}[I\!E_{n-1,t}I_{n-1,t}|v_{n-1}] &=& &e^{k(n-1)h} e^{k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^0 k^{-1}\theta^1\sigma_v^0\\ && +&e^{k(n-1)h} e^{0k[t-(n-1)h]}[t-(n-1)h]^1v_{n-1}^1 k^{-0}\theta^0\sigma_v^0\\ && -&e^{k(n-1)h} e^{0k[t-(n-1)h]}[t-(n-1)h]^1v_{n-1}^0 k^{-0}\theta^1\sigma_v^0\\ && -&e^{k(n-1)h} e^{0k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^0 k^{-1}\theta^1\sigma_v^0,\\ % \mathbb{E}[I_{n-1,t}^2|v_{n-1}] &=&-&e^{0k(n-1)h} e^{-k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^1 k^{-1}\theta^0\sigma_v^0\\ && +&e^{0k(n-1)h} e^{-k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^0 k^{-1}\theta^1\sigma_v^0\\ && +&e^{0k(n-1)h} e^{0k[t-(n-1)h]}[t-(n-1)h]^1v_{n-1}^0 k^{-0}\theta^1\sigma_v^0\\ && +&e^{0k(n-1)h} e^{0k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^1 k^{-1}\theta^0\sigma_v^0\\ && -&e^{0k(n-1)h} e^{0k[t-(n-1)h]}[t-(n-1)h]^0v_{n-1}^0 k^{-1}\theta^1\sigma_v^0.\end{split}\]

Functions

c_nmi(n, m, i)

Coefficent \(c_{nmi}\) as in (1).

int_e_poly(c, tp, m, poly)

Integral of \(c \times tp \times \int_{(n-1)h}^t e^{mks} poly ds\)

int_et(n, m)

\(\int_{(n-1)h}^{t} e^{ik[s-(n-1)h]}[s-(n-1)h]^jds\)

moment_IEII(n3, n4, n5)

\(\mathbb{E}[I\!E_{n-1,t}^{n_3}I_{n-1,t}^{n_4}I_{n-1,t}^{*n_5}|v_{n-1}]\)

moment_v(n)

Moment of \(v_{n-1}\) as in equation (1)

poly2num(poly, par)

Convert a polynomial to numerical value

recursive_IEII(n3, n4, n5, IEII)

Recursive step in equation (3)