Discrete Tanaka formula (source code)

= Discrete Tanaka formula

For integer paths with increments in $\{-1,0,1\}$, the <positive part> obeys a telescoping identity with slope $f(x)=\mathbf1_{\{x>0\}}+\frac12\mathbf1_{\{x=0\}}$ and a correction $\frac12\mathbf1_{\{S_{t-1}=K\}}(\Delta S_t)^2$ at the kink. For a <martingale>, the slope term is a <martingale transform>.