{
  "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": [
        "# 17 EIA-day reaction profile\n",
        "\n",
        "Do the four pre-2020 surprise bins rank the Wednesday RWTC return the same way after 2019?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "The same weekly WCESTUS1 surprise as the inventory study: change minus the prior 52-week median. Train quartile edges are frozen. Each week is placed in one of four bins. The score is the Spearman correlation of the train bin-mean release return with the holdout bin-mean."
      ]
    },
    {
      "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'] == 'eia-profile')\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 quartile edges, thousand barrels: -3060.0, 39.5, 2773.0. Spearman correlation of the bin means is 0.400. The correlation is above zero, which was the bar.\n",
            "Mean Wednesday RWTC log return by inventory-surprise quartile\n",
            "1 | 0.424% | 0.557%\n",
            "2 | 0.301% | -0.127%\n",
            "3 | -0.106% | -0.877%\n",
            "4 | -0.232% | 0.240%\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "Quartile 1 is the most negative surprise (a larger draw, or a smaller build, than the prior 52-week median).\n",
        "\n",
        "## Result\n",
        "\n",
        "Train quartile edges, thousand barrels: -3060.0, 39.5, 2773.0. Spearman correlation of the bin means is 0.400. The correlation is above zero, which was the bar."
      ]
    }
  ]
}
