Created
November 10, 2025 15:05
-
-
Save danwagnerco/9a8b5181da21a7b7276ef7475bc34cda to your computer and use it in GitHub Desktop.
Using interpolated 7d / 30d IV for ticker OXY to creating a rolling slope calculation with the Unusual Whales API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "id": "6c4609e5", | |
| "metadata": {}, | |
| "source": [ | |
| "Unusual Whales API endpoints we will use in this notebook:\n", | |
| "\n", | |
| "**Realized Volatility**\n", | |
| "- Docs: [https://api.unusualwhales.com/docs#/operations/PublicApi.TickerController.realized_volatility](https://api.unusualwhales.com/docs#/operations/PublicApi.TickerController.realized_volatility)\n", | |
| "- GET: `https://api.unusualwhales.com/api/stock/{ticker}/volatility/realized`\n", | |
| "\n", | |
| "**Interpolated IV**\n", | |
| "- Docs: [https://api.unusualwhales.com/docs#/operations/PublicApi.TickerController.interpolated_iv](https://api.unusualwhales.com/docs#/operations/PublicApi.TickerController.interpolated_iv)\n", | |
| "- GET: `https://api.unusualwhales.com/api/stock/{ticker}/interpolated-iv`" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 1, | |
| "id": "b7b6a31b", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "\n", | |
| " <div id=\"VLxxKs\"></div>\n", | |
| " <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n", | |
| " if(!window.letsPlotCallQueue) {\n", | |
| " window.letsPlotCallQueue = [];\n", | |
| " }; \n", | |
| " window.letsPlotCall = function(f) {\n", | |
| " window.letsPlotCallQueue.push(f);\n", | |
| " };\n", | |
| " (function() {\n", | |
| " var script = document.createElement(\"script\");\n", | |
| " script.type = \"text/javascript\";\n", | |
| " script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/[email protected]/js-package/distr/lets-plot.min.js\";\n", | |
| " script.onload = function() {\n", | |
| " window.letsPlotCall = function(f) {f();};\n", | |
| " window.letsPlotCallQueue.forEach(function(f) {f();});\n", | |
| " window.letsPlotCallQueue = [];\n", | |
| " \n", | |
| " };\n", | |
| " script.onerror = function(event) {\n", | |
| " window.letsPlotCall = function(f) {}; // noop\n", | |
| " window.letsPlotCallQueue = [];\n", | |
| " var div = document.createElement(\"div\");\n", | |
| " div.style.color = 'darkred';\n", | |
| " div.textContent = 'Error loading Lets-Plot JS';\n", | |
| " document.getElementById(\"VLxxKs\").appendChild(div);\n", | |
| " };\n", | |
| " var e = document.getElementById(\"VLxxKs\");\n", | |
| " e.appendChild(script);\n", | |
| " })()\n", | |
| " </script>\n", | |
| " " | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "import os\n", | |
| "import time\n", | |
| "import httpx # pip install httpx==0.27.2\n", | |
| "import polars as pl # pip install polars==1.33.1\n", | |
| "import lets_plot as lp # pip install lets-plot==4.3.3\n", | |
| "lp.LetsPlot.setup_html()\n", | |
| "\n", | |
| "uw_token = os.getenv(\"UW_TOKEN\")\n", | |
| "headers = {\n", | |
| " \"Accept\": \"application/json, text/plain\",\n", | |
| " \"Authorization\": uw_token\n", | |
| "}" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "6c81e0db", | |
| "metadata": {}, | |
| "source": [ | |
| "We need to collect trading dates for the last year, and using the Realized Volatility endpoint is a bit of a hack for that because its response is very convenient." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 2, | |
| "id": "4154b3be", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "['2024-11-11', '2024-11-12', '2024-11-13', '2024-11-14', '2024-11-15']" | |
| ] | |
| }, | |
| "execution_count": 2, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "ticker = \"OXY\"\n", | |
| "rv_url = f\"https://api.unusualwhales.com/api/stock/{ticker}/volatility/realized\"\n", | |
| "params = {\"timeframe\": \"1Y\"}\n", | |
| "rsp = httpx.get(rv_url, headers=headers, params=params)\n", | |
| "trading_dates = [r[\"date\"] for r in rsp.json()[\"data\"]]\n", | |
| "trading_dates[:5]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "a4f0aff6", | |
| "metadata": {}, | |
| "source": [ | |
| "Now that we have the trading dates, we will hit the Interpolated IV endpoint for data." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 3, | |
| "id": "2956731a", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "[{'date': '2025-05-12',\n", | |
| " 'days': 1,\n", | |
| " 'percentile': '0.709',\n", | |
| " 'volatility': '0.363',\n", | |
| " 'implied_move_perc': '0.023'},\n", | |
| " {'date': '2025-05-12',\n", | |
| " 'days': 5,\n", | |
| " 'percentile': '0.697',\n", | |
| " 'volatility': '0.359',\n", | |
| " 'implied_move_perc': '0.028'},\n", | |
| " {'date': '2025-05-12',\n", | |
| " 'days': 7,\n", | |
| " 'percentile': '0.72',\n", | |
| " 'volatility': '0.351',\n", | |
| " 'implied_move_perc': '0.032'},\n", | |
| " {'date': '2025-05-12',\n", | |
| " 'days': 14,\n", | |
| " 'percentile': '0.656',\n", | |
| " 'volatility': '0.323',\n", | |
| " 'implied_move_perc': '0.042'},\n", | |
| " {'date': '2025-05-12',\n", | |
| " 'days': 30,\n", | |
| " 'percentile': '0.569',\n", | |
| " 'volatility': '0.31',\n", | |
| " 'implied_move_perc': '0.06'}]" | |
| ] | |
| }, | |
| "execution_count": 3, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "interpolated_ivs = []\n", | |
| "for td in trading_dates:\n", | |
| " url = f\"https://api.unusualwhales.com/api/stock/{ticker}/interpolated-iv\"\n", | |
| " params = {\"date\": td}\n", | |
| " rsp = httpx.get(url, headers=headers, params=params)\n", | |
| " interpolated_ivs.extend(rsp.json()[\"data\"])\n", | |
| " time.sleep(0.6) # Avoid hitting the basic 120 req/min limit\n", | |
| "interpolated_ivs[:5]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "3e6ed9ea", | |
| "metadata": {}, | |
| "source": [ | |
| "Convert this list of dictionaries into a dataframe for easier manipulation and plotting." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 4, | |
| "id": "ded712ab", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div><style>\n", | |
| ".dataframe > thead > tr,\n", | |
| ".dataframe > tbody > tr {\n", | |
| " text-align: right;\n", | |
| " white-space: pre-wrap;\n", | |
| "}\n", | |
| "</style>\n", | |
| "<small>shape: (1_143, 5)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>date</th><th>days</th><th>percentile</th><th>volatility</th><th>implied_move_perc</th></tr><tr><td>str</td><td>i64</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>"2025-05-12"</td><td>1</td><td>"0.709"</td><td>"0.363"</td><td>"0.023"</td></tr><tr><td>"2025-05-12"</td><td>5</td><td>"0.697"</td><td>"0.359"</td><td>"0.028"</td></tr><tr><td>"2025-05-12"</td><td>7</td><td>"0.72"</td><td>"0.351"</td><td>"0.032"</td></tr><tr><td>"2025-05-12"</td><td>14</td><td>"0.656"</td><td>"0.323"</td><td>"0.042"</td></tr><tr><td>"2025-05-12"</td><td>30</td><td>"0.569"</td><td>"0.31"</td><td>"0.06"</td></tr><tr><td>…</td><td>…</td><td>…</td><td>…</td><td>…</td></tr><tr><td>"2025-11-10"</td><td>30</td><td>"0.811"</td><td>"0.359"</td><td>"0.07"</td></tr><tr><td>"2025-11-10"</td><td>60</td><td>"0.502"</td><td>"0.33"</td><td>"0.091"</td></tr><tr><td>"2025-11-10"</td><td>90</td><td>"0.566"</td><td>"0.328"</td><td>"0.111"</td></tr><tr><td>"2025-11-10"</td><td>180</td><td>"0.815"</td><td>"0.345"</td><td>"0.162"</td></tr><tr><td>"2025-11-10"</td><td>365</td><td>"0.832"</td><td>"0.34"</td><td>"0.227"</td></tr></tbody></table></div>" | |
| ], | |
| "text/plain": [ | |
| "shape: (1_143, 5)\n", | |
| "┌────────────┬──────┬────────────┬────────────┬───────────────────┐\n", | |
| "│ date ┆ days ┆ percentile ┆ volatility ┆ implied_move_perc │\n", | |
| "│ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", | |
| "│ str ┆ i64 ┆ str ┆ str ┆ str │\n", | |
| "╞════════════╪══════╪════════════╪════════════╪═══════════════════╡\n", | |
| "│ 2025-05-12 ┆ 1 ┆ 0.709 ┆ 0.363 ┆ 0.023 │\n", | |
| "│ 2025-05-12 ┆ 5 ┆ 0.697 ┆ 0.359 ┆ 0.028 │\n", | |
| "│ 2025-05-12 ┆ 7 ┆ 0.72 ┆ 0.351 ┆ 0.032 │\n", | |
| "│ 2025-05-12 ┆ 14 ┆ 0.656 ┆ 0.323 ┆ 0.042 │\n", | |
| "│ 2025-05-12 ┆ 30 ┆ 0.569 ┆ 0.31 ┆ 0.06 │\n", | |
| "│ … ┆ … ┆ … ┆ … ┆ … │\n", | |
| "│ 2025-11-10 ┆ 30 ┆ 0.811 ┆ 0.359 ┆ 0.07 │\n", | |
| "│ 2025-11-10 ┆ 60 ┆ 0.502 ┆ 0.33 ┆ 0.091 │\n", | |
| "│ 2025-11-10 ┆ 90 ┆ 0.566 ┆ 0.328 ┆ 0.111 │\n", | |
| "│ 2025-11-10 ┆ 180 ┆ 0.815 ┆ 0.345 ┆ 0.162 │\n", | |
| "│ 2025-11-10 ┆ 365 ┆ 0.832 ┆ 0.34 ┆ 0.227 │\n", | |
| "└────────────┴──────┴────────────┴────────────┴───────────────────┘" | |
| ] | |
| }, | |
| "execution_count": 4, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "raw_df = pl.DataFrame(interpolated_ivs)\n", | |
| "raw_df" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "c6cc901b", | |
| "metadata": {}, | |
| "source": [ | |
| "Let's \"unmelt\" this dataframe into a \"wide\" dataframe so we can calculate the 7d / 30d slope." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 5, | |
| "id": "167df4d2", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div><style>\n", | |
| ".dataframe > thead > tr,\n", | |
| ".dataframe > tbody > tr {\n", | |
| " text-align: right;\n", | |
| " white-space: pre-wrap;\n", | |
| "}\n", | |
| "</style>\n", | |
| "<small>shape: (127, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>date</th><th>slope_7_30</th></tr><tr><td>str</td><td>f64</td></tr></thead><tbody><tr><td>"2025-05-12"</td><td>0.132258</td></tr><tr><td>"2025-05-13"</td><td>0.10596</td></tr><tr><td>"2025-05-14"</td><td>0.07837</td></tr><tr><td>"2025-05-15"</td><td>0.045181</td></tr><tr><td>"2025-05-16"</td><td>-0.021672</td></tr><tr><td>…</td><td>…</td></tr><tr><td>"2025-11-04"</td><td>0.129032</td></tr><tr><td>"2025-11-05"</td><td>0.141566</td></tr><tr><td>"2025-11-06"</td><td>0.178571</td></tr><tr><td>"2025-11-07"</td><td>0.185393</td></tr><tr><td>"2025-11-10"</td><td>0.426184</td></tr></tbody></table></div>" | |
| ], | |
| "text/plain": [ | |
| "shape: (127, 2)\n", | |
| "┌────────────┬────────────┐\n", | |
| "│ date ┆ slope_7_30 │\n", | |
| "│ --- ┆ --- │\n", | |
| "│ str ┆ f64 │\n", | |
| "╞════════════╪════════════╡\n", | |
| "│ 2025-05-12 ┆ 0.132258 │\n", | |
| "│ 2025-05-13 ┆ 0.10596 │\n", | |
| "│ 2025-05-14 ┆ 0.07837 │\n", | |
| "│ 2025-05-15 ┆ 0.045181 │\n", | |
| "│ 2025-05-16 ┆ -0.021672 │\n", | |
| "│ … ┆ … │\n", | |
| "│ 2025-11-04 ┆ 0.129032 │\n", | |
| "│ 2025-11-05 ┆ 0.141566 │\n", | |
| "│ 2025-11-06 ┆ 0.178571 │\n", | |
| "│ 2025-11-07 ┆ 0.185393 │\n", | |
| "│ 2025-11-10 ┆ 0.426184 │\n", | |
| "└────────────┴────────────┘" | |
| ] | |
| }, | |
| "execution_count": 5, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "df = (\n", | |
| " raw_df\n", | |
| " .with_columns(\n", | |
| " pl.col(\"percentile\").cast(pl.Float64),\n", | |
| " pl.col(\"volatility\").cast(pl.Float64),\n", | |
| " pl.col(\"implied_move_perc\").cast(pl.Float64),\n", | |
| " )\n", | |
| " .pivot(\n", | |
| " on=\"days\",\n", | |
| " values=[\"percentile\", \"volatility\", \"implied_move_perc\"],\n", | |
| " index=\"date\",\n", | |
| " )\n", | |
| " .with_columns(\n", | |
| " (pl.col(\"volatility_7\")/pl.col(\"volatility_30\") - 1).alias(\"slope_7_30\"),\n", | |
| " )\n", | |
| " .select([\"date\", \"slope_7_30\"])\n", | |
| " .sort(\"date\")\n", | |
| ")\n", | |
| "df" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "fed64333", | |
| "metadata": {}, | |
| "source": [ | |
| "The next cell is \"boilerplate\" to make the plots look nice, scroll on by..." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 6, | |
| "id": "0ab503a0", | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "UW_DARK_THEME = {\n", | |
| " \"red\": \"#dc3545\",\n", | |
| " \"yellow\": \"#ffc107\",\n", | |
| " \"teal\": \"#20c997\",\n", | |
| " \"blue_medium\": \"#53a5d5\",\n", | |
| " \"blue_light\": \"#b5d5e1\",\n", | |
| " \"black\": \"#161c2d\",\n", | |
| " \"gray_medium\": \"#748196\",\n", | |
| " \"gray_light\": \"#f9fbfd\",\n", | |
| "}\n", | |
| "\n", | |
| "def uw_dark_theme(colors: dict, show_legend: bool=True):\n", | |
| " \"\"\"Create a dark theme for lets-plot using UW colors.\"\"\"\n", | |
| " t = lp.theme_none() + lp.theme(\n", | |
| " plot_background=lp.element_rect(fill=colors[\"black\"]),\n", | |
| " panel_background=lp.element_rect(fill=colors[\"black\"]),\n", | |
| " panel_grid_major=lp.element_blank(),\n", | |
| " panel_grid_minor=lp.element_blank(),\n", | |
| " axis_ontop=True,\n", | |
| " axis_ticks=lp.element_blank(),\n", | |
| " axis_tooltip=lp.element_rect(color=colors[\"gray_light\"]),\n", | |
| " tooltip=lp.element_rect(color=colors[\"gray_light\"], fill=colors[\"black\"]),\n", | |
| " line=lp.element_line(color=colors[\"gray_medium\"], size=1),\n", | |
| " rect=lp.element_rect(color=colors[\"black\"], fill=colors[\"black\"], size=2),\n", | |
| " text=lp.element_text(color=colors[\"gray_light\"], size=10),\n", | |
| " legend_background=lp.element_rect(\n", | |
| " color=colors[\"gray_light\"], fill=colors[\"black\"], size=2\n", | |
| " ),\n", | |
| " plot_title=lp.element_text(hjust=0.5, size=16, color=colors[\"gray_light\"]),\n", | |
| " )\n", | |
| " if show_legend:\n", | |
| " return t + lp.theme(legend_position=\"bottom\")\n", | |
| " else:\n", | |
| " return t + lp.theme(legend_position=\"none\")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "id": "f7d0c2b8", | |
| "metadata": {}, | |
| "source": [ | |
| "Finally we are ready to plot the `OXY` 7d / 30d interpolated IV slope over time." | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "id": "bbd98298", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| " <div id=\"3us9b3\"></div>\n", | |
| " <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n", | |
| " (function() {\n", | |
| " var plotSpec={\n", | |
| "\"data\":{\n", | |
| "\"date\":[\"2025-05-12\",\"2025-05-13\",\"2025-05-14\",\"2025-05-15\",\"2025-05-16\",\"2025-05-19\",\"2025-05-20\",\"2025-05-21\",\"2025-05-22\",\"2025-05-23\",\"2025-05-27\",\"2025-05-28\",\"2025-05-29\",\"2025-05-30\",\"2025-06-02\",\"2025-06-03\",\"2025-06-04\",\"2025-06-05\",\"2025-06-06\",\"2025-06-09\",\"2025-06-10\",\"2025-06-11\",\"2025-06-12\",\"2025-06-13\",\"2025-06-16\",\"2025-06-17\",\"2025-06-18\",\"2025-06-20\",\"2025-06-23\",\"2025-06-24\",\"2025-06-25\",\"2025-06-26\",\"2025-06-27\",\"2025-06-30\",\"2025-07-01\",\"2025-07-02\",\"2025-07-03\",\"2025-07-07\",\"2025-07-08\",\"2025-07-09\",\"2025-07-10\",\"2025-07-11\",\"2025-07-14\",\"2025-07-15\",\"2025-07-16\",\"2025-07-17\",\"2025-07-18\",\"2025-07-21\",\"2025-07-22\",\"2025-07-23\",\"2025-07-24\",\"2025-07-25\",\"2025-07-28\",\"2025-07-29\",\"2025-07-30\",\"2025-07-31\",\"2025-08-01\",\"2025-08-04\",\"2025-08-05\",\"2025-08-06\",\"2025-08-07\",\"2025-08-08\",\"2025-08-11\",\"2025-08-12\",\"2025-08-13\",\"2025-08-14\",\"2025-08-15\",\"2025-08-18\",\"2025-08-19\",\"2025-08-20\",\"2025-08-21\",\"2025-08-22\",\"2025-08-25\",\"2025-08-26\",\"2025-08-27\",\"2025-08-28\",\"2025-08-29\",\"2025-09-02\",\"2025-09-03\",\"2025-09-04\",\"2025-09-05\",\"2025-09-08\",\"2025-09-09\",\"2025-09-10\",\"2025-09-11\",\"2025-09-12\",\"2025-09-15\",\"2025-09-16\",\"2025-09-17\",\"2025-09-18\",\"2025-09-19\",\"2025-09-22\",\"2025-09-23\",\"2025-09-24\",\"2025-09-25\",\"2025-09-26\",\"2025-09-29\",\"2025-09-30\",\"2025-10-01\",\"2025-10-02\",\"2025-10-03\",\"2025-10-06\",\"2025-10-07\",\"2025-10-08\",\"2025-10-09\",\"2025-10-10\",\"2025-10-13\",\"2025-10-14\",\"2025-10-15\",\"2025-10-16\",\"2025-10-17\",\"2025-10-20\",\"2025-10-21\",\"2025-10-22\",\"2025-10-23\",\"2025-10-24\",\"2025-10-27\",\"2025-10-28\",\"2025-10-29\",\"2025-10-30\",\"2025-10-31\",\"2025-11-03\",\"2025-11-04\",\"2025-11-05\",\"2025-11-06\",\"2025-11-07\",\"2025-11-10\"],\n", | |
| "\"slope_7_30\":[0.13225806451612887,0.10596026490066235,0.0783699059561127,0.04518072289156616,-0.021671826625387025,0.06325301204819267,0.03892215568862256,0.07670454545454564,-0.01719197707736375,-0.08831908831908819,0.041420118343195034,0.11988304093567237,0.050595238095237915,0.020958083832335328,0.05688622754491002,0.11501597444089451,0.10122699386503053,0.15976331360946738,0.0031948881789136685,-0.006269592476489061,0.03833865814696491,0.04761904761904745,0.03939393939393954,0.13812154696132595,0.08333333333333326,0.1778975741239892,0.08522727272727271,0.03179190751445082,0.12640449438202261,0.027027027027026973,-0.030303030303030276,-0.05063291139240511,-0.06493506493506496,-0.06129032258064526,0.012944983818770295,0.0,-0.055374592833876246,-0.020467836257309968,-0.011730205278592365,-0.07185628742514971,-0.11818181818181828,-0.14285714285714302,-0.01412429378531077,-0.07988980716253435,-0.07002801120448165,-0.1789772727272727,-0.18361581920903958,-0.0914285714285713,-0.07826086956521727,-0.09144542772861364,-0.06567164179104479,-0.12835820895522398,0.053412462908011715,0.1268011527377524,0.16901408450704225,0.2901408450704226,0.2633053221288517,0.4803370786516856,0.38873239436619733,0.4405797101449276,0.0903225806451613,-0.043333333333333335,0.10097719869706845,0.06711409395973167,0.08219178082191791,0.03678929765886285,-0.0374149659863946,0.048275862068965614,0.06060606060606055,0.06101694915254252,0.09000000000000008,-0.043010752688172116,-0.02473498233215532,0.01403508771929829,-0.0035211267605633756,-0.046762589928057596,-0.18014705882352944,0.09342560553633228,0.10000000000000009,0.1095890410958904,0.06825938566552914,0.08754208754208759,0.06953642384105962,0.06229508196721323,-0.020134228187919434,-0.05802047781569952,0.012987012987013102,0.11858974358974361,0.08910891089108919,0.046052631578947345,-0.04391891891891897,0.022950819672131084,0.07278481012658244,0.03846153846153855,0.028571428571428692,-0.05228758169934644,0.07741935483870965,0.18181818181818188,0.09148264984227117,0.0953846153846154,-0.04807692307692313,-0.003154574132492094,-0.01567398119122254,-0.03809523809523818,-0.036809815950920255,0.025787965616045794,-0.06528189910979232,-0.07182320441988943,-0.06760563380281681,0.016216216216216273,-0.15186246418338112,-0.17002881844380402,-0.11111111111111116,-0.022922636103151706,-0.10140845070422533,-0.12979351032448383,-0.026627218934911268,-0.0029850746268657025,0.08982035928143706,-0.05637982195845703,-0.15133531157270042,-0.08408408408408419,0.12903225806451601,0.14156626506024095,0.1785714285714286,0.1853932584269664,0.42618384401114207]\n", | |
| "},\n", | |
| "\"mapping\":{\n", | |
| "\"x\":\"date\",\n", | |
| "\"y\":\"slope_7_30\",\n", | |
| "\"color\":\"slope_7_30\"\n", | |
| "},\n", | |
| "\"data_meta\":{\n", | |
| "},\n", | |
| "\"ggtitle\":{\n", | |
| "\"text\":\"OXY 7d to 30d IV Slope Over Time\"\n", | |
| "},\n", | |
| "\"theme\":{\n", | |
| "\"name\":\"none\",\n", | |
| "\"line\":{\n", | |
| "\"color\":\"#748196\",\n", | |
| "\"size\":1.0,\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"rect\":{\n", | |
| "\"fill\":\"#161c2d\",\n", | |
| "\"color\":\"#161c2d\",\n", | |
| "\"size\":2.0,\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"text\":{\n", | |
| "\"color\":\"#f9fbfd\",\n", | |
| "\"size\":10.0,\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"axis_ontop\":true,\n", | |
| "\"axis_ticks\":{\n", | |
| "\"blank\":true\n", | |
| "},\n", | |
| "\"legend_background\":{\n", | |
| "\"fill\":\"#161c2d\",\n", | |
| "\"color\":\"#f9fbfd\",\n", | |
| "\"size\":2.0,\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"panel_background\":{\n", | |
| "\"fill\":\"#161c2d\",\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"panel_grid_major\":{\n", | |
| "\"blank\":true\n", | |
| "},\n", | |
| "\"panel_grid_minor\":{\n", | |
| "\"blank\":true\n", | |
| "},\n", | |
| "\"plot_background\":{\n", | |
| "\"fill\":\"#161c2d\",\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"plot_title\":{\n", | |
| "\"color\":\"#f9fbfd\",\n", | |
| "\"size\":16.0,\n", | |
| "\"hjust\":0.5,\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"axis_tooltip\":{\n", | |
| "\"color\":\"#f9fbfd\",\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"tooltip\":{\n", | |
| "\"fill\":\"#161c2d\",\n", | |
| "\"color\":\"#f9fbfd\",\n", | |
| "\"blank\":false\n", | |
| "},\n", | |
| "\"legend_position\":\"none\"\n", | |
| "},\n", | |
| "\"kind\":\"plot\",\n", | |
| "\"scales\":[{\n", | |
| "\"aesthetic\":\"color\",\n", | |
| "\"values\":[\"#ffc107\"]\n", | |
| "}],\n", | |
| "\"layers\":[{\n", | |
| "\"geom\":\"line\",\n", | |
| "\"mapping\":{\n", | |
| "},\n", | |
| "\"data_meta\":{\n", | |
| "},\n", | |
| "\"data\":{\n", | |
| "}\n", | |
| "}],\n", | |
| "\"metainfo_list\":[]\n", | |
| "};\n", | |
| " var plotContainer = document.getElementById(\"3us9b3\");\n", | |
| " window.letsPlotCall(function() {{\n", | |
| " LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n", | |
| " }});\n", | |
| " })();\n", | |
| " </script>" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "p = (\n", | |
| " lp.ggplot(df)\n", | |
| " + lp.aes(x=\"date\", y=\"slope_7_30\", color=\"slope_7_30\")\n", | |
| " + lp.geom_line()\n", | |
| " + lp.scale_color_manual(values=[UW_DARK_THEME[\"yellow\"]])\n", | |
| " + lp.ggtitle(f\"{ticker} 7d to 30d IV Slope Over Time\")\n", | |
| " + uw_dark_theme(UW_DARK_THEME, show_legend=False)\n", | |
| ")\n", | |
| "p.show()" | |
| ] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "dans-magic-house", | |
| "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.11.11" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 5 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment