{
  "nbformat": 4,
  "nbformat_minor": 5,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "name": "python",
      "pygments_lexer": "ipython3"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# 09 Anomaly flags\n",
        "\n",
        "Do RWTC days that sit more than four robust z-scores from the pre-2020 center lead larger five-print absolute moves?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "This study reads stored series. It does not add a derived column."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {},
      "source": [
        "import json\n",
        "from pathlib import Path\n",
        "studies = json.loads(Path('data/studies.json').read_text())\n",
        "study = next(item for item in studies['studies'] if item['slug'] == 'anomalies')\n",
        "print(study['verdict'])\n",
        "print(study['verdict_line'])\n",
        "print(study['table']['caption'])\n",
        "for row in study['table']['rows']:\n",
        "    print(' | '.join(row))\n"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "held\n",
            "Train median daily log return is 0.071%. MAD scale is 1.852%. Holdout days with |z| above 4: 53. Their mean absolute five-print return is 16.789%, against 4.483% on the other holdout days. The flagged days were followed by larger absolute moves. The holdout contains the 2020 break, and a large print often sits next to another large print.\n",
            "Holdout RWTC days scored with the frozen train center and MAD\n",
            "|z| > 4 | 53 | 16.789%\n",
            "The rest of the holdout | 1625 | 4.483%\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "Holdout days with |z| above 4 are the flags. The bar is a higher mean absolute five-print return on flags than on the other holdout days.\n",
        "\n",
        "## Result\n",
        "\n",
        "Train median daily log return is 0.071%. MAD scale is 1.852%. Holdout days with |z| above 4: 53. Their mean absolute five-print return is 16.789%, against 4.483% on the other holdout days. The flagged days were followed by larger absolute moves. The holdout contains the 2020 break, and a large print often sits next to another large print."
      ]
    }
  ]
}
