Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified submissions/tingjun2/Figure_1_100k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/Figure_1_5M.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/Figure_2_100k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/Figure_2_5M.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/Figure_3_100k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/Figure_3_5M.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/Figure_4_100k.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/Figure_4_5M.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 16 additions & 16 deletions submissions/tingjun2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
The **GARCH(1,1) Volatility Model** (Generalized Autoregressive Conditional Heteroskedasticity) describes the evolution of a security price $S$ where the variance $V$ is a stochastic process exhibiting **Mean Reversion** and **Volatility Clustering**.

This implementation maps the discrete-time GARCH process to the theoretical **Q-Variance** relationship. By simulating millions of trading days, we demonstrate that the stochastic variance updates converge to a deterministic parabolic fit:
$$V(z) = \sigma_0^2 + \frac{(z - z_{off})^2}{2}$$


$$V(z) = \sigma_0^2 + \frac{(z - z_{off})^2}{2}$$

## Parameters & Mapping Logic
The model utilizes four parameters to control the GARCH dynamics and recover the theoretical geometry of the Q-variance parabola:
The model utilizes six parameters to control GARCH dynamics and ensure numerical stability during high-intensity simulations. **Only the primary parameters (Target Vol, Annual Return, and Persistence) are optimized to maximize $R^2$; the Shock Weight ($\alpha$) is automatically derived from persistence, while the safety buffers remain fixed at their default values.**

| Parameter | Value | Influence on Q-Variance Geometry |
| Parameter | Value | Influence on Q-Variance Geometry / Stability |
| :--- | :--- | :--- |
| **Target Vol ($\sigma$)** | **0.425** | **Minimal Volatility ($\sigma_0$):** Sets the vertical baseline (the "floor" of the parabola). |
| **Annual Return ($\mu$)** | **0.06** | **Z-Shift ($z_{off}$):** Controls the horizontal asymmetry (displacement from zero). |
| **Persistence ($\beta$)** | **0.8** | **Curvature/Steepness:** Determines the rate of decay; higher $\beta$ maintains "memory" of past volatility. |
| **Shock Weight ($\alpha$)** | **0.19** | **Sensitivity:** Controls the reaction to market shocks. Fixed such that $\alpha + \beta = 0.99$. |
| **Vol Cap ($V_{max}$)** | **4.0** | **Numerical Stability:** Prevents "volatility explosions" (NaN/Inf) by capping annual vol at 400%. |
| **Price Floor ($S_{min}$)** | **0.01** | **Continuity:** Prevents the simulation from failing if price approaches zero. |

> **Note:** The "Mean Reversion" strength is implicitly defined as $\gamma = 1 - (\alpha + \beta) = 0.01$.

Expand All @@ -26,17 +27,15 @@ The simulation generates a synthetic price history using independent paths of **
### Discrete-Time Updates

- **Variance Update (GARCH Logic):**
The variance at step $i$ is driven by the weighted average of the long-run variance (Variance Targeting), the previous variance, and the most recent market percentage-return shock ($\epsilon_{i-1}$):
The variance at step $i$ is driven by the weighted average of the long-run variance (Variance Targeting), the previous variance, and the most recent market **log-return shock** ($\epsilon_{i-1}$):

$$V_i = \omega + \alpha \cdot \epsilon_{i-1}^2 + \beta \cdot V_{i-1}$$

Where:
- $\epsilon_{i-1} = \frac{S_{i-1} - S_{i-2}}{S_{i-2}}$
- $\omega = \frac{\sigma^{2}}{252} \cdot 0.01$ (Targeting a long-run annual volatility $\sigma$)
where:
- $\epsilon_{i-1} = \ln(S_{i-1} / S_{i-2})$ (Logarithmic return)
- $\omega = \frac{\sigma^{2}}{252} \cdot 0.01$ (Targeting long-run annual volatility $\sigma$)
- $\alpha = 0.99 - \beta$



