Skip to content

Commit

Permalink
new graphs and readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thekioskman committed Apr 13, 2022
1 parent b03dfa4 commit 3672990
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -439,7 +439,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.8"
"version": "3.9.12"
},
"orig_nbformat": 4
},
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ As a rule of thumb, anything < 5% means we can be pretty certain. Another thing
<br>
If trace stat at 1% < trace stat at 5% < trace stat at 10% -> the smaller the value, the more likely that the null hypothesis is wrong
<br>
_BUT_
*BUT*
<br>
if If trace stat at 1% > trace stat at 5% > trace stat at 10% -> the bigger the value, the more likely that the null hypothesis is wrong

Expand Down Expand Up @@ -213,11 +213,24 @@ In practice, we always prefer the Johansen Test over the CADF test. The Johansen


## Linear Regression
Another method we can use to get the hedge ratio between *two* stocks
Another method we can use to get the hedge ratio between *two* stocks is to use a linear regression. The concept here is pretty simple, consider the following time series for the EWC and EWA ETF's. A quick CADF test tells us that they do conintegrate. We can verify this by ploting their time series values on a scatter plot, with EWC(t) on the x-axis, and EWA(t) on the y-axis.

![Linear Regression Demo](./images/Linear%20Regression%20DEMO.png)

In theory, the actual price point values of our time series should be close to, and hover around the value of the least squares regression we ran. (Since our time series value conintegrate). This means that we expect the price to mean revert around this regression line. Thefore, to generate a stationary series we use the following equation.

<img src="https://render.githubusercontent.com/render/math?math=EWA(t) = slope*EWC(t)">

And therefore
<img src="https://render.githubusercontent.com/render/math?math=stationary(t) = EWA(t) - slope*EWC(t)">

Now the idea here is that since our price values for EWA and EWC oscilate around the regression line EWA = slope*EWC, the value of the series EWA - slope*EWC should oscilate around 0. Essentially generating a mean revering time series.

## Linear Regression with Moving Window




## Johansen Test (Advanced)

## Kalman Filter (Advanced)
Expand Down
Binary file added images/Linear Regession Hedge Ratio Example.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 added images/Linear Regression DEMO.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
265 changes: 263 additions & 2 deletions images/image_generation.ipynb

Large diffs are not rendered by default.

Binary file modified images/staionary example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3672990

Please sign in to comment.