🔥 GARCH(1,1) — Volatility Forecasting
The model, invented by Robert Engle (2003 Nobel laureate in Economics), is defined as: σ²ₜ = ω + α·r²ₜ₋₁ + β·σ²ₜ₋₁
Vnstock fits the GARCH(1,1) model using Maximum Likelihood Estimation (MLE) on the last 60+ sessions, returning:
- Current annualized volatility (e.g., HPG ~28%/year)
- 5-day and 20-day forecasts
- Persistence (α+β) — the duration of shock effects
- Regime: Low / Normal / High / Crisis
📊 VaR / CVaR 95% — Maximum Expected Loss
VaR (Value at Risk) 95%: with a 95% probability, what is the maximum loss in one day? For example, VNM VaR 95% = -1.83% means \"95% of the time, the loss will be ≤ 1.83% in one day\".
CVaR (Conditional VaR): in the worst 5% of cases, what is the average loss? CVaR is always greater than VaR, measuring \"tail risk\" more accurately.
🎲 Monte Carlo 1000 paths
Simulating 1,000 price paths over 20 sessions using drift, Brownian motion, and historical volatility data (with outliers clipped due to splits). Outputs:
- P10 — the worst 10% scenario
- P50 (median) — the average scenario
- P90 — the best 10% scenario
- Probability of profit % — the percentage of paths ending above the current price
5 sample paths are drawn as SVGs in the UI for visualization.
📐 Kelly Criterion — Position Sizing
Formula: f* = (p·b − q) / b, where p = win rate and b = average win/average loss.
Vnstock caps at 25% (quarter Kelly) for safety. Recommendation: Quarter / Half / Full Kelly depending on risk tolerance.
No more reckless \"all-in\" bets — proper sizing is key to long-term survival.
🔬 Microstructure: OFI · Microprice · Kyle · Amihud · VPIN
Inspired by High-Frequency Trading and Lopez de Prado:
- OFI: Order Flow Imbalance (active buys vs sells)
- Microprice = (ask·bid_vol + bid·ask_vol) / (bid_vol + ask_vol) — the \"true\" price weighted by order book
- Kyle's λ: |Δprice| / volume — measuring price impact
- Amihud Illiquidity: |return| / value_traded
- VPIN: Volume-synchronized PIN (Lopez de Prado 2012) — detecting toxic flow before flash crashes