{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from imbalance_price_calculator import ImbalancePriceCalculator\n", "\n", "# auto reload modules\n", "%load_ext autoreload\n", "%autoreload 2\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[16.0, 154.25, 154.25, 1.0], [40.0, 159.25, 159.25, 1.0], [20.0, 159.25, 159.25, 1.0], [52.1, 194.6, 279.69, 2.0], [58.0, 194.6, 279.84, 2.0], [39.0, 243.97, 592.87, 2.0], [15.0, 515.6, 636.81, 2.0], [1.3, 515.6, 638.3, 2.0], [0.8, 515.6, 642.18, 2.0], [15.0, 515.6, 643.81, 2.0], [1.0, 526.6, 651.6, 2.0], [150.0, 243.97, 701.68, 2.0], [19.0, 1000.0, 1000.0, 2.0], [1.0, 1500.0, 1500.0, 2.0], [2.0, 896.22, 1696.22, 2.0], [10.0, 1815.0, 1815.0, 2.0], [97.1, 2000.0, 2000.0, 2.0], [79.0, 2867.35, 2867.35, 2.0], [64.0, 202.2, 279.45, 2.0], [64.0, 202.3, 279.55, 2.0], [40.0, 205.3, 326.48, 2.0], [195.0, 145.8, 337.1, 2.0], [330.0, 243.97, 373.89, 2.0], [1.0, 450.0, 450.0, 2.0], [450.0, 198.8, 544.25, 2.0], [43.0, 243.97, 553.07, 2.0], [0.6, 243.97, 592.87, 2.0], [210.0, 243.97, 602.27, 2.0], [16.0, 514.92, 630.53, 2.0], [1.5, 515.6, 636.81, 2.0], [15.0, 515.6, 642.18, 2.0], [0.6, 515.6, 643.81, 2.0], [15.0, 526.6, 651.6, 2.0], [44.9, 1450.0, 1450.0, 2.0], [7.0, 599.0, 599.0, 1.0], [5.0, 150.0, 150.0, 2.0], [1.0, 158.79, 158.79, 1.0], [33.0, 390.0, 390.0, 1.0], [6.0, 194.6, 279.69, 2.0], [0.8, 205.3, 326.48, 2.0], [25.0, 299.0, 496.76, 2.0], [1.7, 243.97, 553.07, 2.0], [1.3, 514.92, 630.53, 2.0], [15.0, 515.6, 638.3, 2.0], [375.0, 243.97, 643.02, 2.0], [225.0, 190.2, 647.07, 2.0], [16.0, 1450.0, 1450.0, 2.0], [0.5, 896.22, 1696.22, 2.0], [2.0, 800.0, 800.0, 3.0]]\n" ] } ], "source": [ "# load data\n", "import pandas\n", "\n", "df = pandas.read_csv('../../data/ods139.csv', delimiter=';', decimal=\".\", thousands=',')\n", "df['Datetime'] = pandas.to_datetime(df['Datetime'])\n", "\n", "\n", "# get rows for 2023-12-07 09:45\n", "df = df[df['Datetime'] == '2023-12-09 12:00:00']\n", "# get bid ladder\n", "bid_ladder = df[['Bid Volume', 'Bid Price', 'Bid+Start Price', 'Activation Order']].values.tolist()\n", "\n", "print(bid_ladder)\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(16.0, 154.25, 154.25, 1.0)\n", "(17.0, 158.79, 158.79, 1.0)\n", "(57.0, 159.25, 159.25, 1.0)\n", "(77.0, 159.25, 159.25, 1.0)\n", "(110.0, 390.0, 390.0, 1.0)\n", "(117.0, 599.0, 599.0, 1.0)\n", "(312.0, 599.0, 145.8, 2.0)\n", "(317.0, 599.0, 150.0, 2.0)\n", "(542.0, 599.0, 190.2, 2.0)\n", "(594.1, 599.0, 194.6, 2.0)\n", "(652.1, 599.0, 194.6, 2.0)\n", "(658.1, 599.0, 194.6, 2.0)\n", "(1108.1, 599.0, 198.8, 2.0)\n", "(1172.1, 599.0, 202.2, 2.0)\n", "(1236.1, 599.0, 202.3, 2.0)\n", "(1276.1, 599.0, 205.3, 2.0)\n", "(1276.8999999999999, 599.0, 205.3, 2.0)\n", "(1315.8999999999999, 599.0, 243.97, 2.0)\n", "(1465.8999999999999, 599.0, 243.97, 2.0)\n", "(1795.8999999999999, 599.0, 243.97, 2.0)\n", "(1838.8999999999999, 599.0, 243.97, 2.0)\n", "(1839.4999999999998, 599.0, 243.97, 2.0)\n", "(2049.5, 599.0, 243.97, 2.0)\n", "(2051.2, 599.0, 243.97, 2.0)\n", "(2426.2, 599.0, 243.97, 2.0)\n", "(2451.2, 599.0, 299.0, 2.0)\n", "(2452.2, 599.0, 450.0, 2.0)\n", "(2468.2, 599.0, 514.92, 2.0)\n", "(2469.5, 599.0, 514.92, 2.0)\n", "(2484.5, 599.0, 515.6, 2.0)\n", "(2485.8, 599.0, 515.6, 2.0)\n", "(2486.6000000000004, 599.0, 515.6, 2.0)\n", "(2501.6000000000004, 599.0, 515.6, 2.0)\n", "(2503.1000000000004, 599.0, 515.6, 2.0)\n", "(2518.1000000000004, 599.0, 515.6, 2.0)\n", "(2518.7000000000003, 599.0, 515.6, 2.0)\n", "(2533.7000000000003, 599.0, 515.6, 2.0)\n", "(2534.7000000000003, 599.0, 526.6, 2.0)\n", "(2549.7000000000003, 599.0, 526.6, 2.0)\n", "(2551.7000000000003, 896.22, 896.22, 2.0)\n", "(2552.2000000000003, 896.22, 896.22, 2.0)\n", "(2571.2000000000003, 1000.0, 1000.0, 2.0)\n", "(2616.1000000000004, 1450.0, 1450.0, 2.0)\n", "(2632.1000000000004, 1450.0, 1450.0, 2.0)\n", "(2633.1000000000004, 1500.0, 1500.0, 2.0)\n", "(2643.1000000000004, 1815.0, 1815.0, 2.0)\n", "(2740.2000000000003, 2000.0, 2000.0, 2.0)\n", "(2819.2000000000003, 2867.35, 2867.35, 2.0)\n", "(2821.2000000000003, 2867.35, 800.0, 3.0)\n" ] } ], "source": [ "c = ImbalancePriceCalculator(bid_ladder)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "lines+markers", "type": "scatter", "x": [ 16, 17, 17, 57, 57, 77, 77, 110, 110, 117, 117, 312, 312, 317, 317, 542, 542, 594.1, 594.1, 652.1, 652.1, 658.1, 658.1, 1108.1, 1108.1, 1172.1, 1172.1, 1236.1, 1236.1, 1276.1, 1276.1, 1276.8999999999999, 1276.8999999999999, 1315.8999999999999, 1315.8999999999999, 1465.8999999999999, 1465.8999999999999, 1795.8999999999999, 1795.8999999999999, 1838.8999999999999, 1838.8999999999999, 1839.4999999999998, 1839.4999999999998, 2049.5, 2049.5, 2051.2, 2051.2, 2426.2, 2426.2, 2451.2, 2451.2, 2452.2, 2452.2, 2468.2, 2468.2, 2469.5, 2469.5, 2484.5, 2484.5, 2485.8, 2485.8, 2486.6000000000004, 2486.6000000000004, 2501.6000000000004, 2501.6000000000004, 2503.1000000000004, 2503.1000000000004, 2518.1000000000004, 2518.1000000000004, 2518.7000000000003, 2518.7000000000003, 2533.7000000000003, 2533.7000000000003, 2534.7000000000003, 2534.7000000000003, 2549.7000000000003, 2549.7000000000003, 2551.7000000000003, 2551.7000000000003, 2552.2000000000003, 2552.2000000000003, 2571.2000000000003, 2571.2000000000003, 2616.1000000000004, 2616.1000000000004, 2632.1000000000004, 2632.1000000000004, 2633.1000000000004, 2633.1000000000004, 2643.1000000000004, 2643.1000000000004, 2740.2000000000003, 2740.2000000000003, 2819.2000000000003, 2819.2000000000003, 2821.2000000000003 ], "y": [ 154.25, 154.25, 158.79, 158.79, 159.25, 159.25, 159.25, 159.25, 390, 390, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 599, 896.22, 896.22, 896.22, 896.22, 1000, 1000, 1450, 1450, 1450, 1450, 1500, 1500, 1815, 1815, 2000, 2000, 2867.35, 2867.35, 2867.35, 2867.35 ] } ], "layout": { "hovermode": "x unified", "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Bid ladder" }, "xaxis": { "title": { "text": "Volume" } }, "yaxis": { "title": { "text": "Price" } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "100MW: 390.0\n", "200MW: 599.0\n", "300MW: 599.0\n", "400MW: 599.0\n", "500MW: 599.0\n", "600MW: 599.0\n", "700MW: 599.0\n", "800MW: 599.0\n", "900MW: 599.0\n", "1000MW: 599.0\n", "Max: 2867.35\n" ] } ], "source": [ "c.plot()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "599.0\n" ] } ], "source": [ "print(c.get_imbalance_price(1000))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "base", "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.10.11" } }, "nbformat": 4, "nbformat_minor": 2 }