Skip to content

Commit 4783b00

Browse files
committed
cointegration
1 parent d1278ac commit 4783b00

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

app/cointegration.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def _(mo):
2525
from quantflow.data.fmp import FMP
2626

2727
frequency = mo.ui.dropdown(
28-
options={x.value: x.value for x in FMP.freq},
29-
value="1min",
28+
options={x.name.replace("_", " "): x.value for x in FMP.freq},
29+
value="daily",
3030
label="Frequency",
3131
)
3232
frequency
@@ -128,17 +128,15 @@ def _(mo):
128128
mo.md(r"""
129129
### Why Pick the Largest Eigenvalue?
130130
131-
In the Johansen cointegration test, the eigenvalues ($\lambda$) are sorted in descending order, and each one corresponds to a different potential cointegrating vector.
131+
In the Johansen cointegration test, the eigenvalues ($\lambda$) are sorted in descending order, and each one corresponds to a different potential cointegrating vector.
132132
133-
**The magnitude of the eigenvalue represents the strength and stability of the corresponding cointegrating relationship.**
133+
**The magnitude of the eigenvalue represents the strength and stability of the corresponding cointegrating relationship.**
134134
135-
1. **Strongest Relationship:** The largest eigenvalue corresponds to the linear combination of the time series that is "most stationary." This means the resulting spread (the residuals) has the strongest tendency to revert to its mean over time.
135+
1. **Strongest Relationship:** The largest eigenvalue corresponds to the linear combination of the time series that is "most stationary." This means the resulting spread (the residuals) has the strongest tendency to revert to its mean over time.
136+
2. **Statistical Significance:** The test statistics used in the Johansen test (the Trace test and the Maximum Eigenvalue test) are functions of these eigenvalues. These tests help us determine how many statistically significant cointegrating relationships exist, starting from the one associated with the largest eigenvalue.
137+
3. **Practical Application:** For applications like pairs trading, we want to find the most reliable and predictable long-run equilibrium relationship. By choosing the cointegrating vector associated with the largest eigenvalue, we are selecting the portfolio of assets whose value is most likely to be mean-reverting, making it the best candidate for a statistical arbitrage strategy.
136138
137-
2. **Statistical Significance:** The test statistics used in the Johansen test (the Trace test and the Maximum Eigenvalue test) are functions of these eigenvalues. These tests help us determine how many statistically significant cointegrating relationships exist, starting from the one associated with the largest eigenvalue.
138-
139-
3. **Practical Application:** For applications like pairs trading, we want to find the most reliable and predictable long-run equilibrium relationship. By choosing the cointegrating vector associated with the largest eigenvalue, we are selecting the portfolio of assets whose value is most likely to be mean-reverting, making it the best candidate for a statistical arbitrage strategy.
140-
141-
In short, picking the largest eigenvalue is equivalent to picking the **most significant and stable cointegrating vector** found by the test.
139+
In short, picking the largest eigenvalue is equivalent to picking the **most significant and stable cointegrating vector** found by the test.
142140
""")
143141
return
144142

@@ -157,5 +155,10 @@ def _(mo):
157155
return
158156

159157

158+
@app.cell
159+
def _():
160+
return
161+
162+
160163
if __name__ == "__main__":
161164
app.run()

0 commit comments

Comments
 (0)