{
  "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": [
        "# 20 SPR flow\n",
        "\n",
        "Is the holdout correlation between the weekly SPR stock change and the Wednesday RWTC return negative?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: failed.\n",
        "\n",
        "Weekly change in EIA WCSSTUS1, the Strategic Petroleum Reserve, thousand barrels. Kept only when the two week-ending dates are 7 days apart. A negative change is a draw."
      ]
    },
    {
      "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'] == 'spr-flow')\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": [
            "failed\n",
            "Train correlation of the SPR change with the Wednesday RWTC return is 0.019. Holdout correlation is 0.047. The holdout correlation is not negative. The bar was missed.\n",
            "WCSSTUS1 weekly change versus the Wednesday RWTC log return\n",
            "Train | 1584 | 0.019\n",
            "Holdout | 348 | 0.047\n",
            "Skipped, no Wednesday RWTC print | 359 | \n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "The bar is a negative holdout correlation: a draw (negative change) lining up with a higher Wednesday return.\n",
        "\n",
        "## Result\n",
        "\n",
        "Train correlation of the SPR change with the Wednesday RWTC return is 0.019. Holdout correlation is 0.047. The holdout correlation is not negative. The bar was missed."
      ]
    }
  ]
}