- **Price Update:**
The price follows a Geometric Brownian Motion (GBM) step, adjusted for the current stochastic variance $V_i$:

Expand All @@ -53,14 +52,12 @@ The model was optimized using the 5M-day horizon to achieve a high-fidelity fit
### Optimized Model Performance
| Total Days | $\sigma_0$ (Target) | $z_{off}$ (Target) | $R^2$ | Notes |
| :--- | :--- | :--- | :--- | :--- |
| **5,000,000** | 0.2586 | 0.0214 | **0.997** | High-fidelity structural convergence. |
| **100,000** | 0.2586 | 0.0214 | **0.966** | Lower $R^2$ due to idiosyncratic noise. |
| **5,000,000** | 0.2586 | 0.0214 | **0.99** | High-fidelity structural convergence. |
| **100,000** | 0.2586 | 0.0214 | **0.972** | Lower $R^2$ due to idiosyncratic noise. |

### Comparative Visualizations
The transition from 100k days to 5M days shows the "clearing" of statistical noise. In the large sample, the stochastic variance updates converge almost perfectly to the theoretical parabola.



#### **100,000 Day Sample (Noise-Dominant)**
<div style="display: flex; justify-content: space-around;">
<img src="Figure_1_100k.png" width="32%">
Expand All @@ -81,21 +78,24 @@ The transition from 100k days to 5M days shows the "clearing" of statistical noi
By plotting $R^2$ as a function of total simulated days, we identified a clear threshold for statistical validity:

- **Convergence Point:** The model consistently reaches $R^2 > 0.995$ after approximately **1,130,000 days**.
- **The Law of Large Numbers:** Beyond 2 million days, the fit quality stabilizes at an asymptote, confirming that the optimized GARCH parameters accurately represent the underlying Q-variance structure.
- **The Law of Large Numbers:** Beyond 2 million days, the fit quality stabilizes at an asymptote. The inclusion of the **Volatility Cap (4.0)** and **Price Floor (0.01)** ensures that even with extreme log-return shocks, the aggregate fit remains numerically stable.

![Convergence Analysis](convergence_analysis.png)
Figure: $R^2$ score vs. Total Days. The 0.995 threshold is maintained after the 1M-day mark.

---

## Acknowledgments & Version History

> [!NOTE]
> **Version 2.0 Update**
> An earlier version of this model utilized an incorrect definition of the intercept term ($\omega$), which led to a scaling mismatch in the long-run variance. Special thanks to **@Orrell** for pointing out this discrepancy.

In this current version, I have:
* **Transitioned to Log Returns:** Replaced fractional returns with log returns for mathematical symmetry and consistency with GBM price updates.
* **Fixed the $\omega$ definition:** Implemented proper **Variance Targeting** logic, where $\omega = V_{target} \cdot \gamma$.
* **Standardized Nomenclature:** Renamed parameters to follow standard GARCH(1,1) conventions ($\alpha$ for the shock component and $\beta$ for the persistence component).
* **Re-optimized Parameters:** Recalibrated the parameter set specifically for the 5M-day horizon to ensure maximum fit.
* **Added Safety Buffers:** Implemented a Volatility Cap (4.0) and Price Floor (0.01) to ensure the 5M-day simulation remains robust against mathematical overflow.

Despite these structural corrections, the results remain consistent with previous findings, further confirming the original hypothesis of **Q-variance emergence** in GARCH-governed systems.

Expand Down
Binary file modified submissions/tingjun2/convergence_analysis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified submissions/tingjun2/dataset_part1.parquet
Binary file not shown.
Binary file modified submissions/tingjun2/dataset_part2.parquet
Binary file not shown.
Binary file modified submissions/tingjun2/dataset_part3.parquet
Binary file not shown.
149 changes: 81 additions & 68 deletions submissions/tingjun2/price_generator2.ipynb

Large diffs are not rendered by default.

Loading
Loading