I have a nonnegative random variable $X$ with $E[X] < \infty$, that admits a density wrt to the Lebesgue measure. For arbitrary $K > 0$, I write
$$P(K) = E[\max(X-K,0)]$$ I am interested in the function $K \mapsto P(K)$. My first question is
Under what conditions is $P$ twice differentiable?
My second question is assuming that it exists,
What is $\frac{\partial^2 P}{\partial K^2}$?
With some handwaving I can "show" that $\frac{\partial^2 P}{\partial K^2} = f_{X}(K)$ where $f_X(K)$ is the density of $X$ evaluated at $K$. I reason as follows.
\begin{align} \frac{\partial^2 P}{\partial K^2} &= \lim_{h\to 0}\frac{P(K+h) - 2P(K) + P(K-h)}{h^2} \\ &= \lim_{h\to 0}\frac{E[\max(X-(K+h),0) - 2\max(X-K,0) + \max(X-(K-h),0)]}{h^2}\\ &\stackrel{(1)}{=}E\left[\lim_{h\to 0}\frac{\max(X-(K+h),0) - 2\max(X-K),0) + \max(X-(K-h),0)}{h^2}\right]\\ &\stackrel{(2)}{=}E\left[\delta_{K}(X)\right]\\ &\stackrel{(3)}{=}f_X(K) \end{align} $\delta_K(X) := \delta(X-K)$ denotes the Dirac delta function above.
Things that require justification (as far as I can tell) are the numbered equalities above.
$(1)$ is clear. Some kind of dominated convergence must be invoked here. I did not think about this step in depth to be honest.
$(2)$ is bizarre, to say the least, but my reasoning is there is that the function inside the limit is an isosceles triangle with base $2h$ and height $1/h$ for every $h > 0$. It always integrates to $1$ and is zero outside the interval$[K-h,K+h]$. So as $h \to 0$ it "should" converge to the Dirac delta function in some sense.
$(3)$ is probably justified. Since $X$ admits a density, $$E\left[\delta_{K}(X)\right] = \int\delta_{K}(x)f_X(x)dx = f_X(K)$$ I see no issue here but I am not absolutely certain either.
I would very much appreciate it if someone could give me hints/pointers as to what needs to be done to make all the arguments here fully precise.
Let $\mu$ be the CDF of $X$. Then $$ P(K)=\mathbb{E}\left(X-K\right)^+=\int_{\mathbb{R}}\left(x-K\right)^+{\rm d}\mu=\int_K^{\infty}\left(x-K\right){\rm d}\mu=\int_K^{\infty}x{\rm d}\mu-K\left(1-\mu(K)\right), $$ or more clearly, $$ P(K)=K\mu(K)+\mathbb{E}X-K-e(K), $$ where $$ e(K)=\int_0^Kx{\rm d}\mu, $$ and obviously, $e(\infty)=\mathbb{E}X$.
Thanks to this result, if $\mu$ yields a PDF $f$, i.e., ${\rm d}\mu(x)=f(x){\rm d}x$, then $$ P'(K)=\mu(K)+Kf(K)-1-Kf(K)=\mu(K)-1, $$ and thus $$ P''(K)=f(K). $$