Skip to content

Instantly share code, notes, and snippets.

@nagishin
Last active August 12, 2020 04:43
Show Gist options
  • Save nagishin/e9d044ba6a490591a776e7fbe97ab964 to your computer and use it in GitHub Desktop.
Save nagishin/e9d044ba6a490591a776e7fbe97ab964 to your computer and use it in GitHub Desktop.
bybit_rank.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "bybit_rank.ipynb",
"provenance": [],
"collapsed_sections": [],
"toc_visible": true,
"authorship_tag": "ABX9TyNK9RtB9av7HKqe7TSDh1Xc",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/nagishin/e9d044ba6a490591a776e7fbe97ab964/bybit_rank.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "aP_paxIUzsIp",
"colab_type": "text"
},
"source": [
"# ローカルファイル アップロード"
]
},
{
"cell_type": "code",
"metadata": {
"id": "hRwXLPk2mk4X",
"colab_type": "code",
"colab": {
"resources": {
"http://localhost:8080/nbextensions/google.colab/files.js": {
"data": "Ly8gQ29weXJpZ2h0IDIwMTcgR29vZ2xlIExMQwovLwovLyBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLy8geW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgovLyBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLy8KLy8gICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAK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ok": true,
"headers": [
[
"content-type",
"application/javascript"
]
],
"status": 200,
"status_text": ""
}
},
"base_uri": "https://localhost:8080/",
"height": 77
},
"outputId": "ed765f1c-833c-4166-d0ba-7ea91242f28f"
},
"source": [
"from google.colab import files\n",
"uploaded = files.upload()"
],
"execution_count": 1,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
" <input type=\"file\" id=\"files-176002a6-d8b0-47be-a64a-a0efdfaf107d\" name=\"files[]\" multiple disabled\n",
" style=\"border:none\" />\n",
" <output id=\"result-176002a6-d8b0-47be-a64a-a0efdfaf107d\">\n",
" Upload widget is only available when the cell has been executed in the\n",
" current browser session. Please rerun this cell to enable.\n",
" </output>\n",
" <script src=\"/nbextensions/google.colab/files.js\"></script> "
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "stream",
"text": [
"Saving rank_0812_1330.txt to rank_0812_1330.txt\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "j7L0xYR9z6jm",
"colab_type": "text"
},
"source": [
"# ファイル読込 & DataFrame化"
]
},
{
"cell_type": "code",
"metadata": {
"id": "jEqsp7AfxDLP",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 419
},
"outputId": "8e66c478-eeaf-42c0-e256-9bf5c0bb7918"
},
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"rank_file = 'rank_0812_1330.txt'\n",
"np_rank = np.loadtxt(rank_file, dtype=str)\n",
"#print(np_rank)\n",
"\n",
"count = len(np_rank)\n",
"cols = 6\n",
"rows = int(count / cols)\n",
"nd_rank = np_rank.reshape(rows, cols)\n",
"#print(nd_rank)\n",
"\n",
"df_rank = pd.DataFrame(nd_rank, columns=['No', 'Name', 'BaseBTC', 'NowBTC', 'PnlBTC', 'PnlRatio'])\n",
"df_rank['No'] = df_rank['No'].map(lambda x: int(x.replace('NO.', '')))\n",
"df_rank['BaseBTC'] = df_rank['BaseBTC'].astype('float')\n",
"df_rank['NowBTC'] = df_rank['NowBTC'].astype('float')\n",
"df_rank['PnlBTC'] = df_rank['PnlBTC'].astype('float')\n",
"df_rank['PnlRatio'] = df_rank['PnlRatio'].map(lambda x: float(x.replace('%', '')))\n",
"\n",
"#print('No', type(df_rank['No'][0]))\n",
"#print('Name', type(df_rank['Name'][0]))\n",
"#print('BaseBTC', type(df_rank['BaseBTC'][0]))\n",
"#print('NowBTC', type(df_rank['NowBTC'][0]))\n",
"#print('PnlBTC', type(df_rank['PnlBTC'][0]))\n",
"#print('PnlRatio', type(df_rank['PnlRatio'][0]))\n",
"\n",
"display(df_rank)"
],
"execution_count": 2,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>No</th>\n",
" <th>Name</th>\n",
" <th>BaseBTC</th>\n",
" <th>NowBTC</th>\n",
" <th>PnlBTC</th>\n",
" <th>PnlRatio</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>Taa28</td>\n",
" <td>0.100817</td>\n",
" <td>2.186927e-01</td>\n",
" <td>0.117876</td>\n",
" <td>116.92</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>j0hnta</td>\n",
" <td>0.100000</td>\n",
" <td>2.156663e-01</td>\n",
" <td>0.115666</td>\n",
" <td>115.67</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>SUICUNE</td>\n",
" <td>0.108479</td>\n",
" <td>2.197801e-01</td>\n",
" <td>0.111302</td>\n",
" <td>102.60</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>HAMBURGER</td>\n",
" <td>0.100000</td>\n",
" <td>1.940028e-01</td>\n",
" <td>0.094003</td>\n",
" <td>94.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>B00NE</td>\n",
" <td>0.103536</td>\n",
" <td>1.933309e-01</td>\n",
" <td>0.089795</td>\n",
" <td>86.73</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>378</th>\n",
" <td>379</td>\n",
" <td>aarseth</td>\n",
" <td>0.100000</td>\n",
" <td>2.000000e-08</td>\n",
" <td>-0.100000</td>\n",
" <td>-100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>379</th>\n",
" <td>380</td>\n",
" <td>nanashi</td>\n",
" <td>0.162361</td>\n",
" <td>0.000000e+00</td>\n",
" <td>-0.162361</td>\n",
" <td>-100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>380</th>\n",
" <td>381</td>\n",
" <td>taka1110</td>\n",
" <td>0.100000</td>\n",
" <td>0.000000e+00</td>\n",
" <td>-0.100000</td>\n",
" <td>-100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>381</th>\n",
" <td>382</td>\n",
" <td>karuboman</td>\n",
" <td>0.100727</td>\n",
" <td>0.000000e+00</td>\n",
" <td>-0.100727</td>\n",
" <td>-100.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>382</th>\n",
" <td>383</td>\n",
" <td>TM2020</td>\n",
" <td>0.100000</td>\n",
" <td>0.000000e+00</td>\n",
" <td>-0.100000</td>\n",
" <td>-100.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>383 rows × 6 columns</p>\n",
"</div>"
],
"text/plain": [
" No Name BaseBTC NowBTC PnlBTC PnlRatio\n",
"0 1 Taa28 0.100817 2.186927e-01 0.117876 116.92\n",
"1 2 j0hnta 0.100000 2.156663e-01 0.115666 115.67\n",
"2 3 SUICUNE 0.108479 2.197801e-01 0.111302 102.60\n",
"3 4 HAMBURGER 0.100000 1.940028e-01 0.094003 94.00\n",
"4 5 B00NE 0.103536 1.933309e-01 0.089795 86.73\n",
".. ... ... ... ... ... ...\n",
"378 379 aarseth 0.100000 2.000000e-08 -0.100000 -100.00\n",
"379 380 nanashi 0.162361 0.000000e+00 -0.162361 -100.00\n",
"380 381 taka1110 0.100000 0.000000e+00 -0.100000 -100.00\n",
"381 382 karuboman 0.100727 0.000000e+00 -0.100727 -100.00\n",
"382 383 TM2020 0.100000 0.000000e+00 -0.100000 -100.00\n",
"\n",
"[383 rows x 6 columns]"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "khNLXDDT0krW",
"colab_type": "text"
},
"source": [
"# 集計"
]
},
{
"cell_type": "code",
"metadata": {
"id": "OLOJNu1n0tVO",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "de34f4d0-c0fb-4ab1-b721-702cc63baab5"
},
"source": [
"r = df_rank['PnlRatio'].values\n",
"total = len(r)\n",
"no_trade = np.sum(r == 0)\n",
"dead = np.sum(r < -95)\n",
"active = total - no_trade - dead\n",
"active_plus = np.sum(r > 0)\n",
"active_minus = np.count_nonzero((r < 0) & (r >= -95))\n",
"top10_average = r[:10].mean()\n",
"\n",
"print(f'[Total] : {total:3}')\n",
"print()\n",
"print(f'[Active] : {active:3}( {active/total:.2%} )')\n",
"print(f' | Profit : {active_plus:3}( {active_plus/total:.2%} )')\n",
"print(f' | Loss : {active_minus:3}( {active_minus/total:.2%} )')\n",
"print()\n",
"print(f'[Inactive] : {total - active:3}( {(total - active)/total:.2%} )')\n",
"print(f' | No Trade : {no_trade:3}( {no_trade/total:.2%} )')\n",
"print(f' | LossCut : {dead:3}( {dead/total:.2%} )')\n",
"print()\n",
"print(f'[Top10 Avr] : {top10_average:.2f}%')\n"
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": [
"[Total] : 383\n",
"\n",
"[Active] : 222( 57.96% )\n",
" | Profit : 97( 25.33% )\n",
" | Loss : 125( 32.64% )\n",
"\n",
"[Inactive] : 161( 42.04% )\n",
" | No Trade : 125( 32.64% )\n",
" | LossCut : 36( 9.40% )\n",
"\n",
"[Top10 Avr] : 78.69%\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "zt1D8LxSJYwj",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 700
},
"outputId": "efe2abde-8b28-4815-8aa7-440d9e7ddcf4"
},
"source": [
"# 損益率を10%単位で丸め\n",
"unit_ratio = 10\n",
"df_rank['UnitRatio'] = df_rank['PnlRatio'].map(lambda x: x + unit_ratio if x > 0 else x)\n",
"df_rank['UnitRatio'] = (df_rank['UnitRatio'] // unit_ratio) * unit_ratio\n",
"df_unit_ratio = df_rank.groupby('UnitRatio').agg({'No': 'count'})\n",
"display(df_unit_ratio)"
],
"execution_count": 4,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>No</th>\n",
" </tr>\n",
" <tr>\n",
" <th>UnitRatio</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>-100.0</th>\n",
" <td>38</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-90.0</th>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-80.0</th>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-70.0</th>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-60.0</th>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-50.0</th>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-40.0</th>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-30.0</th>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-20.0</th>\n",
" <td>15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>-10.0</th>\n",
" <td>80</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0.0</th>\n",
" <td>125</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10.0</th>\n",
" <td>63</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20.0</th>\n",
" <td>17</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30.0</th>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40.0</th>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>70.0</th>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>90.0</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>100.0</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>110.0</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120.0</th>\n",
" <td>2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" No\n",
"UnitRatio \n",
"-100.0 38\n",
"-90.0 3\n",
"-80.0 3\n",
"-70.0 2\n",
"-60.0 4\n",
"-50.0 6\n",
"-40.0 5\n",
"-30.0 5\n",
"-20.0 15\n",
"-10.0 80\n",
" 0.0 125\n",
" 10.0 63\n",
" 20.0 17\n",
" 30.0 3\n",
" 40.0 6\n",
" 70.0 3\n",
" 90.0 1\n",
" 100.0 1\n",
" 110.0 1\n",
" 120.0 2"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "Kq-naoJYdlNm",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 542
},
"outputId": "3cf3edae-8f61-412f-e7f4-de5992556207"
},
"source": [
"import plotly\n",
"import plotly.graph_objs as go\n",
"import plotly.io as pio\n",
"pio.renderers.default = 'colab'\n",
"#plotly.__version__\n",
"\n",
"data = [\n",
" go.Bar(\n",
" x=df_unit_ratio.index.values,\n",
" y=df_unit_ratio.No.values,\n",
" ),\n",
"]\n",
"\n",
"layout = go.Layout(\n",
" title='Profit / loss ratio distribution',\n",
" xaxis=dict(\n",
" title='Ratio (%)'\n",
" ),\n",
" yaxis=dict(\n",
" title='Count'\n",
" )\n",
")\n",
"\n",
"fig = go.Figure(data=data, layout=layout)\n",
"plotly.offline.iplot(fig)\n",
"#fig.show()"
],
"execution_count": 5,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<html>\n",
"<head><meta charset=\"utf-8\" /></head>\n",
"<body>\n",
" <div>\n",
" <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>\n",
" <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
" <script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></script> \n",
" <div id=\"65a8f7e0-224a-4e1c-8f57-4b39b63d837b\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>\n",
" <script type=\"text/javascript\">\n",
" \n",
" window.PLOTLYENV=window.PLOTLYENV || {};\n",
" \n",
" if (document.getElementById(\"65a8f7e0-224a-4e1c-8f57-4b39b63d837b\")) {\n",
" Plotly.newPlot(\n",
" '65a8f7e0-224a-4e1c-8f57-4b39b63d837b',\n",
" [{\"type\": \"bar\", \"x\": [-100.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 70.0, 90.0, 100.0, 110.0, 120.0], \"y\": [38, 3, 3, 2, 4, 6, 5, 5, 15, 80, 125, 63, 17, 3, 6, 3, 1, 1, 1, 2]}],\n",
" {\"template\": {\"data\": {\"bar\": [{\"error_x\": {\"color\": \"#2a3f5f\"}, \"error_y\": {\"color\": \"#2a3f5f\"}, \"marker\": {\"line\": {\"color\": \"#E5ECF6\", \"width\": 0.5}}, \"type\": \"bar\"}], \"barpolar\": [{\"marker\": {\"line\": {\"color\": \"#E5ECF6\", \"width\": 0.5}}, \"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.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.0, \"#f0f921\"]], \"type\": \"contour\"}], \"contourcarpet\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"type\": \"contourcarpet\"}], \"heatmap\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"heatmap\"}], \"heatmapgl\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"heatmapgl\"}], \"histogram\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"histogram\"}], \"histogram2d\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"histogram2d\"}], \"histogram2dcontour\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"histogram2dcontour\"}], \"mesh3d\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"type\": \"mesh3d\"}], \"parcoords\": [{\"line\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"parcoords\"}], \"pie\": [{\"automargin\": true, \"type\": \"pie\"}], \"scatter\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"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.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.0, \"#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}, \"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.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.0, \"#f0f921\"]], \"sequentialminus\": [[0.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.0, \"#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\": \"Profit / loss ratio distribution\"}, \"xaxis\": {\"title\": {\"text\": \"Ratio (%)\"}}, \"yaxis\": {\"title\": {\"text\": \"Count\"}}},\n",
" {\"responsive\": true}\n",
" ).then(function(){\n",
" \n",
"var gd = document.getElementById('65a8f7e0-224a-4e1c-8f57-4b39b63d837b');\n",
"var x = new MutationObserver(function (mutations, observer) {{\n",
" var display = window.getComputedStyle(gd).display;\n",
" if (!display || display === 'none') {{\n",
" console.log([gd, 'removed!']);\n",
" Plotly.purge(gd);\n",
" observer.disconnect();\n",
" }}\n",
"}});\n",
"\n",
"// Listen for the removal of the full notebook cells\n",
"var notebookContainer = gd.closest('#notebook-container');\n",
"if (notebookContainer) {{\n",
" x.observe(notebookContainer, {childList: true});\n",
"}}\n",
"\n",
"// Listen for the clearing of the current output cell\n",
"var outputEl = gd.closest('.output');\n",
"if (outputEl) {{\n",
" x.observe(outputEl, {childList: true});\n",
"}}\n",
"\n",
" })\n",
" };\n",
" \n",
" </script>\n",
" </div>\n",
"</body>\n",
"</html>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "VxCGz1lTf3l-",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 542
},
"outputId": "53f08775-5452-4b75-b179-7bbd7e3e8668"
},
"source": [
"data = [\n",
" go.Histogram(\n",
" x=df_rank.PnlBTC.values,\n",
" ),\n",
"]\n",
"\n",
"layout = go.Layout(\n",
" title='Profit / loss BTC distribution',\n",
" xaxis=dict(\n",
" title='BTC'\n",
" ),\n",
" yaxis=dict(\n",
" title='Count'\n",
" )\n",
")\n",
"\n",
"fig = go.Figure(data=data, layout=layout)\n",
"plotly.offline.iplot(fig)\n",
"#fig.show()"
],
"execution_count": 6,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"<html>\n",
"<head><meta charset=\"utf-8\" /></head>\n",
"<body>\n",
" <div>\n",
" <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>\n",
" <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
" <script src=\"https://cdn.plot.ly/plotly-latest.min.js\"></script> \n",
" <div id=\"0c805f93-4f7a-476f-9a61-fea32d86794b\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>\n",
" <script type=\"text/javascript\">\n",
" \n",
" window.PLOTLYENV=window.PLOTLYENV || {};\n",
" \n",
" if (document.getElementById(\"0c805f93-4f7a-476f-9a61-fea32d86794b\")) {\n",
" Plotly.newPlot(\n",
" '0c805f93-4f7a-476f-9a61-fea32d86794b',\n",
" [{\"type\": \"histogram\", \"x\": [0.11787565, 0.11566629, 0.11130152, 0.09400276, 0.089795, 0.07127777, 0.06688296, 0.06412532, 0.03921404, 0.04594002, 0.03230609, 0.03198913, 0.03461313, 0.03058938, 0.0298422, 0.05785685, 0.02727988, 0.01977715, 0.02073503, 0.01771233, 0.01656658, 0.01636199, 0.02069217, 0.01757942, 0.01476884, 0.01397624, 0.01344301, 0.01294378, 0.01205084, 0.01175898, 0.02009782, 0.0104991, 0.15842113, 0.01020473, 0.01154447, 0.00942766, 0.00891785, 0.00747935, 0.00681104, 0.0066646, 0.00765047, 0.01678436, 0.00573675, 0.00558686, 0.00535017, 0.00480607, 0.00499537, 0.00451687, 0.00428832, 0.01688123, 0.0038732, 0.1914624, 0.00317925, 0.00306085, 0.00335223, 0.00297057, 0.00511625, 0.00281941, 0.0029013, 0.00269644, 0.00265183, 0.00435663, 0.00263774, 0.00250638, 0.00209921, 0.00213656, 0.00578919, 0.00179951, 0.00176878, 0.00194702, 0.00143051, 0.00162533, 0.00138713, 0.00120229, 0.00116501, 0.00105379, 0.00105007, 0.0009953, 0.00074707, 0.00079454, 0.00056242, 0.00045166, 0.00037866, 0.0002503, 0.00029283, 0.00023717, 0.00020416, 0.00021191, 0.00022887, 9.227e-05, 5.531e-05, 4.52e-05, 3.111e-05, 2.539e-05, 2.308e-05, 1.033e-05, 1.009e-05, 9.2e-07, 1.9e-07, 1.7e-07, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5e-08, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -9e-08, -4.2e-07, -5.8e-07, -5.5e-07, -1.47e-06, -1.66e-06, -2.24e-06, -1.78e-06, -2.99e-06, -4.64e-06, -1.467e-05, -1.794e-05, -1.998e-05, -2.565e-05, -0.00014882, -3.404e-05, -4.126e-05, -6.03e-05, -8.108e-05, -0.00010147, -8.88e-05, -0.00012264, -0.00065069, -0.0001454, -0.00015521, -0.00019195, -0.00023614, -0.00023951, -0.00043402, -0.00026972, -0.00029994, -0.00077691, -0.00032694, -0.00043569, -0.00055238, -0.00049367, -0.00051705, -0.00051851, -0.00054495, -0.00063405, -0.00069274, -0.00072825, -0.00816836, -0.0066315, -0.00089099, -0.0011664, -0.00105168, -0.00114928, -0.00123895, -0.00133536, -0.00128326, -0.00140658, -0.00141424, -0.00204256, -0.00161322, -0.00755722, -0.00159302, -0.00162844, -0.00226973, -0.00180806, -0.00197004, -0.00314804, -0.00234038, -0.02722316, -0.02540002, -0.00279449, -0.00310044, -0.00317199, -0.0492625, -0.00412668, -0.00407227, -0.00409967, -0.00448632, -0.0072822, -0.00593577, -0.01052728, -0.00595566, -0.00661205, -0.00630457, -0.00637428, -0.00704432, -0.00762178, -0.00792977, -0.00720469, -0.00723337, -0.00741734, -0.00802126, -0.00814132, -0.00894459, -0.00987293, -0.01048416, -0.01152186, -0.06577409, -0.01189773, -0.01978313, -0.01587582, -0.01477959, -0.8008, -0.01444447, -0.09792979, -0.0225742, -0.01582193, -0.12470634, -0.01784756, -0.02059723, -0.02224991, -0.02604676, -0.18027504, -0.26271952, -0.03518793, -0.0306914, -0.03613101, -0.04041013, -0.08318524, -0.03727333, -0.04335221, -0.04481675, -0.04590162, -0.04441809, -0.66423553, -0.06521405, -0.07206125, -0.06416975, -0.05752253, -0.11890256, -0.09371473, -0.06283895, -0.0853096, -0.07930106, -0.08156362, -0.08731369, -0.09693519, -0.0915804, -0.2531842, -0.10819763, -0.2375366, -0.09721556, -0.09896505, -0.10474403, -0.10065084, -0.100197, -0.13587632, -0.22267136, -0.10811958, -0.14967708, -0.09990918, -0.09991033, -0.10449955, -0.11296746, -0.09994532, -0.10169896, -0.10983876, -0.10890978, -0.11493422, -0.29635325, -0.10299737, -0.1159119, -0.09999989, -0.09999999, -1.64405807, -0.1, -0.1, -0.1, -0.10432061, -0.1, -0.12572714, -0.09999998, -0.1623611, -0.1, -0.10072674, -0.1]}],\n",
" {\"template\": {\"data\": {\"bar\": [{\"error_x\": {\"color\": \"#2a3f5f\"}, \"error_y\": {\"color\": \"#2a3f5f\"}, \"marker\": {\"line\": {\"color\": \"#E5ECF6\", \"width\": 0.5}}, \"type\": \"bar\"}], \"barpolar\": [{\"marker\": {\"line\": {\"color\": \"#E5ECF6\", \"width\": 0.5}}, \"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.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.0, \"#f0f921\"]], \"type\": \"contour\"}], \"contourcarpet\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"type\": \"contourcarpet\"}], \"heatmap\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"heatmap\"}], \"heatmapgl\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"heatmapgl\"}], \"histogram\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"histogram\"}], \"histogram2d\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"histogram2d\"}], \"histogram2dcontour\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"colorscale\": [[0.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.0, \"#f0f921\"]], \"type\": \"histogram2dcontour\"}], \"mesh3d\": [{\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}, \"type\": \"mesh3d\"}], \"parcoords\": [{\"line\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"type\": \"parcoords\"}], \"pie\": [{\"automargin\": true, \"type\": \"pie\"}], \"scatter\": [{\"marker\": {\"colorbar\": {\"outlinewidth\": 0, \"ticks\": \"\"}}, \"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.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.0, \"#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}, \"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.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.0, \"#f0f921\"]], \"sequentialminus\": [[0.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.0, \"#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\": \"Profit / loss BTC distribution\"}, \"xaxis\": {\"title\": {\"text\": \"BTC\"}}, \"yaxis\": {\"title\": {\"text\": \"Count\"}}},\n",
" {\"responsive\": true}\n",
" ).then(function(){\n",
" \n",
"var gd = document.getElementById('0c805f93-4f7a-476f-9a61-fea32d86794b');\n",
"var x = new MutationObserver(function (mutations, observer) {{\n",
" var display = window.getComputedStyle(gd).display;\n",
" if (!display || display === 'none') {{\n",
" console.log([gd, 'removed!']);\n",
" Plotly.purge(gd);\n",
" observer.disconnect();\n",
" }}\n",
"}});\n",
"\n",
"// Listen for the removal of the full notebook cells\n",
"var notebookContainer = gd.closest('#notebook-container');\n",
"if (notebookContainer) {{\n",
" x.observe(notebookContainer, {childList: true});\n",
"}}\n",
"\n",
"// Listen for the clearing of the current output cell\n",
"var outputEl = gd.closest('.output');\n",
"if (outputEl) {{\n",
" x.observe(outputEl, {childList: true});\n",
"}}\n",
"\n",
" })\n",
" };\n",
" \n",
" </script>\n",
" </div>\n",
"</body>\n",
"</html>"
]
},
"metadata": {
"tags": []
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment