{
"cells": [
{
"cell_type": "markdown",
"id": "7e087d05-8fef-4c19-87ce-f8eba57f4cff",
"metadata": {},
"source": [
"# Regime filters\n",
"\n",
"A regime filter is a classification to indicate the market condition we are in. They could provide some useful pointers to improve trading results. Though we cannot predict the market movements with certainty, we can atleast get an edge.\n",
"\n",
"We should keep these filters simple so that it is easy to understand and do not overfit too much to available data. Boolean filters are a good choice since they only have a true or false value and not prone to too much overfitting, though they may only have a slight edge."
]
},
{
"cell_type": "markdown",
"id": "f87a5d74-bb4b-4143-9b66-4edb5fe340f7",
"metadata": {},
"source": [
"## A simple price filter\n",
"\n",
"Let us a simple price filter.\n",
"\n",
"1. Create a moving average of the price for the last 60 days.\n",
"2. If the close price is greater than the average price, give it a value of 1.\n",
"3. If the close price is less than the average price, give it a value of 0\n",
" \n",
"We shift the average price by 1 day so that we do not include today's close price \n",
"\n",
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "284271ac-a02b-470b-b16f-4b4a4b17c854",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import seaborn as sns\n",
"sns.set()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4ed9a13b-be52-4eba-b841-7d307166b1e3",
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"# parameters\n",
"ma = 60"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ff4d2846-03e6-43de-8417-9badc0027b8a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.displot(data=df, x='ret', hue='is_price', kind='kde')"
]
},
{
"cell_type": "markdown",
"id": "4d1b5f6b-0ed8-48b5-8865-d46310d7fbe1",
"metadata": {},
"source": [
"Looks there seem to be an edge when the filter is negative where the returns are a bit more.\n",
"\n",
"~~In the earlier version, I computed the end of the day returns which is obvious and just a explanation of events already happened. Forward returns should always be considered to find a predictive edge.~~\n",
"\n",
"\n",
"
\n",
" This doesn't seem like a tradeable edge since the margin is very small\n",
"
\n",
"\n",
"Let us see whether the edge persists through all years.\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "b8ab2ef6-e6a4-4fe2-b125-547ae6fab284",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
""
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEmCAYAAAB4VQe4AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAA4Q0lEQVR4nO3de1yUVf4H8M8MN0VUhJ3hp9Rv1bytgRFimCWspnIXASkFxWyzoty8JMl6jdQ1ibykQuWutrFmsqYoBWhZWmZtQP5CTd10M1SUGS6loMBczu8Pl1mRh9sMMMzweb9eveI55/k+55zxYb48t/PIhBACREREd5GbuwNERNQ5MUEQEZEkJggiIpLEBEFERJKYIIiISBITBBERSWKCILO7fPkyhg4ditjY2AZ1f/rTnzB06FCUl5eboWeNW7ZsGU6dOtXh7XbGz4KsFxMEdQoODg64ePEirly5Yii7efMmCgoKzNirxh0/fhx8hIisHRMEdQo2NjYICgpCVlaWoezQoUN47LHH6q332WefITo6GlOmTMG0adNw4sQJAEBpaSmef/55PPHEExg/fjxmzpyJsrIyAMD48eOxefNmxMTEYNy4cUhOTpbsw/jx4zF//nwEBQXhk08+QUlJCV544QVERkYiLCwMb731FgBgw4YNUKlUWLRoEb7//nvMnDkTubm5hu3cuezh4YF58+YhICAAJ0+ehKenJzZv3oxp06Zh/PjxePfddwEAarUaTz31FCIiIhAREYGNGzc2+llt3LgRERERCA8Px+effw4AmD17Nnbv3m1YJy0tDX/+85/rxR04cADTpk0zLBcXF+PRRx9FbW0tLly4gKeeegqRkZEIDw/Hnj17AAB6vR6rV69GdHQ0goODERQUZEjaiYmJeO655xASEoLXX3+90f6SBRNEZnb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s1i+vTp4vvvvzeU5efni9GjRwtvb2/GdpK2u+KYhRDi+PHj4vz58/XKiouLxerVqzttny3x35ljbl2sFKtMEEIY/0vYFWPN2XZXHLMpuuLnxTF3XOzdrPYuJiIiMo1V3sVERESmY4IgIiJJTBBERCSJCYKIiCRZ5XMQRB1h2bJlcHFxwcKFCwEABw4cwMGDBxEVFYW0tDRoNBp069YNixcvxoMPPojS0lKsWLECZWVlUKvVcHd3x8aNG+Hq6orx48djxIgROHfuHBYuXIiJEyeaeXREPIIgMlpsbCz27t0LrVYLANi9ezfGjh2LDRs24J133kFmZiZWrVqFP/7xj7h58yY+/vhjeHl5Yffu3Th8+DC6deuG/fv3G7Y3ePBg5OTkMDlQp8EjCCIj/e53v8M999yDI0eOYMCAAVCpVNDpdFCpVHjyyScN68lkMhQVFWHWrFnIz8/Hjh07cPHiRfz444944IEHDOv5+PiYYRREjWOCIDJBbGwsPvzwQ/Tv3x+PP/449Ho9Hn74YWzcuNGwztWrV6FUKvH666+jsLAQUVFR8PX1hVarrTdBn6OjoxlGQNQ4nmIiMkFAQADOnDmDQ4cOISoqCqNHj8ZXX32FCxcuALg9e+vkyZNRU1ODY8eOYdasWZgyZQpcXV1x/Phx6HQ6M4+AqHE8giAygb29PQICAlBaWgoXFxe4uLjg1VdfxcKFCyGEgK2tLdLS0uDo6IgXXngBycnJSE1NhY2NDby9vVFUVGTuIRA1ilNtEJng5s2bmDFjBlauXFnvegKRNeApJiIjffnll/j9738PX19fJgeySjyCICIiSTyCICIiSUwQREQkiQmCiIgkMUEQEZEkJggiIpLEBEFERJL+H6hiAR7YJdAFAAAAAElFTkSuQmCC\n",
"text/plain": [
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df['year'] = df.index.year\n",
"df.groupby(['year', 'is_price']).ret.mean().unstack().plot.bar(stacked=True, \n",
" title=\"Mean returns by year\")"
]
},