Class MaximizeStandardDeviation

java.lang.Object
com.polytechnik.utils.MaximizeStandardDeviation

public class MaximizeStandardDeviation extends Object
Find \( \left|\psi\right> \) state such that \[ P\&L=\frac{\left<\psi|(p-\mathtt{pa})^2 I| \psi\right>}{\left<\psi|\psi\right> } \xrightarrow[\psi]{\quad }\max \] subject to: \[ \left<\psi|(p-\mathtt{pa}) I|\psi\right>=0 \] The constant \( \mathtt{pa}=\left<\psi|p I|\psi\right>/\left<\psi|I|\psi\right> \) is average price in \( \left|\psi\right> \) state. and the functional itself has the meaning of \( P\&L \). Contrary to pure iteration type approach of DIminP2maxI this implementation uses Lagrange multipliers technique to improve the convergence. The functional \[ \left<\psi|(p-\mathtt{pa})^2 I| \psi\right> +\mu\left<\psi|(p-\mathtt{pa}) I|\psi\right> - \lambda\left[\left<\psi|\psi\right> -1\right] \] is constructed. Variate it by \( \left|\psi\right> \) , obtain the equation: \[ \left|(p-\mathtt{pa})^2 I| \psi\right> +\mu\left|(p-\mathtt{pa}) I|\psi\right>= \lambda\left|\psi\right> \] An iteration process is:
  • For an initial \( \left|\psi\right> \) calculate average price \( \mathtt{pa} \) and Lagrange multiplier \( \mu \): \begin{align} \mathtt{pa}&=\frac{\left<\psi|p I|\psi\right>}{\left<\psi|I|\psi\right>} \\ \left|b\right>&=\left|(p-\mathtt{pa}) I|\psi\right> \\ \mu &= - \, \frac{\left<b|(p-\mathtt{pa})^2 I|\psi\right>}{\left<b|b\right>} \end{align}
  • Construct the matrix \[ \left|{\cal PL}\right|= \left|(p-\mathtt{pa})^2 I\right| +\mu\left|(p-\mathtt{pa}) I\right| \]
  • Solve eigenvalue problem \[ \left|{\cal PL}|\psi^{[i]}\right>= \lambda^{[i]} \left|\psi^{[i]}\right> \] and take the state \( \left|\psi^{[i]}\right> \) corresponding an eigenvalue \( \lambda^{[i]} \) as next iteration \( \left|\psi\right> \) . Often (but not always!) this is the state corresponding to maximal eigenvalue. In general case see MaximizeStandardDeviation.EVSelection that selects the state of maximal \( P\&L \).
  • Take the matrix \( \left|{\cal PL}\right| \) with updated \( \mathtt{pa} \) and \( \mu \) and repeat the process of above for this new \( \left|\psi\right> \) . If a solution exists -- iteration process converges quickly (typically 5-7 iterations), unless price \( |p| \) and execution flow \( |I| \) operators have several eigenvectors in common; for example when \( \left|(p-\mathtt{pa})^2 I\right| \) and \( \left|(p-\mathtt{pa})I\right| \) operators have the same eigenvectors the \( \left|{\cal PL}\right| \) eigenvectors are always the same and iteration process fails. On the first iteration as \( \left|\psi\right> \) select an eigenvectors of the problem \( \left|I|\psi\right>=\lambda\left|\psi\right> \) , a few eigenvectors corresponding to large execution flow is a good try. Typically the MaximizeStandardDeviation.StandardDeviationForPsi is used to calculate the \( P\&L \) for all these eigenvectors and sorting them by it.
  • The result of this iteration process is the state of maximal \( P\&L \) , it is equal to the value of maximal eigenvalue of \( \left|{\cal PL}|\psi^{[i]}\right>= \lambda^{[i]} \left|\psi^{[i]}\right> \) problem. Position change \( dS \) corresponding to it is: \begin{align} dS&=-(p-\mathtt{pa})\psi^2(x(t))\omega(t) dV \\ P\&L&= -\int p dS = \left<\psi|(p-\mathtt{pa})^2I|\psi\right> = \lambda^{[\max]}\\ 0&=\int dS = - \left<\psi|(p-\mathtt{pa})I|\psi\right> \end{align} Position change is a subject to \(0=\int dS\) constraint, \( P\&L \) is a covariance (with minus sign) between price and postion change. The \( P\&L \) can be written in dual form by applying integration by parts to express it not via postion change \( dS \) but via postion \( S\) itself: \begin{align} S(t_{now})&=\int_{t=-\infty}^{t=t_{now}} dS \\ P\&L&= \int S dp \\ 0&=S(-\infty)=S(t_{now}) \end{align} Directional information can be obtained from considering \( S(t) \) behavior, localized form of \( \psi^2(x(t)) \) makes it often sufficient to consider \( \left<S\right> \) : whether "on average" we have to be long or short. In some \( x, \omega(x) \) bases \( \left<S\right> \) can be plain reduced to \( \left<\psi|(p-\mathtt{pa})Ix|\psi\right> \) form or similar; in such a case normalized solution to market direction can be e.g. a correlation between \( (p-\mathtt{pa})I \) and \( x \) in the found state \( \left|\psi\right> \) , see an example in unit test PnLInPsiHstate.PnLInPsiHstateTest.test_Extra(). In general, however, such a correlation-style approach is typically unsatisfactory.
This class takes four matrices \( \left<Q_j Q_k\right>, \left<Q_j I Q_k\right>, \left<Q_j pI Q_k\right>, \left<Q_j p^2I Q_k\right> \) as input, runs the algorithm of above and obtains the state psi_PnLMax corresponding to maximal \( P\&L \).
See Also: