Files
quant/vectorbt/tests/notebooks/labels.ipynb

763 lines
226 KiB
Plaintext
Raw Permalink Normal View History

2025-11-01 09:32:26 +08:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# labels"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import vectorbt as vbt"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"Collapsed": "false"
},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"from datetime import datetime, timedelta\n",
"from numba import njit"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Disable caching for performance testing\n",
"vbt.settings.caching['enabled'] = False"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"close = pd.DataFrame({\n",
" 'a': [1, 2, 1, 2, 3, 2],\n",
" 'b': [3, 2, 3, 2, 1, 2]\n",
"}, index=pd.Index([\n",
" datetime(2020, 1, 1),\n",
" datetime(2020, 1, 2),\n",
" datetime(2020, 1, 3),\n",
" datetime(2020, 1, 4),\n",
" datetime(2020, 1, 5),\n",
" datetime(2020, 1, 6)\n",
"]))\n",
"\n",
"pos_ths = [np.array([1, 1 / 2]), np.array([2, 1 / 2]), np.array([3, 1 / 2])]\n",
"neg_ths = [np.array([1 / 2, 1 / 3]), np.array([1 / 2, 2 / 3]), np.array([1 / 2, 3 / 4])]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1000, 1000)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"big_close = pd.DataFrame(np.random.randint(1, 10, size=(1000, 1000)).astype(float))\n",
"big_close.index = [datetime(2018, 1, 1) + timedelta(days=i) for i in range(1000)]\n",
"big_close.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Look-ahead indicators"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fmean_window 2 3 \\\n",
"fmean_ewm False True False True \n",
" a b a b a b a \n",
"2020-01-01 1.5 2.5 1.802469 2.197531 1.666667 2.333333 1.8125 \n",
"2020-01-02 1.5 2.5 1.407407 2.592593 2.000000 2.000000 1.6250 \n",
"2020-01-03 2.5 1.5 2.222222 1.777778 2.333333 1.666667 2.2500 \n",
"2020-01-04 2.5 1.5 2.666667 1.333333 NaN NaN NaN \n",
"2020-01-05 NaN NaN NaN NaN NaN NaN NaN \n",
"2020-01-06 NaN NaN NaN NaN NaN NaN NaN \n",
"\n",
"fmean_window \n",
"fmean_ewm \n",
" b \n",
"2020-01-01 2.1875 \n",
"2020-01-02 2.3750 \n",
"2020-01-03 1.7500 \n",
"2020-01-04 NaN \n",
"2020-01-05 NaN \n",
"2020-01-06 NaN \n",
"11.2 ms ± 1.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"77.1 ms ± 1.63 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 8000)\n"
]
}
],
"source": [
"print(vbt.FMEAN.run(close, window=(2, 3), ewm=(False, True), param_product=True).fmean)\n",
"\n",
"%timeit vbt.FMEAN.run(big_close, window=2)\n",
"%timeit vbt.FMEAN.run(big_close, window=np.arange(2, 10).tolist())\n",
"\n",
"print(vbt.FMEAN.run(big_close, window=np.arange(2, 10).tolist()).wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fstd_window 2 3 \\\n",
"fstd_ewm False True False True \n",
" a b a b a b a \n",
"2020-01-01 0.5 0.5 0.644867 0.644867 0.471405 0.471405 0.646256 \n",
"2020-01-02 0.5 0.5 0.883301 0.883301 0.816497 0.816497 0.859125 \n",
"2020-01-03 0.5 0.5 0.591608 0.591608 0.471405 0.471405 0.547723 \n",
"2020-01-04 0.5 0.5 0.707107 0.707107 NaN NaN NaN \n",
"2020-01-05 NaN NaN NaN NaN NaN NaN NaN \n",
"2020-01-06 NaN NaN NaN NaN NaN NaN NaN \n",
"\n",
"fstd_window \n",
"fstd_ewm \n",
" b \n",
"2020-01-01 0.646256 \n",
"2020-01-02 0.859125 \n",
"2020-01-03 0.547723 \n",
"2020-01-04 NaN \n",
"2020-01-05 NaN \n",
"2020-01-06 NaN \n",
"13.2 ms ± 565 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"107 ms ± 1.88 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 8000)\n"
]
}
],
"source": [
"print(vbt.FSTD.run(close, window=(2, 3), ewm=(False, True), param_product=True).fstd)\n",
"\n",
"%timeit vbt.FSTD.run(big_close, window=2)\n",
"%timeit vbt.FSTD.run(big_close, window=np.arange(2, 10).tolist())\n",
"\n",
"print(vbt.FSTD.run(big_close, window=np.arange(2, 10).tolist()).wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fmin_window 2 3 \n",
" a b a b\n",
"2020-01-01 1.0 2.0 1.0 2.0\n",
"2020-01-02 1.0 2.0 1.0 1.0\n",
"2020-01-03 2.0 1.0 2.0 1.0\n",
"2020-01-04 2.0 1.0 NaN NaN\n",
"2020-01-05 NaN NaN NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN\n",
"9.06 ms ± 323 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"113 ms ± 875 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 8000)\n"
]
}
],
"source": [
"print(vbt.FMIN.run(close, window=(2, 3)).fmin)\n",
"\n",
"%timeit vbt.FMIN.run(big_close, window=2)\n",
"%timeit vbt.FMIN.run(big_close, window=np.arange(2, 10).tolist())\n",
"\n",
"print(vbt.FMIN.run(big_close, window=np.arange(2, 10).tolist()).wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fmax_window 2 3 \n",
" a b a b\n",
"2020-01-01 2.0 3.0 2.0 3.0\n",
"2020-01-02 2.0 3.0 3.0 3.0\n",
"2020-01-03 3.0 2.0 3.0 2.0\n",
"2020-01-04 3.0 2.0 NaN NaN\n",
"2020-01-05 NaN NaN NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN\n",
"9.08 ms ± 418 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"114 ms ± 700 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 8000)\n"
]
}
],
"source": [
"print(vbt.FMAX.run(close, window=(2, 3)).fmax)\n",
"\n",
"%timeit vbt.FMAX.run(big_close, window=2)\n",
"%timeit vbt.FMAX.run(big_close, window=np.arange(2, 10).tolist())\n",
"\n",
"print(vbt.FMAX.run(big_close, window=np.arange(2, 10).tolist()).wrapper.shape)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Label generators"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"fixlb_n 2 3 \n",
" a b a b\n",
"2020-01-01 0.0 0.000000 1.0 -0.333333\n",
"2020-01-02 0.0 0.000000 0.5 -0.500000\n",
"2020-01-03 2.0 -0.666667 1.0 -0.333333\n",
"2020-01-04 0.0 0.000000 NaN NaN\n",
"2020-01-05 NaN NaN NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN\n",
"3.11 ms ± 84.1 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"43.6 ms ± 2.82 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n",
"(1000, 8000)\n"
]
}
],
"source": [
"print(vbt.FIXLB.run(close, n=(2, 3)).labels)\n",
"\n",
"%timeit vbt.FIXLB.run(big_close, n=2)\n",
"%timeit vbt.FIXLB.run(big_close, n=np.arange(2, 10).tolist())\n",
"\n",
"print(vbt.FIXLB.run(big_close, n=np.arange(2, 10).tolist()).wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-2aca23\"><g class=\"clips\"><clipPath id=\"clip2aca23xyplot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath id=\"clip2aca23xy2plot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2aca23x\"><rect x=\"48\" y=\"0\" width=\"617.5799999999999\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2aca23y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2aca23xy\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2aca23y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip2aca23xy2\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"g2aca23-cb02e2a0ad-aba9-4d5d-afbb-8528290e1c22\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(99.46000000000001,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(202.39,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(305.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(408.25,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(511.18,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(614.11,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><p
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.FIXLB.run(close['a'], n=2).plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"meanlb_window 2 3 \\\n",
"meanlb_ewm False True False True \n",
" a b a b a b a \n",
"2020-01-01 0.50 -0.166667 0.802469 -0.267490 0.666667 -0.222222 0.8125 \n",
"2020-01-02 -0.25 0.250000 -0.296296 0.296296 0.000000 0.000000 -0.1875 \n",
"2020-01-03 1.50 -0.500000 1.222222 -0.407407 1.333333 -0.444444 1.2500 \n",
"2020-01-04 0.25 -0.250000 0.333333 -0.333333 NaN NaN NaN \n",
"2020-01-05 NaN NaN NaN NaN NaN NaN NaN \n",
"2020-01-06 NaN NaN NaN NaN NaN NaN NaN \n",
"\n",
"meanlb_window \n",
"meanlb_ewm \n",
" b \n",
"2020-01-01 -0.270833 \n",
"2020-01-02 0.187500 \n",
"2020-01-03 -0.416667 \n",
"2020-01-04 NaN \n",
"2020-01-05 NaN \n",
"2020-01-06 NaN \n",
"12.8 ms ± 2.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"77.2 ms ± 1.27 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 8000)\n"
]
}
],
"source": [
"print(vbt.MEANLB.run(close, window=(2, 3), ewm=(False, True), param_product=True).labels)\n",
"\n",
"%timeit vbt.MEANLB.run(big_close, window=2)\n",
"%timeit vbt.MEANLB.run(big_close, window=np.arange(2, 10).tolist())\n",
"\n",
"print(vbt.MEANLB.run(big_close, window=np.arange(2, 10).tolist()).wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-5e38f2\"><g class=\"clips\"><clipPath id=\"clip5e38f2xyplot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath id=\"clip5e38f2xy2plot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip5e38f2x\"><rect x=\"48\" y=\"0\" width=\"617.5799999999999\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clip5e38f2y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip5e38f2xy\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip5e38f2y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip5e38f2xy2\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"g5e38f2-cb0b55b784-37cb-4fa6-abd9-2a31b4563656\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(99.46000000000001,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(202.39,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(305.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(408.25,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(511.18,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(614.11,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><p
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.MEANLB.run(close['a'], window=2).plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"lexlb_pos_th array_0 array_1 array_2 \n",
"lexlb_neg_th array_0 array_1 array_2 \n",
" a b a b a b\n",
"2020-01-01 -1 1 -1 1 0 0\n",
"2020-01-02 1 -1 0 0 0 0\n",
"2020-01-03 -1 1 0 0 0 0\n",
"2020-01-04 0 0 0 0 0 0\n",
"2020-01-05 1 -1 1 -1 0 0\n",
"2020-01-06 0 1 0 1 0 0\n",
"15.6 ms ± 230 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"(1000, 1000)\n"
]
}
],
"source": [
"print(vbt.LEXLB.run(close, pos_th=pos_ths, neg_th=neg_ths).labels)\n",
"\n",
"%timeit vbt.LEXLB.run(big_close, pos_th=1, neg_th=0.5)\n",
"\n",
"print(vbt.LEXLB.run(big_close, pos_th=1, neg_th=0.5).wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-a12fb9\"><g class=\"clips\"><clipPath id=\"clipa12fb9xyplot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath id=\"clipa12fb9xy2plot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipa12fb9x\"><rect x=\"48\" y=\"0\" width=\"609.12\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clipa12fb9y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipa12fb9xy\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipa12fb9y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipa12fb9xy2\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"ga12fb9-cb62a84054-a133-472d-9565-8b72e3f8add3\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"609.12\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(98.75999999999999,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(200.28,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(301.8,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(403.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(504.84,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(606.36,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(2
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.LEXLB.run(close['a'], pos_th=1, neg_th=0.5).plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"trendlb_pos_th array_0 array_1 array_2 \n",
"trendlb_neg_th array_0 array_1 array_2 \n",
"trendlb_mode 0 0 0 \n",
" a b a b a b\n",
"2020-01-01 1.0 0.0 1.0 0.0 NaN NaN\n",
"2020-01-02 0.0 1.0 1.0 0.0 NaN NaN\n",
"2020-01-03 1.0 0.0 1.0 0.0 NaN NaN\n",
"2020-01-04 1.0 0.0 1.0 0.0 NaN NaN\n",
"2020-01-05 NaN 1.0 NaN 1.0 NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN NaN NaN\n",
"28.3 ms ± 335 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"(1000, 1000)\n"
]
}
],
"source": [
"print(vbt.TRENDLB.run(close, pos_th=pos_ths, neg_th=neg_ths, mode='Binary').labels)\n",
"\n",
"%timeit vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='Binary')\n",
"\n",
"print(vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='Binary').wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-4a1048\"><g class=\"clips\"><clipPath id=\"clip4a1048xyplot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath id=\"clip4a1048xy2plot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip4a1048x\"><rect x=\"48\" y=\"0\" width=\"617.5799999999999\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clip4a1048y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip4a1048xy\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip4a1048y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip4a1048xy2\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"g4a1048-cbc9c8447e-db1a-4f15-b918-9da81beaed3e\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(99.46000000000001,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(202.39,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(305.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(408.25,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(511.18,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(614.11,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><p
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.TRENDLB.run(close['a'], pos_th=1, neg_th=0.5, mode='Binary').plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"trendlb_pos_th array_0 array_1 array_2 \n",
"trendlb_neg_th array_0 array_1 array_2 \n",
"trendlb_mode 1 1 1 \n",
" a b a b a b\n",
"2020-01-01 1.0 0.0 1.0 0.0 NaN NaN\n",
"2020-01-02 0.0 1.0 0.5 0.5 NaN NaN\n",
"2020-01-03 1.0 0.0 1.0 0.0 NaN NaN\n",
"2020-01-04 0.5 0.5 0.5 0.5 NaN NaN\n",
"2020-01-05 NaN 1.0 NaN 1.0 NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN NaN NaN\n",
"106 ms ± 718 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 1000)\n"
]
}
],
"source": [
"print(vbt.TRENDLB.run(close, pos_th=pos_ths, neg_th=neg_ths, mode='BinaryCont').labels)\n",
"\n",
"%timeit vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='BinaryCont')\n",
"\n",
"print(vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='BinaryCont').wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-ba72e5\"><g class=\"clips\"><clipPath id=\"clipba72e5xyplot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath id=\"clipba72e5xy2plot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipba72e5x\"><rect x=\"48\" y=\"0\" width=\"617.5799999999999\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clipba72e5y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipba72e5xy\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipba72e5y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clipba72e5xy2\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"gba72e5-cba0b4d3d2-7d0b-483e-9f9c-c34e047dca01\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(99.46000000000001,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(202.39,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(305.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(408.25,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(511.18,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(614.11,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><p
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.TRENDLB.run(close['a'], pos_th=1, neg_th=0.5, mode='BinaryCont').plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"trendlb_pos_th array_0 array_1 array_2 \n",
"trendlb_neg_th array_0 array_1 array_2 \n",
"trendlb_mode 2 2 2 \n",
" a b a b a b\n",
"2020-01-01 1.000000 0.0 1.0 0.0 NaN NaN\n",
"2020-01-02 0.000000 1.0 0.5 0.5 NaN NaN\n",
"2020-01-03 1.000000 0.0 1.0 0.0 NaN NaN\n",
"2020-01-04 0.666667 0.0 0.5 0.5 NaN NaN\n",
"2020-01-05 NaN 1.0 NaN 1.0 NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN NaN NaN\n",
"43.5 ms ± 1.24 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 1000)\n"
]
}
],
"source": [
"print(vbt.TRENDLB.run(close, pos_th=pos_ths, neg_th=neg_ths, mode='BinaryContSat').labels)\n",
"\n",
"%timeit vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='BinaryContSat')\n",
"\n",
"print(vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='BinaryContSat').wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-972762\"><g class=\"clips\"><clipPath id=\"clip972762xyplot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath id=\"clip972762xy2plot\" class=\"plotclip\"><rect width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip972762x\"><rect x=\"48\" y=\"0\" width=\"617.5799999999999\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clip972762y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip972762xy\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip972762y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip972762xy2\"><rect x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"g972762-cb9ab78014-66dc-4ae0-8c00-cd73b14ec922\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"617.5799999999999\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(99.46000000000001,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(202.39,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(305.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(408.25,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(511.18,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(614.11,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h617.5799999999999\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><p
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.TRENDLB.run(close['a'], pos_th=1, neg_th=0.5, mode='BinaryContSat').plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"trendlb_pos_th array_0 array_1 array_2 \n",
"trendlb_neg_th array_0 array_1 array_2 \n",
"trendlb_mode 3 3 3 \n",
" a b a b a b\n",
"2020-01-01 1.0 -0.333333 2.0 -0.666667 NaN NaN\n",
"2020-01-02 -0.5 0.500000 0.5 -0.500000 NaN NaN\n",
"2020-01-03 2.0 -0.666667 2.0 -0.666667 NaN NaN\n",
"2020-01-04 0.5 -0.500000 0.5 -0.500000 NaN NaN\n",
"2020-01-05 NaN 1.000000 NaN 1.000000 NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN NaN NaN\n",
"27.9 ms ± 112 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 1000)\n"
]
}
],
"source": [
"print(vbt.TRENDLB.run(close, pos_th=pos_ths, neg_th=neg_ths, mode='PctChange').labels)\n",
"\n",
"%timeit vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='PctChange')\n",
"\n",
"print(vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='PctChange').wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-16f217\"><g class=\"clips\"><clipPath id=\"clip16f217xyplot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath id=\"clip16f217xy2plot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip16f217x\"><rect x=\"48\" y=\"0\" width=\"609.12\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clip16f217y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip16f217xy\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip16f217y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip16f217xy2\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"g16f217-cb841f581b-870a-41fc-baa6-372297c0abf4\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"609.12\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(98.75999999999999,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(200.28,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(301.8,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(403.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(504.84,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(606.36,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(2
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.TRENDLB.run(close['a'], pos_th=1, neg_th=0.5, mode='PctChange').plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"trendlb_pos_th array_0 array_1 array_2 \n",
"trendlb_neg_th array_0 array_1 array_2 \n",
"trendlb_mode 4 4 4 \n",
" a b a b a b\n",
"2020-01-01 0.500000 -0.333333 0.666667 -0.666667 NaN NaN\n",
"2020-01-02 -0.500000 0.333333 0.333333 -0.500000 NaN NaN\n",
"2020-01-03 0.666667 -0.666667 0.666667 -0.666667 NaN NaN\n",
"2020-01-04 0.333333 -0.500000 0.333333 -0.500000 NaN NaN\n",
"2020-01-05 NaN 0.500000 NaN 0.500000 NaN NaN\n",
"2020-01-06 NaN NaN NaN NaN NaN NaN\n",
"28.2 ms ± 44.8 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 1000)\n"
]
}
],
"source": [
"print(vbt.TRENDLB.run(close, pos_th=pos_ths, neg_th=neg_ths, mode='PctChangeNorm').labels)\n",
"\n",
"%timeit vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='PctChangeNorm')\n",
"\n",
"print(vbt.TRENDLB.run(big_close, pos_th=1, neg_th=0.5, mode='PctChangeNorm').wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-0a83f1\"><g class=\"clips\"><clipPath id=\"clip0a83f1xyplot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath id=\"clip0a83f1xy2plot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip0a83f1x\"><rect x=\"48\" y=\"0\" width=\"609.12\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clip0a83f1y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip0a83f1xy\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip0a83f1y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip0a83f1xy2\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"g0a83f1-cba9e1da00-c046-43f5-8561-3fb62abadb86\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"609.12\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(98.75999999999999,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(200.28,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(301.8,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(403.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(504.84,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(606.36,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(2
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.TRENDLB.run(close['a'], pos_th=1, neg_th=0.5, mode='PctChangeNorm').plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"bolb_window 1 \n",
"bolb_pos_th array_0 array_1 array_2 \n",
"bolb_neg_th array_0 array_1 array_2 \n",
" a b a b a b\n",
"2020-01-01 1.0 -1.0 0.0 0.0 0.0 0.0\n",
"2020-01-02 -1.0 1.0 -1.0 1.0 -1.0 1.0\n",
"2020-01-03 1.0 -1.0 0.0 0.0 0.0 0.0\n",
"2020-01-04 0.0 -1.0 0.0 0.0 0.0 0.0\n",
"2020-01-05 0.0 1.0 0.0 1.0 0.0 1.0\n",
"2020-01-06 0.0 0.0 0.0 0.0 0.0 0.0\n",
"bolb_window 2 \n",
"bolb_pos_th array_0 array_1 array_2 \n",
"bolb_neg_th array_0 array_1 array_2 \n",
" a b a b a b\n",
"2020-01-01 1.0 -1.0 0.0 0.0 0.0 0.0\n",
"2020-01-02 -1.0 1.0 -1.0 1.0 -1.0 1.0\n",
"2020-01-03 1.0 -1.0 1.0 -1.0 0.0 0.0\n",
"2020-01-04 0.0 -1.0 0.0 0.0 0.0 0.0\n",
"2020-01-05 0.0 1.0 0.0 1.0 0.0 1.0\n",
"2020-01-06 0.0 0.0 0.0 0.0 0.0 0.0\n",
"18.2 ms ± 277 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
"137 ms ± 341 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n",
"(1000, 8000)\n"
]
}
],
"source": [
"print(vbt.BOLB.run(close, window=1, pos_th=pos_ths, neg_th=neg_ths).labels)\n",
"print(vbt.BOLB.run(close, window=2, pos_th=pos_ths, neg_th=neg_ths).labels)\n",
"\n",
"%timeit vbt.BOLB.run(big_close, window=2, pos_th=1, neg_th=0.5)\n",
"%timeit vbt.BOLB.run(big_close, window=np.arange(2, 10).tolist(), pos_th=1, neg_th=0.5)\n",
"\n",
"print(vbt.BOLB.run(big_close, window=np.arange(2, 10).tolist(), pos_th=1, neg_th=0.5).wrapper.shape)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg class=\"main-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800\" height=\"350\" style=\"\" viewBox=\"0 0 800 350\"><rect x=\"0\" y=\"0\" width=\"800\" height=\"350\" style=\"fill: rgb(255, 255, 255); fill-opacity: 1;\"/><defs id=\"defs-9d8626\"><g class=\"clips\"><clipPath id=\"clip9d8626xyplot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath id=\"clip9d8626xy2plot\" class=\"plotclip\"><rect width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip9d8626x\"><rect x=\"48\" y=\"0\" width=\"609.12\" height=\"350\"/></clipPath><clipPath class=\"axesclip\" id=\"clip9d8626y\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip9d8626xy\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip9d8626y2\"><rect x=\"0\" y=\"46\" width=\"800\" height=\"261\"/></clipPath><clipPath class=\"axesclip\" id=\"clip9d8626xy2\"><rect x=\"48\" y=\"46\" width=\"609.12\" height=\"261\"/></clipPath></g><g class=\"gradients\"><linearGradient x1=\"0\" x2=\"0\" y1=\"1\" y2=\"0\" id=\"g9d8626-cb96cf60e5-9347-4fa6-b91b-ea2c8d6539b4\"><stop offset=\"0%\" stop-color=\"rgb(13, 8, 135)\" stop-opacity=\"1\"/><stop offset=\"11.11111111111111%\" stop-color=\"rgb(70, 3, 159)\" stop-opacity=\"1\"/><stop offset=\"22.22222222222222%\" stop-color=\"rgb(114, 1, 168)\" stop-opacity=\"1\"/><stop offset=\"33.33333333333333%\" stop-color=\"rgb(156, 23, 158)\" stop-opacity=\"1\"/><stop offset=\"44.44444444444444%\" stop-color=\"rgb(189, 55, 134)\" stop-opacity=\"1\"/><stop offset=\"55.55555555555556%\" stop-color=\"rgb(216, 87, 107)\" stop-opacity=\"1\"/><stop offset=\"66.66666666666666%\" stop-color=\"rgb(237, 121, 83)\" stop-opacity=\"1\"/><stop offset=\"77.77777777777779%\" stop-color=\"rgb(251, 159, 58)\" stop-opacity=\"1\"/><stop offset=\"88.88888888888889%\" stop-color=\"rgb(253, 202, 38)\" stop-opacity=\"1\"/><stop offset=\"100%\" stop-color=\"rgb(240, 249, 33)\" stop-opacity=\"1\"/></linearGradient></g></defs><g class=\"bglayer\"><rect class=\"bg\" x=\"48\" y=\"46\" width=\"609.12\" height=\"261\" style=\"fill: rgb(229, 236, 246); fill-opacity: 1; stroke-width: 0;\"/></g><g class=\"layer-below\"><g class=\"imagelayer\"/><g class=\"shapelayer\"/></g><g class=\"cartesianlayer\"><g class=\"subplot xy\"><g class=\"layer-subplot\"><g class=\"shapelayer\"/><g class=\"imagelayer\"/></g><g class=\"gridlayer\"><g class=\"x\"><path class=\"xgrid crisp\" transform=\"translate(98.75999999999999,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(200.28,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(301.8,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(403.32,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(504.84,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"xgrid crisp\" transform=\"translate(606.36,0)\" d=\"M0,46v261\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y\"><path class=\"ygrid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/></g><g class=\"y2\"><path class=\"y2grid crisp\" transform=\"translate(0,290.2)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,233.35)\" d=\"M48,0h609.12\" style=\"stroke: rgb(255, 255, 255); stroke-opacity: 1; stroke-width: 1px;\"/><path class=\"y2grid crisp\" transform=\"translate(0,176.5)\" d=\"M48,0h609.12\" style=\"stroke: rgb(2
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"vbt.BOLB.run(close['a'], window=2, pos_th=1, neg_th=0.5).plot().show_svg()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}