{
  "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": [
        "# 13 Curve regime score\n",
        "\n",
        "Does the gap between five-print RWTC returns when the curve z-score is above 1 and when it is below -1 keep its sign after 2019?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "(CL1_MINUS_CL4 minus the train mean) divided by the train population standard deviation. Train mean -0.142 dollars per barrel. Train standard deviation 1.850. Both moments stop at 31 Dec 2019 and are applied to every later print. A positive CL1_MINUS_CL4 means the front NYMEX contract is above the fourth."
      ]
    },
    {
      "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'] == 'curve-z')\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, z above 1 minus z below -1, is -1.331% (927 high, 996 low). Holdout gap is -5.886% (336 high, 39 low). The holdout kept the train sign.\n",
            "Five-print RWTC return, high curve z versus low curve z\n",
            "Train | 927 | 996 | -1.331%\n",
            "Holdout | 336 | 39 | -5.886%\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "The score is a level z-score of the stored spread, not a new curve. EIA's contract history in this snapshot ends where RCLC1 ends.\n",
        "\n",
        "## Result\n",
        "\n",
        "Train gap, z above 1 minus z below -1, is -1.331% (927 high, 996 low). Holdout gap is -5.886% (336 high, 39 low). The holdout kept the train sign."
      ]
    }
  ]
}
