{
  "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": [
        "# 16 Realized volatility\n",
        "\n",
        "When 20-print realized volatility sits at or above its pre-2020 80th percentile, is the holdout mean absolute five-print RWTC return larger than on the other days?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "Population standard deviation of the last 20 adjacent RWTC log returns, times the square root of 252. A return enters only when the two prints are 1 to 5 calendar days apart. High realized vol is at or above the train 80th percentile, frozen at 0.4535. Implied volatility is not in this archive. No implied-versus-realized ratio is computed."
      ]
    },
    {
      "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'] == 'realized-vol')\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 gap in mean absolute five-print return, high vol minus the rest, is 2.618%. Holdout gap is 3.946% (383 high, 1295 rest). The holdout gap is positive, which was the bar.\n",
            "Mean absolute five-print RWTC return when RV20 is at or above the frozen train 80th percentile\n",
            "Train | 1550 | 6198 | 2.618%\n",
            "Holdout | 383 | 1295 | 3.946%\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "The bar is a positive holdout gap. The train gap is reported and is not used to move the cutoff.\n",
        "\n",
        "## Result\n",
        "\n",
        "Train gap in mean absolute five-print return, high vol minus the rest, is 2.618%. Holdout gap is 3.946% (383 high, 1295 rest). The holdout gap is positive, which was the bar."
      ]
    }
  ]
}
