Solution (source code)

= Solution

A trading strategy chooses a vector $H_t$ of holdings for the period $(t-1,t]$, with $H_t$ measurable with respect to $\mathcal F_{t-1}$. Its end-of-period wealth is $X_t=H_t\cdot P_t$. Rebalancing at date $t$ is <self-financing> when
$$
H_{t+1}\cdot P_t=H_t\cdot P_t;
$$
new holdings cost exactly the value released by the old holdings. With fixed initial capital $x$, the equivalent gains identity is
$$
\boxed{X_t=x+\sum_{u=1}^t H_u\cdot(P_u-P_{u-1}).}
$$
A <European contingent claim> is a maturity-$T$ payoff $\xi$ measurable with respect to $\mathcal F_T$. It is attainable if there exists a <predictable> <self-financing strategy> and an initial capital $x$ for which $X_T=\xi$ almost surely. Such a strategy is a <replicating strategy>, and $x$ is its initial replication cost. Holdings are understood only up to the maturity being replicated.