mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-11-02 07:26:12 +00:00
docs: fix unrendered LaTeX math blocks in indicator docs
Blank lines were missing around $$ fences (bold labels or list items glued directly to $$, and stacked $$ blocks with no separator), causing GitHub to merge them into the surrounding paragraph and misread underscores as italic markers instead of rendering math.
This commit is contained in:
@@ -40,16 +40,21 @@ $$
|
|||||||
2. **Pre-warped Frequency**: $W_c = \tan(\frac{\omega_c}{2})$
|
2. **Pre-warped Frequency**: $W_c = \tan(\frac{\omega_c}{2})$
|
||||||
3. **Ripple Factor**: $\epsilon = \sqrt{10^{R/10} - 1}$
|
3. **Ripple Factor**: $\epsilon = \sqrt{10^{R/10} - 1}$
|
||||||
4. **Transformation**:
|
4. **Transformation**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\mu = \frac{1}{2} \sinh^{-1}(\frac{1}{\epsilon}) \\
|
\mu = \frac{1}{2} \sinh^{-1}(\frac{1}{\epsilon}) \\
|
||||||
\sigma = -\sinh(\mu) W_c \\
|
\sigma = -\sinh(\mu) W_c \\
|
||||||
\omega_d = \cosh(\mu) W_c
|
\omega_d = \cosh(\mu) W_c
|
||||||
$$
|
$$
|
||||||
|
|
||||||
5. **Intermediate Variables**:
|
5. **Intermediate Variables**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
K = \sigma^2 + \omega_d^2
|
K = \sigma^2 + \omega_d^2
|
||||||
$$
|
$$
|
||||||
|
|
||||||
6. **S-Plane to Z-Plane Map (Bilinear Transform)**:
|
6. **S-Plane to Z-Plane Map (Bilinear Transform)**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
b_0' = K \\
|
b_0' = K \\
|
||||||
b_1' = 2K \\
|
b_1' = 2K \\
|
||||||
@@ -58,7 +63,9 @@ $$
|
|||||||
a_1' = 2K - 2 \\
|
a_1' = 2K - 2 \\
|
||||||
a_2' = 1 + 2\sigma + K
|
a_2' = 1 + 2\sigma + K
|
||||||
$$
|
$$
|
||||||
|
|
||||||
7. **Coefficients**:
|
7. **Coefficients**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
b_0 = \frac{b_0'}{a_0'}, \quad b_1 = \frac{b_1'}{a_0'}, \quad b_2 = \frac{b_2'}{a_0'} \\
|
b_0 = \frac{b_0'}{a_0'}, \quad b_1 = \frac{b_1'}{a_0'}, \quad b_2 = \frac{b_2'}{a_0'} \\
|
||||||
a_1 = \frac{a_1'}{a_0'}, \quad a_2 = \frac{a_2'}{a_0'}
|
a_1 = \frac{a_1'}{a_0'}, \quad a_2 = \frac{a_2'}{a_0'}
|
||||||
|
|||||||
@@ -63,11 +63,13 @@ This is an IIR filter - each output depends on all previous outputs, creating in
|
|||||||
The truncated version limits memory to exactly $L$ bars by recomputing the IIR recursion from scratch each bar:
|
The truncated version limits memory to exactly $L$ bars by recomputing the IIR recursion from scratch each bar:
|
||||||
|
|
||||||
**Step 1:** Initialize the tail:
|
**Step 1:** Initialize the tail:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
T_{L+2} = 0, \qquad T_{L+1} = 0
|
T_{L+2} = 0, \qquad T_{L+1} = 0
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Step 2:** Run the recursion forward from oldest to newest:
|
**Step 2:** Run the recursion forward from oldest to newest:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
T_k = a_0(P_{k-1} - P_{k+1}) + a_1 \cdot T_{k+1} + a_2 \cdot T_{k+2}, \qquad k = L, L{-}1, \ldots, 1
|
T_k = a_0(P_{k-1} - P_{k+1}) + a_1 \cdot T_{k+1} + a_2 \cdot T_{k+2}, \qquad k = L, L{-}1, \ldots, 1
|
||||||
$$
|
$$
|
||||||
@@ -75,6 +77,7 @@ $$
|
|||||||
where $P_k$ denotes the close price $k$ bars ago.
|
where $P_k$ denotes the close price $k$ bars ago.
|
||||||
|
|
||||||
**Step 3:** Output:
|
**Step 3:** Output:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\text{TBF}_t = T_1
|
\text{TBF}_t = T_1
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -76,21 +76,25 @@ where $x$ is the input series and $w_k$ are the window weights.
|
|||||||
### Window Coefficient Formulas
|
### Window Coefficient Formulas
|
||||||
|
|
||||||
**Hanning:**
|
**Hanning:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
w_k = 0.5 - 0.5 \cos\left(\frac{2\pi k}{P}\right)
|
w_k = 0.5 - 0.5 \cos\left(\frac{2\pi k}{P}\right)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Hamming:**
|
**Hamming:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
w_k = 0.54 - 0.46 \cos\left(\frac{2\pi k}{P}\right)
|
w_k = 0.54 - 0.46 \cos\left(\frac{2\pi k}{P}\right)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Blackman:**
|
**Blackman:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
w_k = 0.42 - 0.5 \cos\left(\frac{2\pi k}{P}\right) + 0.08 \cos\left(\frac{4\pi k}{P}\right)
|
w_k = 0.42 - 0.5 \cos\left(\frac{2\pi k}{P}\right) + 0.08 \cos\left(\frac{4\pi k}{P}\right)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Blackman-Harris:**
|
**Blackman-Harris:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
w_k = 0.35875 - 0.48829 \cos\left(\frac{2\pi k}{P}\right) + 0.14128 \cos\left(\frac{4\pi k}{P}\right) - 0.01168 \cos\left(\frac{6\pi k}{P}\right)
|
w_k = 0.35875 - 0.48829 \cos\left(\frac{2\pi k}{P}\right) + 0.14128 \cos\left(\frac{4\pi k}{P}\right) - 0.01168 \cos\left(\frac{6\pi k}{P}\right)
|
||||||
$$
|
$$
|
||||||
@@ -118,6 +122,7 @@ $$
|
|||||||
Fitted value at lag $i$: $\hat{x}_i = \text{intercept} + \text{slope} \cdot i$
|
Fitted value at lag $i$: $\hat{x}_i = \text{intercept} + \text{slope} \cdot i$
|
||||||
|
|
||||||
Final LS output:
|
Final LS output:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\text{AFIRMA}_{LS} = \frac{1}{P} \left( \sum_{i=0}^{n-1} \hat{x}_i + \sum_{i=n}^{P-1} x_{t-i} \right)
|
\text{AFIRMA}_{LS} = \frac{1}{P} \left( \sum_{i=0}^{n-1} \hat{x}_i + \sum_{i=n}^{P-1} x_{t-i} \right)
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -35,16 +35,19 @@ Key identities:
|
|||||||
### Logarithm Rules
|
### Logarithm Rules
|
||||||
|
|
||||||
**Product Rule:**
|
**Product Rule:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\ln(a \cdot b) = \ln(a) + \ln(b)
|
\ln(a \cdot b) = \ln(a) + \ln(b)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Quotient Rule:**
|
**Quotient Rule:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\ln\left(\frac{a}{b}\right) = \ln(a) - \ln(b)
|
\ln\left(\frac{a}{b}\right) = \ln(a) - \ln(b)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Power Rule:**
|
**Power Rule:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\ln(a^n) = n \cdot \ln(a)
|
\ln(a^n) = n \cdot \ln(a)
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -78,16 +78,19 @@ $$
|
|||||||
Where $MA$ is one of:
|
Where $MA$ is one of:
|
||||||
|
|
||||||
**SMA:**
|
**SMA:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
ADR_t = \frac{1}{N} \sum_{i=0}^{N-1} DR_{t-i}
|
ADR_t = \frac{1}{N} \sum_{i=0}^{N-1} DR_{t-i}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**EMA:**
|
**EMA:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
ADR_t = \alpha \cdot DR_t + (1 - \alpha) \cdot ADR_{t-1}, \quad \alpha = \frac{2}{N+1}
|
ADR_t = \alpha \cdot DR_t + (1 - \alpha) \cdot ADR_{t-1}, \quad \alpha = \frac{2}{N+1}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**WMA:**
|
**WMA:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
ADR_t = \frac{\sum_{i=0}^{N-1} (N-i) \cdot DR_{t-i}}{\sum_{i=0}^{N-1} (N-i)}
|
ADR_t = \frac{\sum_{i=0}^{N-1} (N-i) \cdot DR_{t-i}}{\sum_{i=0}^{N-1} (N-i)}
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ $$
|
|||||||
$$
|
$$
|
||||||
|
|
||||||
Using Welford's running algorithm:
|
Using Welford's running algorithm:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\sigma = \sqrt{\frac{\sum x^2}{n} - \left(\frac{\sum x}{n}\right)^2}
|
\sigma = \sqrt{\frac{\sum x^2}{n} - \left(\frac{\sum x}{n}\right)^2}
|
||||||
$$
|
$$
|
||||||
@@ -70,6 +71,7 @@ $$
|
|||||||
### Percentile Rank Formula
|
### Percentile Rank Formula
|
||||||
|
|
||||||
For a value $v$ in a dataset of $N$ values:
|
For a value $v$ in a dataset of $N$ values:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\text{Percentile} = \frac{\text{count of values} < v}{N}
|
\text{Percentile} = \frac{\text{count of values} < v}{N}
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ This smoothed deviation represents the "raw" volatility reading that feeds into
|
|||||||
The core innovation: instead of exponential smoothing, JVOLTY maintains a 128-sample circular buffer of raw volatility readings. On each bar, the buffer is sorted and a trimmed mean is computed:
|
The core innovation: instead of exponential smoothing, JVOLTY maintains a 128-sample circular buffer of raw volatility readings. On each bar, the buffer is sorted and a trimmed mean is computed:
|
||||||
|
|
||||||
**Full buffer (128 samples):**
|
**Full buffer (128 samples):**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\hat{V}_t = \frac{1}{65} \sum_{i=32}^{96} \text{sorted}[i]
|
\hat{V}_t = \frac{1}{65} \sum_{i=32}^{96} \text{sorted}[i]
|
||||||
$$
|
$$
|
||||||
@@ -86,12 +87,15 @@ $$
|
|||||||
The middle 65 values (indices 32-96) represent approximately the 25th-75th percentile. Extreme values on both tails are discarded.
|
The middle 65 values (indices 32-96) represent approximately the 25th-75th percentile. Extreme values on both tails are discarded.
|
||||||
|
|
||||||
**Partial buffer (16-127 samples):**
|
**Partial buffer (16-127 samples):**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
s = \max(5, \text{round}(0.5 \times \text{count}))
|
s = \max(5, \text{round}(0.5 \times \text{count}))
|
||||||
$$
|
$$
|
||||||
|
|
||||||
$$
|
$$
|
||||||
k = \lfloor(\text{count} - s) / 2\rfloor
|
k = \lfloor(\text{count} - s) / 2\rfloor
|
||||||
$$
|
$$
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\hat{V}_t = \frac{1}{s} \sum_{i=k}^{k+s-1} \text{sorted}[i]
|
\hat{V}_t = \frac{1}{s} \sum_{i=k}^{k+s-1} \text{sorted}[i]
|
||||||
$$
|
$$
|
||||||
@@ -133,6 +137,7 @@ $$
|
|||||||
$$
|
$$
|
||||||
|
|
||||||
where:
|
where:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\text{sqrtDivider} = \frac{\sqrt{L} \times \text{logParam}}{\sqrt{L} \times \text{logParam} + 1}
|
\text{sqrtDivider} = \frac{\sqrt{L} \times \text{logParam}}{\sqrt{L} \times \text{logParam} + 1}
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ Given period $N$:
|
|||||||
1. **Parameters**: $\alpha = \frac{1}{N}$, $\text{decay} = 1 - \alpha$
|
1. **Parameters**: $\alpha = \frac{1}{N}$, $\text{decay} = 1 - \alpha$
|
||||||
|
|
||||||
2. **True Range**:
|
2. **True Range**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
TR_t = \begin{cases}
|
TR_t = \begin{cases}
|
||||||
H_t - L_t & \text{if } t = 0 \\
|
H_t - L_t & \text{if } t = 0 \\
|
||||||
@@ -89,16 +90,19 @@ H_t - L_t & \text{if } t = 0 \\
|
|||||||
$$
|
$$
|
||||||
|
|
||||||
3. **RMA with FMA optimization**:
|
3. **RMA with FMA optimization**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
ATR_{raw,t} = \text{FMA}(ATR_{raw,t-1}, \text{decay}, \alpha \cdot TR_t)
|
ATR_{raw,t} = \text{FMA}(ATR_{raw,t-1}, \text{decay}, \alpha \cdot TR_t)
|
||||||
$$
|
$$
|
||||||
|
|
||||||
4. **Warmup compensation**:
|
4. **Warmup compensation**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
ATR_t = \frac{ATR_{raw,t}}{1 - e_t}
|
ATR_t = \frac{ATR_{raw,t}}{1 - e_t}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
5. **Normalization**:
|
5. **Normalization**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
NATR_t = \frac{ATR_t}{C_t} \times 100
|
NATR_t = \frac{ATR_t}{C_t} \times 100
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -57,11 +57,13 @@ $$
|
|||||||
where $\alpha = 1/\text{period}$.
|
where $\alpha = 1/\text{period}$.
|
||||||
|
|
||||||
**Bias compensator:**
|
**Bias compensator:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
e_t = (1 - \alpha)^t
|
e_t = (1 - \alpha)^t
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Corrected ATR:**
|
**Corrected ATR:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
ATR_t = \frac{\text{RMA}_{raw,t}}{1 - e_t}
|
ATR_t = \frac{\text{RMA}_{raw,t}}{1 - e_t}
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -67,16 +67,19 @@ where $n$ is the smoothing period. For typical values:
|
|||||||
### 3. Daily Variance Components
|
### 3. Daily Variance Components
|
||||||
|
|
||||||
**Overnight variance:**
|
**Overnight variance:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\sigma_o^2 = r_o^2
|
\sigma_o^2 = r_o^2
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Open-to-close variance:**
|
**Open-to-close variance:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\sigma_c^2 = r_c^2
|
\sigma_c^2 = r_c^2
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Rogers-Satchell variance (drift-independent intraday measure):**
|
**Rogers-Satchell variance (drift-independent intraday measure):**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\sigma_{RS}^2 = r_h \cdot (r_h - r_c) + r_l \cdot (r_l - r_c)
|
\sigma_{RS}^2 = r_h \cdot (r_h - r_c) + r_l \cdot (r_l - r_c)
|
||||||
$$
|
$$
|
||||||
@@ -108,11 +111,13 @@ $$
|
|||||||
where $\alpha = 1/n$.
|
where $\alpha = 1/n$.
|
||||||
|
|
||||||
**Bias compensator:**
|
**Bias compensator:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
e_t = (1 - \alpha)^t
|
e_t = (1 - \alpha)^t
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Corrected output:**
|
**Corrected output:**
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\text{RMA}_{corrected} = \frac{\text{RMA}_{raw}}{1 - e_t}
|
\text{RMA}_{corrected} = \frac{\text{RMA}_{raw}}{1 - e_t}
|
||||||
$$
|
$$
|
||||||
@@ -127,6 +132,7 @@ The Rogers-Satchell component has elegant properties:
|
|||||||
- **Non-negativity**: Always ≥ 0 when calculated correctly
|
- **Non-negativity**: Always ≥ 0 when calculated correctly
|
||||||
|
|
||||||
The formula $r_h(r_h - r_c) + r_l(r_l - r_c)$ can be rewritten as:
|
The formula $r_h(r_h - r_c) + r_l(r_l - r_c)$ can be rewritten as:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\sigma_{RS}^2 = r_h \cdot r_l - r_l \cdot r_c - r_h \cdot r_c + r_h^2 + r_l^2 - r_l^2
|
\sigma_{RS}^2 = r_h \cdot r_l - r_l \cdot r_c - r_h \cdot r_c + r_h^2 + r_l^2 - r_l^2
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -83,11 +83,13 @@ where:
|
|||||||
### Smoothed Force Index
|
### Smoothed Force Index
|
||||||
|
|
||||||
Standard EMA form:
|
Standard EMA form:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
EFI_t = \alpha \times F_t + (1 - \alpha) \times EFI_{t-1}
|
EFI_t = \alpha \times F_t + (1 - \alpha) \times EFI_{t-1}
|
||||||
$$
|
$$
|
||||||
|
|
||||||
Using FMA optimization:
|
Using FMA optimization:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
EFI_t = \text{FMA}(\alpha, F_t - EFI_{t-1}, EFI_{t-1})
|
EFI_t = \text{FMA}(\alpha, F_t - EFI_{t-1}, EFI_{t-1})
|
||||||
$$
|
$$
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ $$
|
|||||||
### 2. Rate of Change Calculation
|
### 2. Rate of Change Calculation
|
||||||
|
|
||||||
**Percentage Mode** (default):
|
**Percentage Mode** (default):
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\text{VROC}_t = \frac{V_t - V_{t-n}}{V_{t-n}} \times 100
|
\text{VROC}_t = \frac{V_t - V_{t-n}}{V_{t-n}} \times 100
|
||||||
$$
|
$$
|
||||||
|
|
||||||
**Point Mode**:
|
**Point Mode**:
|
||||||
|
|
||||||
$$
|
$$
|
||||||
\text{VROC}_t = V_t - V_{t-n}
|
\text{VROC}_t = V_t - V_{t-n}
|
||||||
$$
|
$$
|
||||||
|
|||||||
Reference in New Issue
Block a user