{
  "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": [
        "# 18 Seasonal stock deviation\n",
        "\n",
        "Does the correlation between seasonally adjusted commercial crude stocks and the Wednesday RWTC return keep its sign after 2019?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "WCESTUS1 level minus the train mean level for that calendar month. Month means are frozen on weeks before 2020. A later January is compared with the pre-2020 January mean, not with a mean that includes itself."
      ]
    },
    {
      "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'] == 'seas-stock')\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 correlation of the seasonal deviation with the Wednesday RWTC return is 0.006. Holdout correlation is 0.119. The holdout kept the train sign.\n",
            "WCESTUS1 minus the frozen calendar-month mean, versus the Wednesday RWTC return\n",
            "Train | 1584 | 0.006\n",
            "Holdout | 348 | 0.119\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "The bar is sign agreement. The popular sign would be negative. The test does not switch to that story after the numbers are in.\n",
        "\n",
        "## Result\n",
        "\n",
        "Train correlation of the seasonal deviation with the Wednesday RWTC return is 0.006. Holdout correlation is 0.119. The holdout kept the train sign."
      ]
    }
  ]
}
