{
  "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": [
        "# 14 Positioning z-score\n",
        "\n",
        "Does the gap between five-print RWTC returns when the managed-money z-score is above 1.5, and when it is not, keep its sign after 2019?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: failed.\n",
        "\n",
        "Managed-money net divided by open interest on CFTC 067651. Z-score uses the train mean and the train population standard deviation of that ratio. Train mean 0.1146. Train standard deviation 0.0386. The percentile is the share of train ratios at or below the current print. Spreads are not inside the net."
      ]
    },
    {
      "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'] == 'cot-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": [
            "failed\n",
            "Train gap, z above 1.5 minus the rest, is -0.128% (39 extreme, 480 rest). Holdout gap is 1.722% (11 extreme, 340 rest). The holdout flipped the train sign.\n",
            "Five-print RWTC return when COT_Z is above 1.5\n",
            "Train | 39 | 480 | -0.128%\n",
            "Holdout | 11 | 340 | 1.722%\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "The report date is joined to RWTC on that date, or to the next print within 3 calendar days.\n",
        "\n",
        "## Result\n",
        "\n",
        "Train gap, z above 1.5 minus the rest, is -0.128% (39 extreme, 480 rest). Holdout gap is 1.722% (11 extreme, 340 rest). The holdout flipped the train sign."
      ]
    }
  ]
}
