{ "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
openhighlowclosevolumeadj closeret
date
2021-11-244675.7797854702.8701174659.8901374701.45996124640400004701.4599610.002294
2021-11-264664.6298834664.6298834585.4301764594.62011726767400004594.620117-0.022725
2021-11-294628.7500004672.9501954625.2597664655.27002034713800004655.2700200.013200
2021-11-304640.2500004646.0200204560.0000004567.00000049501900004567.000000-0.018961
2021-12-014602.8198244652.9399414510.2700204513.04003940782600004513.040039-0.011815
\n", "
" ], "text/plain": [ " open high low close volume \\\n", "date \n", "2021-11-24 4675.779785 4702.870117 4659.890137 4701.459961 2464040000 \n", "2021-11-26 4664.629883 4664.629883 4585.430176 4594.620117 2676740000 \n", "2021-11-29 4628.750000 4672.950195 4625.259766 4655.270020 3471380000 \n", "2021-11-30 4640.250000 4646.020020 4560.000000 4567.000000 4950190000 \n", "2021-12-01 4602.819824 4652.939941 4510.270020 4513.040039 4078260000 \n", "\n", " adj close ret \n", "date \n", "2021-11-24 4701.459961 0.002294 \n", "2021-11-26 4594.620117 -0.022725 \n", "2021-11-29 4655.270020 0.013200 \n", "2021-11-30 4567.000000 -0.018961 \n", "2021-12-01 4513.040039 -0.011815 " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv('/home/pi/data/sp500.csv', parse_dates=['Date']).rename(\n", "columns = lambda x:x.lower()).sort_values(by='date').set_index('date')\n", "df['ret'] = df.close.pct_change()\n", "df.tail()" ] }, { "cell_type": "code", "execution_count": 4, "id": "42aa76b8-165d-4910-88e3-a417ff0bbe31", "metadata": {}, "outputs": [], "source": [ "df['ma_price'] = df.close.rolling(ma).mean().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" ] }, { "cell_type": "code", "execution_count": 5, "id": "b59e3a27-eba4-4b1a-ba8a-3066f7bf64da", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countmeanstdmin25%50%75%max
is_price
0.01889.00.0004230.017703-0.119841-0.0082440.0009560.0092030.115800
1.03626.00.0002060.008350-0.058944-0.0035600.0005470.0046860.038053
\n", "
" ], "text/plain": [ " count mean std min 25% 50% 75% \\\n", "is_price \n", "0.0 1889.0 0.000423 0.017703 -0.119841 -0.008244 0.000956 0.009203 \n", "1.0 3626.0 0.000206 0.008350 -0.058944 -0.003560 0.000547 0.004686 \n", "\n", " max \n", "is_price \n", "0.0 0.115800 \n", "1.0 0.038053 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.groupby(['is_price']).ret.describe()" ] }, { "cell_type": "code", "execution_count": 6, "id": "d75489d6-8da2-4ad5-b3fe-dcacd65c411b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZoAAAFcCAYAAADxt3jKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAA03ElEQVR4nO3de5hT1b038O/euSdzZciMgIiICKKgoiBwLBxL5epYBOtD1WJtodjnFFqtiFUUiiJUsYC19rVq7avYc0RFBI4iVt9SKyhqraClitwqCHOfyeS6k+z1/pFJYJhbktk7mWR/P8/D4+T+WwT4ui57LUkIIUBERKQTOdsFEBFRfmPQEBGRrhg0RESkKwYNERHpikFDRES6YtAQEZGuzNkuIFV1dV6oam6tyC4tdaKhwZ/tMjSTT+3Jp7YA+dWeXGmL212Y7RJ6PPZo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vdOHHihL5FdyDZtpy+OWq8ZkmSMHHiRLzwwgtYtmwZbrvtNtTX12es/o7qKy8vb9WO9uqvqqpKuv2Zlm574j8vWLAAr776Kvr06YPly5dnrvB2dNUWAJg7dy6+853vtLqvp3431DWesJmi119/HStXrmx139lnn93mealsFCrauWZW7mTbfq1o3RZZljF79uzE7WHDhmHEiBH4+9//jm9961vdqjVV7f2entqOjh7v6nXZkm57gNhRHHFz587N+HdxunR/j3vqd0NdY9CkaOrUqa2680CsS3/55ZcjGo3CZDKhpqYmpY1CKyoqUFNTk7id6uvT1Z22lJeXo6amBgMGDGhV86ZNmzBy5EicddZZAGL/OFgsFt3bcrqKigp8+OGHidun9xpP39w1Xn+vXr3g9XrT/i71km57mpub8fLLL+P73/8+gNj3Ee8RZEtXbelIT/1uqGscOtOAxWLBZZddhtdeew1AbJVPKhuFjh8/Hlu2bEE0GsWRI0dw+PBhDB8+XK9yO5VsWyZMmIBXX30VAPDhhx/CZrOhb9+++Pzzz/GHP/wBAHDw4EHs27cPl156aeYa0KKrzVv79esHm82WWOEXb2d3v0u9pNsep9OJp556Cp988gkAYP369bjqqquy0oa4dDfW7anfDSUhW6sQ8s3Ro0fFTTfdJKZOnSp+8IMfiMbGRiGEEH/605/E2rVrWz33vffea7XqTFVVsWrVKjFt2jQxbdo08c4772S09tMl05ZgMCjuvPNOMW3aNDFjxgzx6aefCiGEaG5uFgsWLBDTp08XV199tdi1a1fW2rF582Yxffp0MWnSJPH73/9eCCHE3LlzxZ49e4QQQuzbt0/MmjVLTJkyRdx+++0iFAoJITpuf7al254PPvhAzJgxQ0yZMkXceuutwuPxZK0NcV21JW7x4sWtVp311O+GOsdNNYmISFccOiMiIl0xaIiISFcMGiIi0hWDhoiIdMWgISIiXTFoiAB89dVXWLBgQbbLIMpLDBoixLafP3ToULbLIMpLvI6G8tr777+PFStWwOl0wu/3Y+HChXjiiScQDodht9uxePFijBgxAlOmTEFVVRVGjRqFp59+OttlE+UV7nVGeW///v3485//jHA4jAULFuDZZ59FaWkp9u/fj1tuuQXbt2/HAw88gPvvv58hQ6QDBg3lvT59+qBfv354/vnnUV1dndhgEojt/vvvf/87e8URGQCDhvKe0+kEAKiqirFjx2Lt2rWJx44fP47y8vJWuwkTkba4GIAMY8yYMXj33Xdx4MABALGTTa+55hqEQiGYTCaEw+EsV0iUn9ijIcMYPHgwli9fjttvvz1xLsvvfvc7OJ1ODB48GCaTCddddx1efPFFHqhFpCGuOiMiIl1x6IyIiHTFoCEiIl0xaIiISFcMGiIi0hWDhoiIdMWgISIiXTFoiIhIVwwaIiLS1f8H+cEwL3k3+mAAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "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/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAA4Q0lEQVR4nO3de1yUVf4H8M8MN0VUhJ3hp9Rv1bytgRFimCWspnIXASkFxWyzoty8JMl6jdQ1ibykQuWutrFmsqYoBWhZWmZtQP5CTd10M1SUGS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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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countmeanstdmin25%50%75%max
is_price
0.01950.00.0004850.017500-0.119841-0.0081440.0009530.0093260.115800
1.03565.00.0001680.008332-0.058944-0.0035450.0005460.0046280.038053
\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 }