{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Composable Blocks & Interactive Charts" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook is a simple illustration of the python API for Blocks and Highcharts interactive charts.\n", "\n", "**What are Blocks?**\n", "Blocks are composable layout elements for easily building HTML, PDF, PNG and JPG based reports. At the same time, all block constructs can be rendered in-line in IPython Notebooks (as will be shown later). This has practical benefits like a single backtest function that can be used for quick analysis during research work in a notebook, but also directly injected into more formal reports with having to fumble around with intermediate formats.\n", "\n", "Practically all the functionality is based on HTML rendering. HTML is a declarative, tree based language that is easy to work with and fungible. Blocks are also declarative, composable into a tree and are meant to be dead simple. The match was thus quite natural.\n", "\n", "The blocks do not try to match the power and precision of latex. Such an undertaking would be not only out of the scope of a simple library, but would mean the reinvention of latex with all the gnarliness that comes with it.\n", "\n", "This notebook aims to showcase the functionality and offers some examples to help people get started." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Imports & Data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%%capture\n", "import numpy as np\n", "import pandas as pd\n", "import pandas.util.testing as pt\n", "from datetime import datetime\n", "\n", "import pybloqs as p" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "df = pd.DataFrame((np.random.rand(200, 4)-0.5)/10,\n", " columns=list(\"ABCD\"),\n", " index=pd.date_range(datetime(2000,1,1), periods=200))\n", "\n", "df_cr = (df + 1).cumprod()\n", "\n", "a = df_cr.A\n", "b = df_cr.B\n", "c = df_cr.C\n", "c.name = \"C\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using Blocks\n", "Obligatory \"Hello World!\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | \n", "\n", " A\n", " | \n", "\n", " B\n", " | \n", "\n", " C\n", " | \n", "\n", " D\n", " | \n", "
---|---|---|---|---|
\n", " 2000-01-01 00:00:00\n", " | \n", "\n", " 0.03\n", " | \n", "\n", " -0.02\n", " | \n", "\n", " -0.01\n", " | \n", "\n", " -0.04\n", " | \n", "
\n", " 2000-01-02 00:00:00\n", " | \n", "\n", " 0.01\n", " | \n", "\n", " 0.02\n", " | \n", "\n", " 0.02\n", " | \n", "\n", " -0.05\n", " | \n", "
\n", " 2000-01-03 00:00:00\n", " | \n", "\n", " 0.00\n", " | \n", "\n", " -0.04\n", " | \n", "\n", " -0.02\n", " | \n", "\n", " -0.03\n", " | \n", "
\n", " 2000-01-04 00:00:00\n", " | \n", "\n", " -0.02\n", " | \n", "\n", " 0.04\n", " | \n", "\n", " 0.01\n", " | \n", "\n", " -0.03\n", " | \n", "
\n", " 2000-01-05 00:00:00\n", " | \n", "\n", " -0.05\n", " | \n", "\n", " 0.04\n", " | \n", "\n", " -0.04\n", " | \n", "\n", " -0.02\n", " | \n", "
\n", "
\n", "
\n", "
\n", "some:\n", " example:\n", " yaml: [1,2,3]\n", " data: \"text\"\n", "" ], "text/plain": [ "