
{
"cell_type": "markdown",
"id": "bed195a0-a222-420e-bb04-b948932d4666",
"metadata": {},
"source": [
"The edge fairly persists over the years.\n",
"\n",
"Let us try changing it to median and see if it improves the results\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "15ba70cc-0f1b-4eaa-a25a-bd0318a955d4",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
"
\n",
"
\n",
"
count
\n",
"
mean
\n",
"
std
\n",
"
min
\n",
"
25%
\n",
"
50%
\n",
"
75%
\n",
"
max
\n",
"
\n",
"
\n",
"
is_price
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
" \n",
" \n",
"
\n",
"
0.0
\n",
"
1950.0
\n",
"
0.000485
\n",
"
0.017500
\n",
"
-0.119841
\n",
"
-0.008144
\n",
"
0.000953
\n",
"
0.009326
\n",
"
0.115800
\n",
"
\n",
"
\n",
"
1.0
\n",
"
3565.0
\n",
"
0.000168
\n",
"
0.008332
\n",
"
-0.058944
\n",
"
-0.003545
\n",
"
0.000546
\n",
"
0.004628
\n",
"
0.038053
\n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" count mean std min 25% 50% 75% \\\n",
"is_price \n",
"0.0 1950.0 0.000485 0.017500 -0.119841 -0.008144 0.000953 0.009326 \n",
"1.0 3565.0 0.000168 0.008332 -0.058944 -0.003545 0.000546 0.004628 \n",
"\n",
" max \n",
"is_price \n",
"0.0 0.115800 \n",
"1.0 0.038053 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['ma_price'] = df.close.rolling(ma).median().shift(1)\n",
"df['is_price'] = df.eval('close > ma_price')+0\n",
"df['is_price'] = df.is_price.shift(1) # Shifting price since we use the signal only next day\n",
"df.groupby(['is_price']).ret.describe()"
]
},
{
"cell_type": "markdown",
"id": "a7c8fea6-9720-401c-80a7-54162b68a6a8",
"metadata": {},
"source": [
"Not so big. This is just a simple way to create a filter to define a market environment and see how it impacts the returns. The following could be done to improve a filter\n",
"\n",
" * Use quantiles instead of mean or median\n",
" * Calculate the filter for different moving averages\n",
" * Try simulating for periods instead of rolling over averages"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
},
"nikola": {
"category": "regime-change",
"date": "2021-11-25 08:50:05 UTC",
"slug": "simple-regime-filter",
"tags": "filters,regimes",
"title": "A simple regime filter"
}
},
"nbformat": 4,
"nbformat_minor": 5
}