{
  "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": [
        "# 01 Seasonality\n",
        "\n",
        "Do WTI's calendar-month mean returns from before 2020 show up again after it?\n",
        "\n",
        "Holdout starts 2020-01-01. Verdict: held.\n",
        "\n",
        "This study reads stored series. It does not add a derived column."
      ]
    },
    {
      "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'] == 'seasonality')\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",
            "Correlation of the 12 train month-means with the 12 holdout month-means is 0.309. Signs match in 5 of 12 months. The correlation is above zero, which was the bar. 5 matching signs out of 12 is a thin map.\n",
            "Mean daily log return of RWTC by calendar month\n",
            "01 | 638 | -0.042% | 141 | 0.172% | not the same\n",
            "02 | 603 | -0.032% | 134 | 0.081% | not the same\n",
            "03 | 676 | 0.170% | 154 | -0.180% | not the same\n",
            "04 | 625 | 0.192% | 143 | 0.448% | same\n",
            "05 | 633 | -0.001% | 146 | 0.285% | not the same\n",
            "06 | 655 | 0.030% | 146 | 0.041% | same\n",
            "07 | 638 | 0.007% | 149 | 0.220% | same\n",
            "08 | 707 | 0.059% | 153 | -0.167% | not the same\n",
            "09 | 634 | 0.039% | 144 | -0.003% | not the same\n",
            "10 | 677 | -0.106% | 129 | -0.038% | same\n",
            "11 | 630 | -0.201% | 117 | -0.185% | same\n",
            "12 | 651 | -0.001% | 128 | 0.140% | not the same\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Method\n",
        "\n",
        "Train prints end 31 Dec 2019. Holdout prints start 1 Jan 2020. Each calendar month gets a mean daily log return in each window.\n",
        "\n",
        "## Result\n",
        "\n",
        "Correlation of the 12 train month-means with the 12 holdout month-means is 0.309. Signs match in 5 of 12 months. The correlation is above zero, which was the bar. 5 matching signs out of 12 is a thin map."
      ]
    }
  ]
}
