{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Multiple Time Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-09-21T08:54:02.986534Z",
     "start_time": "2022-09-21T08:54:00.854256Z"
    }
   },
   "outputs": [],
   "source": [
    "import tslumen\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-09-21T08:54:03.873671Z",
     "start_time": "2022-09-21T08:54:03.868900Z"
    },
    "nbsphinx": "hidden"
   },
   "outputs": [],
   "source": [
    "# patch it\n",
    "_read_csv = pd.read_csv\n",
    "pd.read_csv = lambda fpath, *args, **kwargs: _read_csv(fpath.split('/')[-1], *args, **kwargs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-09-21T08:54:04.806723Z",
     "start_time": "2022-09-21T08:54:04.790829Z"
    }
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv('https://datahub.io/core/s-and-p-500/r/data.csv', parse_dates=[0], index_col=0)\n",
    "df = df[(df.index >= '1990-01-01') & (df.index < '2015-01-01')]\n",
    "meta = {\n",
    "    'frame': {\n",
    "        'Description': '''S&P 500 index data including level, dividend, earnings and P/E ratio on \n",
    "a monthly basis since 1870. The S&P 500 (Standard and Poor’s 500) is a free-float, \n",
    "capitalization-weighted index of the top 500 publicly listed stocks in the US (top 500 by market cap)''',\n",
    "        'Source': '<a href=\"https://datahub.io/core/s-and-p-500\">DataHub</a>',\n",
    "    },\n",
    "    'series': {\n",
    "        'SP500': \"Level ('price') of the S&P 500 index\",\n",
    "        'Dividend': 'Dividend',\n",
    "        'Earnings': 'Earnings',\n",
    "        'Consumer Price Index': 'Consumer Price Index',\n",
    "        'Long Interest Rate': '10 year interest rate (gov bonds)',\n",
    "        'Real Price': 'Real Price',\n",
    "        'Real Dividend': 'Real Dividend',\n",
    "        'Real Earnings': 'Real Earnings',\n",
    "        'PE10': 'Cyclically Adjusted Price Earnings Ratio P/E10 or CAPE',\n",
    "    }\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-09-21T08:54:23.764843Z",
     "start_time": "2022-09-21T08:54:05.938402Z"
    }
   },
   "outputs": [],
   "source": [
    "tslumen.HtmlReport(df, meta)"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Edit Metadata",
  "hide_input": false,
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": false,
   "skip_h1_title": true,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
