User:Math4543/sandbox

Introduction
Chart to Scalar Theory says there is a correspondence or relation between discrete buy and sell orders in the stock market volume and stock market geometry on the boundary. The boundary represents the charts which we can see. If you peel it back, there are buy and sell orders which are contained in the volume. The idea of the scalar is to encode the properties of the stock market into a scalar which represents a constraint of a hypothetical stock chart constrained by boundary conditions.

Making reference to the original paper, solutions to problems in Chart to Scalar where $$\phi_r<1$$ are not unique, meaning there are two solutions: a concave and a convex one for the RHS (right-hand-side).

A problem in Chart to Scalar requires finding the scalar, d, which serves as a constraint for a variational equation.

The scalar is represented by the one-form of the hypothetical RHS path for the stock:

$$d=\int_{x_1}^{x_2}f_{r}(x)\, dx$$ where $$f_r$$ is a function of minimum length

Variational equation:

$$ L = |x_2-x_1|+|p_2-p_1| + \int_{x_1}^{x_2} \sqrt { 1 + [f_{r}'(x)]^2 }\, dx $$

This is a Isoperimetric problem where the length is minimized while constrained by d and $$f_r$$ which is contained within the rectangular RHS region $$(x_1 \times x_2) (p_2 \times p_1)$$

The introduction of integrals $$a_l,a_r$$ on the LHS and RHS equilibrium equations, respectively, allow for a single solution. This is because solving the equilibrium equation results in two unique scalar values $$d_1,d_2$$. Due to the variational principle, the value of d which confers with a longer $$f_r$$ can be discarded, leaving a path of least distance $$f_r$$ that adheres to the constraints.

Equilibrium and Buy Order Equations
Define $$a_l,a_r$$ as the average price of $$f_l,f_r$$:

$$a_l=(x_1-x_a)^{-1}\int_{x_a}^{x_1}f_{l}(x)\, dx$$

$$a_r= \frac{d}{x_2-x_1}$$

The equilibrium equation with $$a_l,a_r$$:

$$\Lambda_l= \Lambda_R$$ or $$a_l v_l w_l\phi_l= a_r v_r w_r \phi_r$$

If $$\eta_l=1$$, the equilibrium equation can be interpreted to mean that the amount of money flowing into a stock on the LHS must equal the amount that flows out on the RHS. Or if $$\eta_l=-1$$, the amount of money that flows into the stock on the RHS must equal the amount that flowed out on the LHS.

The buy order equation:

$$b_o=\frac{1}{2a_v}\left (v_r-\frac{\eta_l\Lambda_l}{a_r}\right ) $$

Sell order equation: $$s_o=v_r/a_v-b_o$$

These equations convert LHS geometry into discrete buy and sell orders, which is useful for applications like option pricing.

The LHS functionals are restricted to the rectangular region:

$$(x_0 \times x_1) (p_3 \times p_1)$$ Where $$x_a=f_l^{-1}(p_2)$$ and $$x_0 \le x_a \le x_1$$

If, for example, let $$\eta_l=1$$. Then $$p_3 \le p_2 \le p_1$$

For the RHS, we have the following components:

$$w_{r}=\frac{-\ln(p_2/p_1)}{-\ln(p_2/p_1)+2(x_2-x_1)/(x_1-x_{a})}$$

RHS Convex: $$\phi_r=\frac{2p_1-2d}{p_1-p_2}$$ RHS Concave: $$\phi_r=\frac{2d-2p_2}{p_1-p_2}$$

( note: $$\phi$$ is a value between 0 and 1 that measures how much a stock path defects from a strait line, with 1 being a line. )

$$a_r$$ is defined earlier and $$v_r$$ is the expected volume on the RHS

Example: Bursting of a Stock Market Bubble
Consider a simulation of a simple stock market market to show how the concavity of the RHS of the bubble bursting must match the LHS of the bubble inflating

The inflation of the bubble on the LHS is a concave curve given by $$f_l(x)=(p_1-p_3)x^2+p_3$$ bounded between $$(0,p_3),(1,p_1)$$. The RHS is bounded between $$(1,p_1),(2,p_3)$$. For this simulation, the hypothetical stock rises from $$p_3$$ to $$p_1$$ and it falls back to $$p_3$$ as the bubble deflates. ($$\eta_l=1$$) is chosen to indicate the LHS is rising. The LHS and RHS volume is equal and $$v_l(x)d/dx=0,v_r(x)d/dx=0$$. Thus the conditions are imposed:

The time symmetry condition: $$x_1-x_0=x_2-x_1=1$$ are imposed, meaning that the duration of events on the LHS is equal to the RHS.

Thus: $$w_l=w_r,v_l=v_r,x_a=x_0=0,x_2=2,x_1=1$$

For the LHS concave curve of form $$f_l(x)=(p_1-p_3)x^2+p_3 $$, the formula is used (making reference to original paper):

$$\phi_l(x_a)v_l(x_a)=\frac{2 v_0}{3(p_1-p_2)} \left (p_1-3p_2+2p_3+2(p_2-p_3)\sqrt{p_2-p_3 \over p_1-p_3} \right )$$

Hence, $$\phi_l=2/3$$ (because $$p_3=p_2$$) And $$a_l=(p_1+2p_3)/3$$

The equilibrium equation $$2(p_1+2p_3)/9= \phi_r a_r$$ which is solved for d (one for the concave RHS and convex RHS):

convex $$d=(3p_1+\sqrt{5p_1^2-4p_3p_1+8p_3^2})/6$$

concave $$d=(p_1+2p_3)/3$$

These are plugged into their respective $$\phi_r$$ formulas to calculate the defect. The goal is to show the convex solution has a greater defect than the concave one:

concave $$\phi_r=2/3$$

convex $$\phi_r=\frac{p_1-(\sqrt{5p_1^2-4p_3p_1+8p_3^2})/3}{p_1-p_3}$$

$$ 2/3 > convex \phi_r$$

Because of the scale invariance properties of $$\phi$$, the above formula reduces to:

$$\phi_r=\frac{x-(\sqrt{5x^2-4x+8})/3}{x-1}$$ where $$x>1$$

letting $$x=1+\epsilon$$, we have the infinite series expansion about $$\epsilon=0$$:

$$2/3>2/3-(2 \epsilon)/9+(2 \epsilon^2)/27-(4 \epsilon^4)/243+(2 \epsilon^5)/243+O(\epsilon^6)$$

Because the concave $$\phi_r$$ has a smaller defect, the path is shorter (closest to a strait line), and hence the concave path is chosen as minimizing the action. Which completes the proof.

This concave-on-concave symmetry agrees with examples in real life of various asset bubbles bursting

Example 1
Example: $$v_l=v_r=10^6$$, the x coordinates are the same as the example above, and $$p_2=p_3=50,p_1=53$$, $$f_l(x)=3x^2+50 $$ and  $$\eta_l=1$$

For this example, the RHS is a concave reflection of the RHS, thus $$\phi_l,r=2/3$$ and $$w_l,a_l=w_r,a_r$$. To compute the buy and sell orders for the RHS:

$$ b_o = \frac{10^6}{2a_v}\left (1+\frac{ 2\ln(50/53)}{3(-\ln(50/53)+2)} \right )$$

$$ b_o \approx \frac{490,000}{a_v} $$

For the rest of this summary, $$a_v=1$$ The actual choice of $$a_v$$ does not matter for non-statistical problems.

Example 2
What if $$ b_o $$ is different? Consider a general case where $$b_o$$ is only slightly less than $$v_r/2$$. Then it becomes more complicated because $$p_2$$ is unknown and $$a_r$$ cannot be assumed to be equal to $$a_l$$ and $$\phi_l$$ becomes a function in terms of $$p_2$$ instead of just 2/3.

The buy order equation and equilibrium equation must be combined for problems where the $$w_r,w_l$$ and or $$v_r,v_l$$ components are not equal, the result being a system of two equations that is solved for $$d$$ (both for the concave and convex) and $$p_2$$ (the final price of the stock, for both the concave and convex) The value of $$p_2$$ and $$d$$ corresponding to the greatest defect is discarded.

As before, $$x_1=1,x_2=2,x_0=0$$

The components are as follows:

The inverse of $$f_l$$ evaluated at $$p_2$$:

$$x_a=\sqrt{p_2-50 \over 3}$$

$$\phi_l v_l=\phi_l(x_a)v_l(x_a)=\frac{2 v_o}{3(53-p_2)} \left (153-3p_2+2(p_2-50)\sqrt{p_2-50 \over 3} \right )$$

Both $$v_o,v_r$$ will be specified later.

In the first example, $$v_o=v_l=v_r=10^6$$. $$v_l$$ is the functional form of LHS volume in terms of $$p_2$$, whereas $$v_o$$ is the total volume along the interval $$x_0,x_1$$

$$w_l= \frac{-\ln(p_2/53)}{(-\ln(p_2/53)+2)}$$

$$w_{r}=\frac{-\ln(p_2/53)}{-\ln(p_2/53)+2/(1-x_{a})}$$

$$a_l=\frac{p_2+\sqrt{3}\sqrt{p_2-50}+103}{3}$$

$$a_r=d$$

RHS Convex: $$\phi_r=\frac{106-2d}{53-p_2}$$ RHS Concave: $$\phi_r=\frac{2d-2p_2}{53-p_2}$$

The system of equations are solved for $$d$$ and $$p_2$$:

$$\Lambda_l= \Lambda_R$$

$$(v_r-2b_o)d=\Lambda_l$$

After some labor, $$\Lambda_l$$ has the series approximation about $$p_2=53$$:

$$\Lambda_l \approx  v_o\left (\frac{(p_2-53)^2}{12}-\frac{11(p_2-53)^3}{2862} \right )$$

$$w_r \approx \frac{(p_2-53)^2}{636}-\frac{59(p_2-53)^3}{404496}$$

As $$b_o \to v_r/2$$, the solution is $$p_2=53$$. This is because if the number of buy orders is half of the RHS volume, we expect the stock to end unchanged.

Consider a small imbalance: $$v_r-2b_o=1000$$. Let: $$v_o,v_r=10^6$$

Solving fox p and d gives six possible solution pairs, but the only one that logically makes sense

Convex:

$$d \approx 52.62,  p_2 \approx 52.23$$

Concave:

$$d \approx 52.60,  p_2 \approx 52.22$$

The convex and concave curves enclose roughly the same area, indicating the that resulting LHS path is very close to being linear. Plugging these solutions into their respective convex and concave $$\phi_r$$ shows that the defect is very small, roughly 2.5%.

Example 3 (deriving the Market impact square-root rule)
A formula very similar to the 'square-root' rule is derived.

Consider the instantaneous sale of stock. For simplicity, let the LHS be linear.

An instantaneous sale means $$x_2-x_1=0$$. Therefore, $$ \phi_r=1,w_r=1,a_r=(p_1+p_2)/2$$

Define $$p_3$$ as the lower-end of the stock range and $$p_1$$ as the present price. $$p_1 > p_3$$

The LHS be visualized as a triangle with the vertices $$(0,p_3),(1,p_3),(1,p_1)$$

Since the LHS is linear, $$\phi_l=1,a_l=a_r$$

$$p_2$$ is the final price of the stock after the instantaneous sale $$v_r$$ is rendered.

Because $$\eta_l=1$$ (the LHS is rising), $$p_3 \le p_2 \le p_1$$

$$v_l=v_o\left(\frac{p_1-p_2}{p_1-p_3} \right)$$ Where $$v_o$$ is the total volume of the LHS between x=0,x=1 (some period of time)

This is obtained by taking the inverse of $$x_a=f_l^{-1}(p_2)$$ and finding the proportion of $$v_o$$ volume that is 'liberated' by the stock falling to $$p_2$$. Via the triangle, $$f_l=(p_1-p_3)x_a+p_3$$ Set $$f_l=p_2$$. Then $$x_a=(p_2-p_3)/(p_1-p_3)$$ and $$1-x_a$$ gives the proportion.

$$w_l$$ can be approximated as $$w_l \approx \frac{1}{2}\left(1-\frac{p_2}{p_1} \right)$$

Set $$p_2=p_1-\epsilon$$ where $$\epsilon$$ is the 'impact'

Setting up the equilibrium equation and solving for $$\epsilon$$ we have:

$$\epsilon=\sqrt{\frac{2p_1(p_1-p_3)v_r}{v_o}}$$

The volatility-like variable $$\alpha$$ can be written as: $$\alpha= \sqrt{\frac{p_1-p_3}{p_1}}$$. Hence, we have:

$$\epsilon= p_1\sqrt{2}\alpha\sqrt{\frac{v_r}{v_o}}$$

As we would expect, the volatility term is scale invariant, but the impact $$\epsilon$$ is proportional to the initial price $$p_1$$. If $$p_3$$ is much small than $$p_1$$, we have a greater price range (more volatility).

The $$\sqrt{2}$$ term is somewhat arbitrary, but we still have the volatility and square-root impact relation.