{
  "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": [
        "# 12 Cushing days of cover\n",
        "\n",
        "Does the gap between five-print RWTC returns when Cushing days of cover are below the pre-2020 20th percentile, and when they are not, keep its sign after 2019?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "Cushing crude stocks (thousand barrels) divided by US refiner net inputs of crude (thousand barrels per day) on the same Friday. The result is days. Low cover is a print below the train 20th percentile, frozen at 1.403 days."
      ]
    },
    {
      "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'] == 'cushing-cover')\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 20th percentile of days of cover is 1.403. Train gap, low cover minus the rest, is -0.204% (145 low, 581 rest). Holdout gap is -0.319% (60 low, 290 rest). The holdout kept the train sign.\n",
            "Five-print RWTC log return when days of cover are below the frozen train 20th percentile\n",
            "Train | 145 | 581 | -0.204%\n",
            "Holdout | 60 | 290 | -0.319%\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "The price date is the Friday print when RWTC exists that day, otherwise the next RWTC print within 3 calendar days. The return then steps five published RWTC prints.\n",
        "\n",
        "## Result\n",
        "\n",
        "Train 20th percentile of days of cover is 1.403. Train gap, low cover minus the rest, is -0.204% (145 low, 581 rest). Holdout gap is -0.319% (60 low, 290 rest). The holdout kept the train sign."
      ]
    }
  ]
}
