python-pour-finance/11-Quantopian-Avancé/03-Analyse-Portefeuille-ave...

879 lines
778 KiB
Plaintext
Raw Permalink Normal View History

2023-08-21 15:12:19 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Analyse de Portefeuille avec PyFolio"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pyfolio as pf\n",
"import matplotlib.pyplot as plt\n",
"import empyrical"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Définir un algorithmique de benchmark pour SPY"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def initialize(context):\n",
" context.spy = sid(8554)\n",
"\n",
" \n",
" set_max_leverage(1.01)\n",
" \n",
" schedule_function(rebalance,date_rules.every_day(),time_rules.market_open())\n",
" \n",
"def rebalance(context,data):\n",
" order_target_percent(context.spy,1)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100% Time: 0:00:02|##########################################################|\n"
]
}
],
"source": [
"# Obtenir les rendements du benchmark\n",
"benchmark_rets = get_backtest('5ea05f494e836745cf5adb9f')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"bm_returns = benchmark_rets.daily_performance['returns']\n",
"bm_positions = benchmark_rets.pyfolio_positions\n",
"bm_transactions = benchmark_rets.pyfolio_transactions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Utiliser l'algorithme de la vidéo 'Effet de Levier'"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100% Time: 0:00:00|##########################################################|\n"
]
}
],
"source": [
"# Utiliser le même algorithme que la vidéo 'Effet de Levier'\n",
"bt = get_backtest('5ea0559950e04245b1a90ff4')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"bt_returns = bt.daily_performance['returns']\n",
"bt_positions = bt.pyfolio_positions\n",
"bt_transactions = bt.pyfolio_transactions"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f63db9fa128>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzwAAAHLCAYAAAAN/p1mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvXmUJHd17/nNjFwqa+9ae29JLam1NXKrBR5GWBLnNcb2\nkz02Z4wlw/EZxmOe4bw5thl8jgFbsg/IsvETmPew2YUxNjQyIIyxsEBoQVZLSOputaTe1+qqru7a\nt9wzlvkj4kb8IjIiMyJyqcyq+/mnl1oyMjLiF7977/d+b0TTNA0MwzAMwzAMwzBrkOhqHwDDMAzD\nMAzDMEyj4ICHYRiGYRiGYZg1Cwc8DMMwDMMwDMOsWTjgYRiGYRiGYRhmzcIBD8MwDMMwDMMwaxYO\neBiGYRiGYRiGWbPEwv7gQw89hCNHjiASieCjH/0odu/ebX7twIED+PSnPw1JknDnnXfigx/8IPL5\nPP7kT/4Ec3NzKBaL+MAHPoC77767Hu+BYRiGYRiGYRjGlVABz8svv4yxsTHs378fZ8+exUc+8hE8\n+uij5tcffPBBPPLIIxgZGcF9992Hd77znTh58iR2796N3/3d38Xk5CTe9773ccDDMAzDMAzDMExD\nCRXwvPDCC9i3bx8AYOfOnVheXkYmk0FXVxfGx8fR39+P0dFRAMDdd9+NF198Ee95z3vMn5+cnMSm\nTZvqcPgMwzAMwzAMwzDehAp4Zmdnccstt5j/HhwcxOzsLLq6ujA7O4uBgQHza0NDQxgfHzf/fe+9\n92J6ehqf//znazhshmEYhmEYhmGY6oQKeDRNK/t3JBKp+jUA2L9/P06cOIEPf/jD+P73v1/1tQ4e\nPBjmEBmGYRiGYRiG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ib.figure.Figure at 0x7f63dbacea90>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"bt_returns.plot()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.14140644478845052"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"empyrical.beta(bt_returns,bm_returns)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Graphiques PyFolio"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"benchmark_rets = bm_returns"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA+QAAAI0CAYAAACUFOOKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl8VfWZ+PHPuWuWe7PvO0kgIYGwBEGUFhBtqXWpddwV\nsVZbqx3npZ1ObcfaKk79aZdpnXFay9QqRa1bW1wqItYNESQBAgGSkJCE7Dc3+703dz2/PzI5cE0I\nIWQDnvfrlRf37M+5OSjP+X6/z1dRVVVFCCGEEEIIIYQQk0o31QEIIYQQQgghhBDnIknIhRBCCCGE\nEEKIKSAJuRBCCCGEEEIIMQUkIRdCCCGEEEIIIaaAJORCCCGEEEIIIcQUkIRcCCGEEEIIIYSYAlOW\nkFdWVnLJJZewcePGIds+/fRTrrvuOm688UZ+9KMfAVBeXs7y5ctZs2YNt9xyC+vWrZvskIUQQggh\nhBBCiHFjmIqLulwu1q1bx9KlS4fd/tBDD7FhwwYSEhK49957+fDDDwkNDWX16tU88MADkxytEEII\nIYQQQggx/qakhdxsNrN+/XoSEhKG3f7aa69p22JiYujq6sLhcKCq6mSGKYQQQgghhBBCTJgpSch1\nOh0mk+mE28PDwwFoa2vjk08+Yfny5TidTkpKSrjzzju55ZZb2LFjx2SFK4QQQgghhBBCjLsp6bI+\nGna7nb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RbKzs3nuued47rnn+N73vsd///d/n9LxiqIMWff000+fchyffvop+/bt\nO+XjhBBCCCGEEGI68wV8PL/neTpdnQCY9CZunn/zSacyS4tMI8maBIDX7+WTuk8mLEbpsj5FVFXV\nPttsNpKSkjh06BAPP/wwRqMRnU7Hr3/9ayIiIvj973/PO++8g16v57777iM1NVU79oMPPuD5559n\n0aJFVFRU8M///M/85je/4Ve/+hWlpaX4/X5uvvlmLr30Uj7++GN+/etfExISQlxcHA8++CBPPvkk\nRqORlJQUVq5cORVfhRBCCCGEEEKMK1VV+Wv5X6nrqgMGGjSvnXstKREpJz1WURRWZq/khb0vALC9\nfjvLMpcRZgob9zjP6YT849qP2Vq9FY/fM27nNOlNrMpZxbKsZSPud+TIEdasWYPb7aatrY3169fT\n2trKj3/8Y/Lz8/nNb37D66+/zrJly9iyZQsvv/wy9fX1/P73v+fb3/42APX19fz2t79l/fr1hIeH\n84c//IHf/OY37Nq1i6amJjZs2IDH4+HrX/86q1atYuPGjfzgBz+guLiYd999F1VV+frXv050dLQk\n40IIIYQQQoizxoe1H7K7ebe2/OWZXw6a0uxkChMKSbQk0trXisfvYVv9Ni7JvWTc4zy3E/K6j8c1\nGQfw+D18XPfxSRPywS7rADU1Ndx77738/Oc/5+c//zn9/f20tbVx+eWXc+DAAYqKigDIyMjgkUce\nobGxEafTyd13383jjz9OeHh40Ll3795NWVkZa9as0VribTYbq1ev5qGHHuKKK67g0ksvJTY2dlzv\nXQghhBBCCCGmWnlrOe9UvaMtF6cWsyxz5Pzs8xRFYUX2Cv5c9mfgWCt5qDF0PEM9t8eQL8tchklv\nGtdzmvSmU/5lZ2dnExISwqOPPsratWvZsGED1113HQAGg4FAIDDkmJaWFhYtWsTGjRuHbDMajVx9\n9dU899xzbNiwgTfeeIO0tDSuvPJKnnvuOaKiorjrrruoqakZ200KIYQQQgghxDShqip9nj6ae5sp\naynj5X0va9tmRM/gitlXDFuD62TmJM4hPjweALfPzSf14z+W/JxuIV+WteykLdkT5fgx5F1dXdhs\nNsLDw0lPT8fj8fDBBx8
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63db5427b8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Rendements cumulés\n",
"plt.subplot(2,1,1)\n",
"pf.plotting.plot_rolling_returns(bt_returns, benchmark_rets)\n",
"\n",
"# Rendements non cumulés, quotidiens\n",
"plt.subplot(2,1,2)\n",
"pf.plotting.plot_returns(bt_returns)\n",
"plt.tight_layout()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABCcAAAF3CAYAAACWgyH0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl8TXf+x/H3vVmRoIjEUm2H+lmKEold1BZLqVAatZRq\njVGl7ZQOVTGW2qpK0VbVqLQV1aD2KK3SGhrRqqHakS6WEGsSJJrt/v6InElkJ8lJrtfz8cjD2e73\nfM698b3ffM73fL8Wm81mEwAAAAAAgEmsZgcAAAAAAADubiQnAAAAAACAqUhOAAAAAAAAU5GcAAAA\nAAAApiI5AQAAAAAATEVyAgAAAAAAmIrkBEqEwMBA9enTx7Tzr1+/XsOHD7+jMi5duqQvv/yykCIC\nYE/q1asnf39/devWTR06dNCoUaP0ww8/GPvffPNNrVmzJtcyvvnmG507dy7bfR9//LEWLVokSerY\nsaMOHTpUoPgy1l8//vijnnnmmQK9/na9/PLLeuSRR/Ttt98Wy/nSbd26VdevX5ckTZw4Ue+++262\nx9WrV0/R0dFFEsPatWuLpFwAJUe9evU0bty4LNsnTZqkevXq3VHZP/74o3755RdJubdjhwwZok2b\nNt3RuXKS2/dSUbt+/bp69eqlyMhIrV27Vl26dNHgwYN17do145hDhw5pzJgxxnpISIgmTJhgRrjI\nJ5ITMN2JEydUvnx5VatWTYcPHzYtDovFckev379/P8kJANmyWCwKDg7W9u3btXv3bvXp00ejRo3S\nwYMHJUkvvfSSnnjiiVzLWLlypc6cOZPtvkGDBmns2LG3HV/G+qtx48Zavnz5bZdVEFu3btWqVavU\npk2bYjlfurfffjtTAzYnd/q9kJOUlBTNnTu3SMoGULL8/PPPRjJUkpKSknT06NE7rl9CQ0N1/Phx\nY72o6qvc5Pa9VNTmzZun3r1764EHHtD777+vzZs3q3379goNDZUkpaamau7cuZo0aZLxmsDAQJ09\ne5b2eglGcgKmW7dunbp3765evXpp/fr1xvYzZ86obdu2Cg4OVq9eveTn56dt27ZJSssQjxs3Tq++\n+qr8/f316KOPKjIyUlLWDHHG9V27dqlXr17y9/dXv379MlXq2fnuu+8UGBioF198UePHj89URpcu\nXTRixAjFxMTo2LFjmj59unbs2KG///3v+u6779S1a9dM5aSvL168WK+99poGDBigVatW5Xot3333\nnfr27atHH31UPXv21Pbt2+/07QZgApvNJpvNZqx369ZNzz33nObPny8p8937jz76SD169FD37t01\nYMAAnThxQgsXLtT+/fs1fvx4bdu2LUs9kr6e7t///rcCAgL0yCOP6K233pKkHOuln376Kcf6KzEx\nUUFBQerWrZt69uypOXPmGNfRsWNHrVmzRv3791e7du00Z86cbK/97NmzGjFihLp166ZevXrp888/\nl5RWN6empuqZZ57Rnj17Mr1m/fr1Gjt2rNGz4umnn9bBgwcVGBiotm3bGr0ObDabFixYoO7du6tH\njx6aOHGibty4YZS/cuVKPfnkk2rfvr3+/ve/S0q7Y/nbb79p6NChRg+TmJgYjRw5Uo888ohGjBih\n+Ph4I5bU1FS1bdtWR48eNbZ99NFHev7557Nca8eOHbVkyRJ1795d586dU3R0tEaNGmX0mtm7d68k\n6emnn9bVq1fVo0cPnT59Oktvl/T1M2fOqF27dpo1a5aGDBkiKe1O7Oeff66AgAC1a9dOK1eulCTF\nx8drzJgx6tGjh7p06aIpU6YoJSUl288EQPFp0aKFvvjiC2P9m2++UaNGjTIds23bNvXq1Us9evTQ\nsGHDdOrUKUlpbcbp06drzJgx6ty5swYMGKCLFy8qJCREn3/+ud544w2jDrDZbJo+fbr8/f3Vq1cv\nnThxItM5xo4dqxUrVhjrv/zyi1q1aqXU1NRMx02cOFGzZ8/WY489prCwMCUlJWnGjBny9/dXp06d\ntGzZMknK8r10ay+0jOu31o051c+StGDBAnXr1k3dunXTsGHDdOHChSzvaXR0tMLCwvTkk0/q4sWL\nqlSpklxcXNSgQQOjDR0cHKwOHTqoevXqmV777LPPavHixbl8YjATyQmYKjU1VTt37pS/v786duyo\nPXv2KCkpydgfExMjBwcHbdq0SRMnTjQa2ZK0Z88eDR48WGFhYfL19dWHH36Y67lSUlI0adIkzZw5\nU2FhYerYsWO+7lz99NNPGjhwoObNm6dz585p0qRJeuutt/TFF1+oRYsWmjJliho0aKDBgwfL39/f\n+GPj1gx2xvU9e/bo/fff19ChQ3O9lvSM7+bNm/XOO+9o586decYLoHTo2bOnfvzxRyUmJhrbrl+/\nrkWLFik0NFTbtm3TiBEj9PXXX2vcuHGqWrWq5s+fr+7du0vKWo9kdOzYMa1fv16hoaFavXq1fv75\nZ0nZ10v169fPsf5auXKloqOjtW3bNq1bt04HDx7U5s2bjdcfPHhQa9euVWhoqIKDg7N9BOK1115T\ny5YttX37dr333nuaMWOGoqKiFBwcLCmtAdm+ffssr/v22281duxY7dixQ5GRkVqxYoVWr16tGTNm\naMmSJZLSel7s3btXGzZs0NatWxUXF2c01CXpq6++0sqVKxUWFqb9+/fr+++/1+uvv26ct1mzZsa5\n5s+fr127duny5ctGXWuz2WS1WtW9e/dMSe+dO3eqR48eWT9UyXi/vLy8FBQUpIYNGyosLEzvv/++\nXn75ZcXGxur111+Xo6Ojtm7dqpo1a2ZbTrorV66oQYMGxvslSZGRkVq/fr2WLl2qBQsWyGazaf36\n9Spfvry2bt2qsLAwOTg46L///W+uZQMoerfWH5s3bzbqcUmKiorSlClTtHTpUm3dulV+fn6aMmWK\nsT8sLEyTJ0/Wzp07ValSJYWGhiowMFCNGjXShAkTNGzYMElpj3k8/vjjRlsyY10oSb17985Uf6e3\nv63WrH8O7t+/X5999pn8/f21atUq/frrr9qyZYu2bNmi7du35/i9lJuMdaOUff184sQJbd++XVu3\nbtX27dvVpUsX7du3L0tZu3btkre3t8qVKyer1WokzVNSUuTg4KCLFy9q06ZN8vHx0ahRo4y6V5La\ntGmjP/74w0gAoWQhOQFT7d27V40aNVLZsmXl6uoqX19f7d6929ifkpKivn37SpIaNmyos2fPGvvq\n1Kmj+vXrS5IaNGigqKioXM/l4OCgffv2qXHjxpIkb2/vfFVM6XFJ0pdffqlGjRqpdu3aktK6h335\n5ZeZ7ojmR5MmTVShQoU8r6Vy5crasGGDfv31V9WqVUtvvPFGgc4DoORyc3NTampqpscLXFxcZLFY\ntHbtWl26dEn+/v4aMWKEsT9jXXNrPZJRr169JEmVKlWSj49PpvEtCuLrr7/WgAEDZLFY5OLiol69\nemUaH+LRRx+VJFWtWlVVqlTJ8uxxcnKy9u3bp4EDB0qSqlevrhYtWmj//v3ZXlNGderUUa1ateTk\n5KT77rtPbdq0kcViUd26dY07aV9//bUCAgLk4uIiSerbt2+m+Pz9/eXs7KwyZcro/vvvz/QdkvG8\nfn5+cnd3l9Vq1YMPPpjlOnr27KmtW7dKkmJjY3X06FE98sgj2cadvj0hIUFff/21ce333nuvmjdv\nnuk7Lj9SUlLUuXPnTNsee+wxSWnfi4mJibp06ZIqV66sH374Qd9++62Sk5MVFBR0x8+0A7gzFotF\nLVq00IkTJ3T58mX9+eefOnz4sFq2bGnUQfv27VPLli117733SpL69++v7777zuj51Lx5c+MP+vr1\n62dq72asx2rXrm20JevXr5+lHmvfvr1Onjyp33//XVLuSdZWrVrJyclJkrR9+3Y9/vjjcnR0lKur\nqx577DHt2LEj2xhyc2udmV397O7urpiYGH3++eeKi4vToEGDjPouoyNHjhi9T6pUqaKrV68qNjZW\n4eHhatiwoebMmaMXXnh
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63dbe5d358>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(1)\n",
"plt.subplot(1,3,1)\n",
"pf.plot_annual_returns(bt_returns)\n",
"plt.subplot(1,3,2)\n",
"pf.plot_monthly_returns_dist(bt_returns)\n",
"plt.subplot(1,3,3)\n",
"pf.plot_monthly_returns_heatmap(bt_returns)\n",
"plt.tight_layout()\n",
"fig.set_size_inches(15,5)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzwAAAHrCAYAAAAKUphQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+813V9///7OQc5yI9Ufh2XFStbugkiorKJvyoSU5am\nIojhEsrt0uyyycrCTDfTC0Y5ZyMqC2aajPwRzZE/UgsthKnA8KCXtkVTERpw+KFyQPDI+/sHH95f\n0MOvN8j7nBfX6z++3+f1/vF4UefN+8bz9X69a0qlUikAAAAFVFvtAQAAAN4pggcAACgswQMAABSW\n4AEAAApL8AAAAIUleAAAgMLqUO0BAGgbjj766PTp0yd1dXUplUrZvHlzTjzxxFxzzTXp1KnTTu/7\n61//Oh/84Adz+OGH76dp3znb7ss//uM/5ogjjsiIESNy9NFH5/HHH09DQ0O1RwRgD1jhASBJUlNT\nkzvvvDMPPPBAHnzwwcycOTNr167Nd7/73V3e9/bbb8/SpUv3w5TvvG33Zdy4cRkxYkSSLX8+ALQ/\nVngASJKUSqVs+13UBx10UE499dT88pe/TJK88cYb+frXv55f/epXaWlpyYgRI3L55Zfn1ltvzdy5\nc/O73/0uX/ziF/PEE0+kT58++au/+qskyfjx48vXP/KRj+SCCy7IzJkz8y//8i/54he/mI9+9KP5\n+c9/npdffjknnnhibr755rfNtmTJkowbNy5r167NcccdlzVr1mTYsGE58cQTc+aZZ+a5555Lkixd\nurR8vVQq5frrr8+cOXPS0tKS448/PhMmTEhdXV3Gjx+fd7/73VmwYEFeeOGFvP/978+3v/3tfO97\n39vhvmz7Z3P33XfnX/7lX7Jp06Ycd9xxmTBhQjp27JinnnoqN910UzZt2pRSqZTPf/7zOeuss97J\n/9kA2AUrPAC06pVXXsnMmTNz/PHHJ0nuuOOO/O53v8vPfvaz/OxnP8tDDz2Uxx9/PH/zN3+T3r17\n5+abb87HP/7xXT7u8uXL8+CDD5YPf/vlL3+Z22+/PQ8//HDmzp2bBQsWvO0+3/jGN3LyySfnkUce\nySWXXJK5c+eWt7115WXr9UceeSTz58/PAw88kAceeCDPPfdcHnjggfLtHn744dx666159NFHs2rV\nqjz66KO7tS/PPvtsvvWtb+XOO+/MY489lm7duuWf/umfkiQTJ07M1VdfnZkzZ+Y73/lOHn300V3+\neQDwzhI8AJRdeumlOfvsszNkyJAMGTIkJ598cj7zmc8kSR566KFceOGF6dChQzp16pRzzz03P//5\nz8v33XYFZGc+/OEPb3d96NCh6dixYw4++OD84R/+YX7/+9+/7T7z588vB8hxxx2XPn367PJ5zjzz\nzNx3332pra1Nx44d069fvyxZsqS8/fTTT0+3bt1SW1ubD33oQ1m2bNlu7cvDDz+cj370o+nZs2eS\nZMSIEeU/hx49euSnP/1pfve73+V973tfvvnNb+5yTgDeWQ5pA6DszjvvTO/evbNmzZqcddZZ+fjH\nP57a2i3/Nvbqq6/mm9/8ZiZNmpRSqZQ33ngj/fv33+PnOOSQQ7a73q1bt/Ll2travPnmm2+7z9q1\na/Oud72rfL179+67fJ7Vq1fnhhtuyHPPPZfa2tqsWrUql156aavPW1dXl82bN+/W/K+99loeeeSR\nPP3000mSN998szzzhAkTMnny5Fx22WXp1KlTxo0bl6FDh+7W4wLwzhA8AJRtXdk47LDDMnr06Eyc\nODGTJ09OkvTu3Tuf+cxncvrpp+/0Md4aLWvXrt2tFZmdede73pXXXnutfH3NmjVJtoTKW59rq1tu\nuSUHHXRQfvazn6VDhw75whe+sFczbNW7d+988pOfzFVXXfW2bd27d88111yTa665JrNnz84VV1yR\n0047LQcffPA+eW4A9pxD2gBo1WWXXZb//M//zDPPPJMk+ehHP5q77747mzdvTqlUyne+8538+te/\nTrLlBAdbg6RXr175r//6ryRbTjY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hoZ07tw5SXLEEUekubk5y5YtS0tLS2bN\nmpVTTjklffr0yX/+538mSZYuXZouXbrsMnYAAAAqVfEKz4ABA3LMMcdk5MiRqaury7XXXpsZM2ak\nW7duGTJkSK677rqMGzcuSTJs2LD06dMnI0aMyNVXX53Ro0fnzTffzPXXX7/PdgQAAOCt9up7ePaH\nefPmOaQNAADYoZ01g+PJAACAwhI8AABAYQkeAACgsAQPAABQWIIHAAAoLMEDAAAUluABAAAKS/AA\nAACFJXgAAIDCEjwAAEBhCR4AAKCwBA8AAFBYggcAACgswQMAABSW4AEAAApL8AAAAIUleAAAgMIS\nPAAAQGEJHgAAoLAEDwAAUFiCBwAAKCzBAwAAFJbgAQAACkvwAAAAhSV4AACAwhI8AABAYQkeAACg\nsAQPAABQWIIHAAAoLMEDAAAUluABAAAKS/AAAACFJXgAAIDCEjwAAEBhCR4AAKCwBA8AAFBYggcA\nACgswQMAABSW4AEAAApL8AAAAIUleAAAgMISPAAAQGEJHgAAoLAEDwAAUFiCBwAAKCzBAwAAFJbg\nAQAACqtDtQcAAGD/mDp1ambPnl3tMfaZdevWJUm6du1a5Un2ncGDB2fMmDHVHqNQrPAAANAuvf76\n63n99derPQZtnBUeAIADxJgxYwq1ejB27NgkyZQpU6o8CW2ZFR4AAKCwBA8AAFBYggcAACgswQMA\nABSW4AEAAAqr4uCZMGFCRo4cmYsvvjiNjY3bbXvyySczfPjwjBw5MpMnTy7//P7778+5556bCy64\nIE888UTlUwMAAOyGik5L/fTTT+fFF1/M9OnTs3jx4owfPz533313efuNN96YqVOnpnfv3rn44osz\ndOjQ9OjRI9/+9rfz05/
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63dc524240>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plot_return_quantiles(bt_returns);"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0gAAAHUCAYAAAAA3AjKAAAABHN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ua2tA/6xZs/TBBx9ozpw5GjBggObOnauNGze2Wr+JEyfqlVdeUVZWlqKjo/XMM89I\nku655x797Gc/05w5c2S32/WDH/xAY8eObfV509PTdffdd2vx4sXNut653W49+uij+uEPfyi/36+U\nlBQ9+uijbb6m8ePH67bbbtN3v/tdmaapUaNG6Wc/+1mr9Z4yZYqWL1+uTz/9VJGRkYF633333Xrk\nkUc0e/ZsGYahadOmaeTIkZKk2bNnKyMjQ4899pgWL16sf//3f1dCQoIyMjJ0/fXX68EHH9Rrr73W\nbJzP1KlT9fLLL+vaa6/V66+/rkceeaTD13Pie+RyufSb3/xGjz76qKqrq+V0OrV48WJJ0qRJk/TU\nU09p+vTpWr9+vX70ox/p+9//vtxutxYuXNjqtTuyaNEi3XffffJ6vZKkG264odlrAoAzmWF21GG6\nG+3Zs0d33nmnbrrpJt1www3Njm3YsEHPPPOM7Ha7ZsyYoTvuuEOStHTpUn3++ecyDEMPPfSQxo0b\n11vVBQBYXn31VW3atEm//e1vm+3PzMzUO++8o5deeukU1QwAgO7Va+3lNTU1euyxxwIz8Jzo8ccf\n13PPPacVK1Zo/fr12rdvn7Zs2aKDBw9q5cqVeuyxx9r8lQ0A0L2++uorXXrppSovL5fX69X777+v\nCRMmnOpqAQDQ43otILl
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63dd2540f0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plot_rolling_beta(bt_returns, benchmark_rets);"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0gAAAHUCAYAAAAA3AjKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xd8VFXex/HvpBEIJCEJCRggCioggkpYFJBqIDTXhhBU\nYO0+ysOqj8KCCooillW2uLgqsErRAArYKOuiICtRIYggIAoIRkJJb6Rnnj9uMiV1kkxmUj7v18sX\n5965c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6e/asNm/erPXr12vPnj365JNPHD7fsWPHtGHDBi1ZskSLFy+W2WzW\n9u3btXPnTm3atElLlizRhg0bKs0EXXLJJfLz89Mdd9yhTz/9VElJSTKZTAoJCbEcs3//fk2cOFFb\nt27VgAEDLIHQ66+/rq5du2rz5s3617/+pVdeecUSiEiyfKZOnTpJkr7//nutX79e77//vlatWqUj\nR47ozJkzmjt3rv7yl7/os88+09VXX6158+ZV+jnT0tJ02WWXaeXKlSouLtbcuXO1cOFCbd26VSNH\njtRLL70kSXr++ed1wQUXaNOmTfL29rZ87n379ulf//qXVq1apU2bNqlTp0565ZVXKlwnJydHu3bt\n0siRIyVJR44c0QUXXKA5c+YoOjpaDzzwgH777bcq78fOnTv11ltv6Z133tHSpUuVlpamjz/+WKNH\nj9bKlSslGcPgAgICtGXLFq1evVrvvfee3XA523v66quvymw2V/hcknTo0CGtWbPG8p2Wff+jR4/W\n9u3blZ+fX2U/AaA5IkACgCZi2rRpGjdunKKiohQVFaVBgwbpnnvukSTt2LFDkyZNkslkUqtWrXT9\n9dfrq6++cvjcN9xwgySpd+/eKigoUEpKiuLj4zV8+HD5+voqICBA48ePr/S9vr6+WrNmjfr27au/\n/e1vGjp0qCZPnqzdu3dbjunevbt69eolSerVq5fOnDkjSXryySf1xBNPSJK6dOmiDh06KCEhwfK+\nESNGVNrPoKAgRUZG6rvvvtPnn3+uPn36qHv37pKkmJgYff7555VmzoqLiy1ZHE9PT+3atUt9+/aV\nJEVGRtpduzI7duxQdHS02rdvL0maOHGidu3aVeG4gwcPKjw8XP7+/pKkzMxM7dmzR7fddpu2bt2q\nnj17atasWVVeZ/DgwWrVqpUuueQSlZSU6LrrrpMk9ejRQ+fOnZMkffnll7rtttskSQEBARo1apTd\nPa/snlam7L6GhoYqJCTEcm+Cg4MVEhKigwcPVvudAEBz4+XuDgAAHLNy5UqFhoYqLS1NY8aM0dix\nY+XhYfydKzU11fJjXJL8/f2r/EFcmbZt20qS5XzFxcXKzMxUWFiY5Rjbdnkd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TZ8+3TLv6Nlnn9WMGTNUVFQkPz8/zZ07t9Lr2Z5z6NCheu+99zRs2DB17dpVc+fO1YEDB/TQ\nQw/p5ZdfVkBAgAYPHqz169db3te3b1/de++9uu2222Q2m9WrVy89/fTTFa7Tu3dvnTp1SllZWWrX\nrp28vb315ptv6vHHH1dhYaEuuOACLVq0qNrvprI+23rkkUf09NNPa+zYsfL09NQDDzygyy+/vNL3\nlG336NGj0s9V2bVSU1OVnJxsOScAtBQmc2WzWBvAwYMH9eCDDyoiIkJms1k9evTQk08+aXl9165d\nWrx4sTw9PTV06FA9+OCDkqRFixbp+++/l8lk0ty5cy3jtwEArrV69Wp9/fXXduW1XWnkyJH685//\nbKnc19jde++9mjBhgqVYQlOzZs0a7dy507LQLQC0FC7LIJ0/f15jxozRnDlzKn194cKFWr58uUJD\nQzVlyhRFR0crNTVVJ0+
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63dc5241d0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plot_rolling_sharpe(bt_returns);"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0UAAAHUCAYAAAD1IoN6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl8VfWd//HXuWv2QBISMBGQRdmEICriUhRRWURHLYg4\nWmlHrY6OM9oZf46tK1aqdaZVp63VtlaqtY6otSpSbcedRaIYZAchC4SsZL256zm/P25yIWaXe7O+\nn4+HD5Nzzj3ncxeS88nn+/18DcuyLERERERERAYpW28HICIiIiIi0puUFImIiIiIyKCmpEhERERE\nRAY1JUUiIiIiIjKoKSkSEREREZFBTUmRiIiIiIgMakqKRET6ufvuu4/58+czf/58pkyZwpw5c5g/\nfz4LFizA4/FE5RrBYJAf//jHTJgwgcrKyhb7fvvb37JgwQLmz5/PvffeSygU6vR8r776KsuXL49K\nbB3ZuHEjF154YcyvE23XXnstO3fu7NZj7rrrLn71q1/FKCIRkYHN0dsBiIjIsbnvvvsiX59//vn8\n9Kc/Zfr06VG9xo033khubi6GYbTYvmnTJl588UVee+01EhISuPHGG3nhhRe45pprOj3n188VKz11\nnWh67rnnejsEEZFBRZUiEZEBxLIsvr4m94EDB/jud7/LvHnzWLRoEX/5y18AWLduHZdffjk//vGP\nI/u+/PLLNs972223cfPNN7c699q1a1m4cCEJCQkAXHnllaxZs6bV403T5N577+W8887jyiuvZNeu\nXZF9//7v/85PfvITLrnkEt59910aGxv5l3/5F+bNm8f555/PY489BsBjjz3Gk08+CYQrV9OnT+fV\nV18FoKqqijPOOAOAJ598knPPPZfLL7+c9evXR67j8/n40Y9+xLx581i4cCE//elPMU2T22+/ndde\new2A0tJSJkyYwMaNGwHIz8/n8ssvZ926dVx99dU8+uijLFiwgAsuuIC8vLxWz7Oj19Tv9/PAAw9w\n0UUXcf755/P0009HHjd79mx+8YtfMH/+fEpLS5k9ezb5+fkAvPnmmyxatIgFCxawfPlyDhw4EHnO\n1113HXPnzuWmm26ioaEhcr7f//73kerdlVdeyVdffdXm+yoiImFKikREBrgf/vCHnHPOObz99tv8\n8pe/5IEHHqC0tBSAnTt3cvrpp/P2229z9dVXt6g6HW3q1Kltbt+/fz8jR46MfD9y5Mg2b8Dfe+89\nNm3axNq1a3nuueciSUezDRs28MorrzB37lz+8Ic/EAwGefvtt3nllVf405/+RH5+PmeccQabN28G\n4Msvv+Skk07is88+A8IVqzPOOIOdO3fy/PPP89prr7F69Wq2bdsWucZvfvMbqqqqWLNmDatXr+aT\nTz7h7bffZtasWXz++eeR8+Tm5kbOm5eXx6xZswDYsmULM2fO5K233mLx4sU89dRTbb4m7b2mzz77\nLIWFhbz11lu88cYbvPnmm3z00UeRx1VUVLBmzRqysrIi24qLi7n//vt56qmneOuttzjzzDO59957\nAXjqqacYMWIE7777Lv/5n/8ZOVddXR2/+MUveOWVV1izZg3f+c53+OCDD9qMVUREwpQUiYgMYH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5s2RIWENDQ28//77AKxZs4apU6dit9vbPNfXmywAzJ8/nzfffJPDhw8TCAT44x//yMUXX9zq\nuNzcXD788EP8fj8ej4e1a9e2G3NVVRUTJ04EwkPeiouLI00ETj/9dFavXh1JvHJzc1m1ahWnnXZa\n5PtNmzZRU1NDMBjkjTfeiJz33HPP5eWXX8Y0TRoaGnj99dcjQ9ZOP/10nn322UjXvtzcXJ599tlI\n84buaO81nTNnDi+99BKmaWJZFk8++SSffPJJh+c666yz2LBhQ2So3h//+MfIEL7p06fz7rvvAuH3\ntXkI4I4dO7j99tsJBoM4nU6mTJnSLzvwiYj0JCVFIiIDSFs3vw8++CAfffQRCxYs4LbbbuPhhx9m\n2LBhQLgxwrp167jooot48cUXueeee1o9vrS0lPnz53PJJZdgGAbLli1jwYIFVFVVMW3aNL7zne+w\ndOlSLr74YiZMmNCistNs7ty5TJ06lQsvvJDrrruO8847r93ncNNNN3H//fdz8cUXk5+fz0033cRj\njz1Gfn4+p5xyCjt27OCUU04BwonBF198EUnypkyZwhVXXMGll17KkiVLIskSwHXXXUdaWhoLFy5k\nyZIlXHjhhZG5PzNnzoycv63zdkd7r+m1115LZmYmCxcuZP78+RQVFUXmAX39fWv+/rjjjuP+++/n\nhhtuYOHCheTn50caLXz/+99n//79zJ07l5UrV0bWY5owYQJZWVksWLCARYsW8atf/Yr//M//7Pbz\nEBEZTAyrrT/9RdGuXbv453/+Z6677jquvvrqFvvWr1/Pf//3f2O32znhhBN46KGH2Lp1KzfffDOj\nRo3CsixOOukkfvjDH8YyRBGRQWndunU8+OCDvPXWW70dyoCh11REpH+K6ZyixsZGVqxY0e5f2u69\n915WrVpFZmYmt912Gx988AHx8fHMmzePu+66K5ahiYiIiIiIADEePud2u3nmmWfIzMxsc/8rr7wS\n2ZeWlkZ1dTUNDQ1tjlsXERERERGJhZgmRTabDZfL1e7+xMREAMrKyvjkk0+YPXs2Ho+HvLw8brjh\nBq655ho2bNgQyxBFRAatWbNmaZhXlOk1FRHpn3q9JXdlZSU33XQT9913H6mpqUyYMIFbbrmF8847\nj/3797N8+XLeeeedyKJ+bcnLy+vBiEVEREREpD9qbnDzdb2aFNXX13P99ddz++23R+YdjRkzhjFj\nxgAwevRoMjIyKC0tJTs7u8NztfcEB6ug10/Flt3YnEfe4pDXhzPOiSPe3cEjWzKDIVLHj8bucoa/\nDwXxVVVi2DovMlqmiTs
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63db2a10b8>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plot_drawdown_periods(bt_returns);"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0kAAAHUCAYAAADvHmP0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xm4HGWdN/xvVfXefbrP0mfNvkBCErYkJLLJjiEIsmoA\nwaCoOMPzirzviEQf4RkUnJdBUTIjLnPB6IxEr1fw0nkiSvQax2ccVCKggjKihJCE7Dn76a2q3j9+\nVaf7nPR6urq7us/3c13nOkl3dfV9eqm6f/W779+tmKZpgoiIiIiIiAAAaqMbQERERERE5CYMkoiI\niIiIiHIwSCIiIiIiIsrBIImIiIiIiCgHgyQiIiIiIqIcDJKIiIiIiIhyMEgiIqIZ27t3L1auXHnc\n7U8//TRuvfXWivd36aWX4te//rUTTSvb9u3bMTY2VrP9L1++HAcOHCi6zeuvv47nn3++Zm0gIqLK\nMEgiIqKqKIpS0e1u8+ijj2J0dLRm+y/ndXj22WfrHhwSEVFhnkY3gIiIWtvWrVtx7NgxHDhwAH/8\n4x/R2dmJf/zHf0Q8HsfLL7+Mu+++G5lMBuedd96UgOInP/kJHnnkESQSCcyfPx8PP/ww2tvbsXXr\nVhw4cACvvvoqNmzYgG984xv493//dwDAvffeiz/96U/41re+BQC4/fbbcd1112HJkiX45Cc/icHB\nQei6jo9+9KPYuHEjtmzZgtdffx233HILHnz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ZbQxDAmD734B8rqa31euX\ngH3kKBBu0hO7WyhK5d9
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63e3b8e860>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plot_drawdown_underwater(bt_returns);"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0UAAAHUCAYAAAD1IoN6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmQJGWZP/BvZtbV51zdPTPciq4gIP4YA34sKAQ3Arsa\nAYIiLuFvY1l1FRZ1FXWDBcElYIFYllXDBd0VkENURIEZAUVRYIFhuWZRzmGOnpnunr67rsx8398f\nPVldR2ZlZlUedXw/hhH0UVU5XVmZ7/M+z/u8ipRSgoiIiIiIqEupcR8AERERERFRnBgUERERERFR\nV2NQREREREREXY1BERERERERdTUGRURERERE1NUYFBERERERUVdjUERERA374Q9/iDPPPBOnnHIK\nTj31VFx00UXYtGlT5MdxwQUX4Be/+EXkr0tERJ0hEfcBEBFRe7rhhhvw9NNP4wc/+AGGh4chpcQ9\n99yDT3/601i/fj1WrFgR9yESERF5wkwRERH5NjMzgx/+8Ie47rrrMDw8DABQFAXnnnsufvOb35QC\nogsuuAA33ngjzjjjDDz//POYmZnBJZdcgtNOOw1nnnkm/uM//qP0nDfeeCNOO+00nHbaabjwwgsx\nPj5e9/tONm7ciLPPPhunnHIKzjvvPGzbtg1zc3M4/PDDMTU1Vfq9q6++GjfccAMA4N///d9x2mmn\n4YQTTsC3vvUtWPuaVx//7t278dd//dc4/fTTcdJJJ+E///M/S8/3+OOPl/5d99xzD9atW4fR0VEA\nwD333IPTTz8dJ554Ir74xS+iWCw2+Q4QEVGQGBQREZFvzz//PPbaay/su+++NT/r7e2t+Pp///d/\n8cADD+D9738/brjhBixbtgzr16/HHXfcgTvvvBPPPfccXn/9daxfvx4PPvgg1q9fj5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Ece+yxeOaZZ/D9738fwGKJXS6Xcw2IiIiI\niIiIGhVqpmjTpk245pprMDo6ikQigQ0bNuCEE07APvvsg5NOOgmXX345Lr30UgDAmWeeif333x8f\n//jH8bWvfQ3nn38+CoUCLr/88jAPkYiIiIiIulyoQdEhhxyC2267zfHnH/jAB3DXXXdVfC+dTuP6\n668P87CIiIiIiIhKYiufIyIiIiIiagUMioiIiIiIqKsxKCIiIiIioq7GoIiIiIiIiLoagyIiIiIi\nIupqDIqIiIiIiKirMSgiIiIiIqKuxqCIiIiIiIi6GoMiIiIiIiLqagyKiIiIiIioqzEoIiIiIiKi\nrsagiIiIYjWlT+GV7CtxHwYREXUxBkVERBSrSWMSb+XeivswiIioizEoIiKiWAkpYMCI+zCIiKiL\nMSgiIqJYmTBhSjPuwyAioi7GoIiIiGIlpGBQREREsWJQREREsRIQMCTL54iIKD4MioiIKFbMFBER\nUdwYFBERUazMPf8jIiKKC4MiIiKKlZSS5XNERBQrBkVERBQrEyaDIiIiihWDIiIiihXXFBERUdwY\nFBERUawEGBQREVG8GBQREVGshGRLbiIiiheDIiIiihW7zxERUdwYFBERUay4poiIiOLGoIiIiGIl\nwPI5IiKKF4MiIiKKFdcUERFR3BgUERFRrFg+R0REcWNQREREsWJLbiIiihuDIiIiipWQIu5DICKi\nLsegiIiIYmXChKrwdkRERPHhXYiIiGIlpIDK2xEREcWIdyEiIoqVgGCmiIiIYsW7EBERxYqZIiIi\nihvvQkREFCuuKSIiorjxLkRERLGSUkJTtLgPg4iIuhiDIiLqGveO3xv3IZANEybL54iIKFa8CxFR\n19hR3BH3IZANIdlogYi
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63db4e99b0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plot_gross_leverage(bt_returns, bt_positions);"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Top 10 long positions of all time</th>\n",
" <th>max</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>AMZN-16841</th>\n",
" <td>50.99%</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Top 10 short positions of all time</th>\n",
" <th>max</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>IBM-3766</th>\n",
" <td>-52.04%</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Top 10 positions of all time</th>\n",
" <th>max</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>IBM-3766</th>\n",
" <td>52.04%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>AMZN-16841</th>\n",
" <td>50.99%</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0UAAAHRCAYAAACl7xLJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XmYFOWdB/BvdfU93XP0HA0zzDDDIKBccomAnAEHCMRA\nhAcUsxhz6W5WglkjrIKKRGNUomHVjSYxSyREDWyiaLIeAaOA4oCAotzMffUc3TN9VXfXu3/0TDHD\nzNCDMg3S38/z8DB9Vf266u3q91tvVbUkhBAgIiIiIiJKULqLXQAREREREdHFxFBEREREREQJjaGI\niIiIiIgSGkMRERERERElNIYiIiIiIiJKaAxFRERERESU0BiKiOiyMWTIEBQVFWHu3LkoKirCokWL\nsHv37vOejqIo+N///V/t9hNPPIEpU6Zg27Zt3b6moqICQ4cOBQC8+OKLeOqpp87/DcSY7saNG3Hf\nffddkOm21/791tTUYP78+Rd8HvHw3nvvobq6GkB0nf3pT3+6yBV1bdu2bbj11lvP6zUvv/zyBa3B\n5/Phrrvu0tpWe4899hhmz56NuXPn4oknnujy9V/kPbRvy2d75plnsGrVKgDA8uXL8dlnn53XtImI\nviz9xS6AiOhCkSQJmzZtQlZWFgBg3759uP322/G3v/0NaWlpPZ7O4cOH8Ze//AXf/OY3AQBvvPEG\nHn30UVx77bUx5w8AN9988xd8B+eebm9p/36dTideffXVXp1fb3nhhRdw++23o0+fPli5cuXFLuec\nzmed1tXV4fnnn8eiRYsu2PyXLl2KadOmdapj+/bt+Oijj/Daa69BVVXcdNNNGD58OGbNmtVpGl+k\nXfbkNS+88MJ5T5eI6MviSBERXTaEEGj/e9SjR49GXl4ePv74YwDRcDN//nzMnTsXy5cvR1lZGYAz\nIzCLFy/Gc889h3/7t3/Dxx9/jGXLluEnP/kJqqqqsHr1arz88stwu91YsWIFZs+ejXnz5uG5557r\nVMfGjRtx7733AgCqqqpw2223Yfbs2Zg/f36HEaj2Tp48iZtuukkb5dq+ffs53+u5prtt2zYUFRVh\n9uzZuPvuuxEKhQBERxvapn/LLbegqqoK9fX1Hd5v+735Qghs2LABc+bMwdy5c7Fq1SoEAgEAwC23\n3IIXXngBN910E6ZMmYK77rqryzrPXl7PP/88AODOO+/s0Pn97LPPMHnyZABAcXExbrzxRlx//fVY\nsmQJysvLtff1ox/9CMuXL8djjz3WYT5PPvkk9uzZg//4j//AG2+8gVWrVuHZZ58FAMyYMQObNm3C\nwoULcd111+HNN9/Egw8+iFmzZmHJkiVobm4GAJw4cQK33HILioqK8I1vfAOffPLJOddBV++vfXsY\nMmQI/vKXv2DBggWYPHkyfv/733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QKcWfcAOtXidrvPOb2zWSwW\nKIqi3fb7/R2WV3vt21/bZw7o2WfE7XZ3aD/Jycnwer2d5iHLMsxmM4DoMmybh8fj6bAcnE6nFsqe\nfvppPP3001i4cCGys7OxatUqLQQTEXWHoYiILivtL7TQXkZGRoe95m63Gzqd7rwuwNA2naamJvTp\n0wdANKC0jcqcLS0tDZIkobm5WesAdvX8cDiMFStW4KmnnsLkyZOhKApGjhzZbQ3nmm4oFML+/fu1\n57a0tCAYDGL37t34xz/+gc2bNyMlJQUvv/xyzAsqtL3XNk1NTUhPTz/na7qbRlfLq6ioCG+99RYa\nGhpQVFQEAMjKykJhYSFeeeWVTtM6cuTIec37fGRlZcFut+P1118/r9edT3vo6iID48aNQyQSwY4d\nO3D8+HFMmjTpnPNLT0/
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63e2ac6c18>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pos_percent = pf.pos.get_percent_alloc(bt_positions)\n",
"pf.plotting.show_and_plot_top_positions(bt_returns, pos_percent);"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0UAAAHUCAYAAAD1IoN6AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xl4FGW+/v+7u5MQlkQIkIRdZA+bCCKI7FlYVRyUIAmI\n26XADxVHPTAM8zsgBrfhcAbBQTbZZRzBUUJYFVxwSTwCUSAQliFECJiNRCFbf//oSUsMIaSh00nV\n+3VddZmu9VNdBebmeeopi91utwsAAAAATMrq6QIAAAAAwJMIRQAAAABMjVAEAAAAwNQIRQAAAABM\njVAEAAAAwNQIRQAAAABMjVAEALhh7du3V0REhIYMGaIBAwboqaee0vfff39d206cOFGHDh3SN998\no/Dw8Aod9x//+Icr5QIAUAKhCABwwywWi1avXq24uDh9+umnuv/++/XUU08pPj6+3G1XrFihDh06\nOPdzvQ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ChIb731llq3bl3h4wEAqgZaigAAN11cXJxWr16t559/XpL0\n888/q3379pKkL774QqdOnSrRmnI1I0aM0Pz589WuXTsFBASUWu7l5aWioiL98ssvkqSGDRvq8OHD\nkqTY2Fjl5eU51y1vkIPi5f3799eOHTuUlZUlSdqwYYOz+5uPj4/69Omj119/XYMHD3a2MA0aNEjr\n16+XJBUUFCgmJkaHDh265vEAAFULoQgAcMMsFovGjx+voUOHqm/fvnrvvfe0ZMkShYSESJKefvpp\nzZ07VyNGjFB8fLymTJmi//mf/9F3331X5gAEQ4cO1blz58rsOhcYGKg77rhDAwcO1Pfff69JkyZp\n+fLlGjlypI4fP16i5eb3xyjrc5cuXfTEE0/o4Ycf1rBhw5STk6PnnnvOud6QIUO0a9euEjU988wz\nunjxooYMGaKRI0eqqKjIGQAZXAEAqgeL3c1jhL722mv67rvvVFhYqCeffFJhYWHOZV9++aXmz58v\nm82mfv36adKkSZKkmJgY7d+/XxaLRTNmzFDnzp3dWSIAoArKy8vT4MGDtWXLlhLP+QAAcLO59Zmi\nr7/+WsnJydqwYYMyMzM1atSoEqFo7ty5Wr58uQIDAzV27FhFREQoPT1dp06d0oYNG5ScnKzp06dr\n48aN7iwTAFAFrVy5UgMGDCAQAQDczq2hqGfPnurataskx+g7v/76q+x2uywWi06fPq26desqKChI\nkjRw4EDt27dP6enpzmFTW7VqpezsbOXm5pYaNQgAYFxDhw5VgwYN9Le//c3TpQAATMCtochiscjX\n11eStHHjRvXv39/Zv/rChQslHpytX7++Tp8+rYyMDHXq1KnE/AsXLhCKAMBEtm7d6ukSAAAmUilD\ncu/cuVMffPCBli1b5pz3+0eZynq0qbhl6VoSEhJuvEgAAAAAhta9e/erznd7KPrss8+0ZMkSLVu2\nzPmiPMnxXofz5887P587d06BgYHy9vbWhQsXnPPT0tLUoEGDco9T1gnCeBISErjekMS9gJK4H8yJ\n645i3AsoVta9cK2GFLcOyZ2Tk6PXX39db7/9tvz8/Eosa9KkiXJzc5WamqqCggJ9+umnuueee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6SpODgYGVmZioxMVF33nmnc91bb71V//73vzVgwADt3btXd9xxh3x9fRUYGKgDBw5o5syZ\nstvtys/PV+fOnSVJzZs3l7+/f4Vrg/sRigAAAOB0d/vgCoeYmy0xMVEhISH69ttv9fXXX2vdunWy\nWq3OoHI1gwcP1o4dO/TVV19p8eLF13WcgoIC58/e3t4lll35Ili73S6LxSK73e6cV1hYKIvForCw\nMK1du1YZGRnOZ5Zq1ar
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63e2b74390>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plot_turnover(bt_returns, bt_transactions, bt_positions);"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA00AAAHUCAYAAADm9cOOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3Xt4VNW9//HP3pMLJuFSQgaIFCpRwzGaCClgpDmIQIBg\nKxwsApZaAvXokSg9gHINoJggQpFaKcciRRBEbaRF1ARpkB+3Ip0gCi1VK15CJGRSAuQCScj8/rCZ\nxxAzkxkzmaTzfj0Pj8nK2nt/d2Y9D35Ye61tOBwOhwAAAAAA38j0dwEAAAAA0JoRmgAAAADABUIT\nAAAAALhAaAIAAAAAFwhNAAAAAOACoQkAAAAAXCA0AQDc6tOnj0aMGKGRI0fqtttu0/3336/33nuv\nScdOmTJFf/vb3/Tuu+8qJSXFo+u++uqr3pTbQFxcnAoLC7Vr1y7Nnz+/Wc7pjW3btmnKlCl+uz4A\nwDuEJgCAW4ZhaNOmTcrJydE777yjMWPG6P7779df/vIXt8f+7ne/03/8x384z9NUly9f1vLly72u\n+evqrjts2DA98cQTzXLOb1sLAKDtIDQBANxyOBz6+rvQR44cqQcffFArVqyQJF28eFEzZszQyJEj\nNWzYMD355JPOvrfffrvy8/Od33/88ccaOHCgampqnG0PPfSQNm3aVO+aaWlpunDhglJTU1VQUKDJ\nkydr1apVGj16tN577z2VlJRo2rRpGjVqlIYNG6YNGzY4j92zZ49SUlI0evRoPf/88872r8/0zJ07\nV88884zS0tJ0++23a+rUqbp06ZIkae/evRo5cqTuuOMOvfLKK0pMTFRhYWG9+pYvX66lS5c6vy8t\nLVXfvn1VVlamEydOaOLEiRo1apTGjh2rffv2NfidTp48Wa+//vo3ft+nTx+9+uqr+uEPf6ghQ4bo\nz3/+s2bOnKnbb79dP//5z1VbWytJstlsuuuuu5SSkqIJEyboiy+++MbPDwDw7RCaAABeGT16tD74\n4ANVVVXppZdeUmVlpXJycrRt2zZt27atXlD6umuvvVbdunXT3r17JUlVVVXav3+/Ro4cWa9fZmam\ngoKC9Oabb6pHjx6SpL/+9a964403dPPNN+s3v/mNevbsqbfeeku/+93vtHLlShUVFam2tlYLFy7U\nkiVL9MYbb8g0TV2+fNl53q/P9OTm5mr16tXatWuXSkpK9Pbbb6u2tlZz587VggULtGPHDn366ae6\nePFig/sYOXKkdu/e7fw+Ly9PSUlJCg8P18yZMzV58mS99dZbevzxxzVz5kxVVFR49PstLS3V66+/\nrpEjRyo9PV0PP/ywcnJy9OGHH+rdd99VRUWFHn74Yc2cOVM7d+7UT3/6U82YMcOjawAAmobQBADw\nSkREhC5fvqyysjJNmTJFzz77rCSpffv2uu6661zOeowePVo7duyQJO3bt0833HCDoqKi3F5z8ODB\nzq8XLFjgXJ/03e9+V1FRUfriiy/06aef6tKlS0pKSpIkjR071uX52rdvL9M0df3116uwsFAnT55U\ndXW1fvCDH0j6agaobmbn6+Lj4+VwOPT3v/9dkvT2229r1KhRKigokN1uV2pqqiTpxhtv1NVXX60P\nPvjA7f193bBhwyRJsbGx6tWrl3r27KmQkBD16tVLZ86c0eHDh9W+fXvnfaampurzzz/X6dOnPboO\nAMC9IH8XAABomwoKChQcHKwOHTro008/1bJly3Ty5EmZpqnTp09r3LhxjR6bmpqqtWvX6uLFi9q1\na5czYLjTsWNH59fvv/++fvnLX+rLL7+UaZoqLi6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AAOACoQkAAAA
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63e09f9b00>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.plotting.plot_daily_volume(bt_returns, bt_transactions);"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Summary stats</th>\n",
" <th>All trades</th>\n",
" <th>Short trades</th>\n",
" <th>Long trades</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Total number of round_trips</th>\n",
" <td>250.00</td>\n",
" <td>109.00</td>\n",
" <td>141.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Percent profitable</th>\n",
" <td>0.74</td>\n",
" <td>0.45</td>\n",
" <td>0.97</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Winning round_trips</th>\n",
" <td>186.00</td>\n",
" <td>49.00</td>\n",
" <td>137.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Losing round_trips</th>\n",
" <td>64.00</td>\n",
" <td>60.00</td>\n",
" <td>4.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Even round_trips</th>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>PnL stats</th>\n",
" <th>All trades</th>\n",
" <th>Short trades</th>\n",
" <th>Long trades</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Total profit</th>\n",
" <td>$1980690.67</td>\n",
" <td>$526009.56</td>\n",
" <td>$1454681.10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Gross profit</th>\n",
" <td>$2152761.28</td>\n",
" <td>$695137.94</td>\n",
" <td>$1457623.34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Gross loss</th>\n",
" <td>$-172070.61</td>\n",
" <td>$-169128.38</td>\n",
" <td>$-2942.23</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Profit factor</th>\n",
" <td>$12.51</td>\n",
" <td>$4.11</td>\n",
" <td>$495.41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avg. trade net profit</th>\n",
" <td>$7922.76</td>\n",
" <td>$4825.78</td>\n",
" <td>$10316.89</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avg. winning trade</th>\n",
" <td>$11573.99</td>\n",
" <td>$14186.49</td>\n",
" <td>$10639.59</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avg. losing trade</th>\n",
" <td>$-2688.60</td>\n",
" <td>$-2818.81</td>\n",
" <td>$-735.56</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ratio Avg. Win:Avg. Loss</th>\n",
" <td>$4.30</td>\n",
" <td>$5.03</td>\n",
" <td>$14.46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Largest winning trade</th>\n",
" <td>$999650.80</td>\n",
" <td>$590207.58</td>\n",
" <td>$999650.80</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Largest losing trade</th>\n",
" <td>$-18940.73</td>\n",
" <td>$-18940.73</td>\n",
" <td>$-1177.78</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Duration stats</th>\n",
" <th>All trades</th>\n",
" <th>Short trades</th>\n",
" <th>Long trades</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Avg duration</th>\n",
" <td>179 days 00:14:59.524000</td>\n",
" <td>168 days 03:03:18.165137</td>\n",
" <td>187 days 10:09:59.156028</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Median duration</th>\n",
" <td>181 days 01:00:00</td>\n",
" <td>167 days 01:00:00</td>\n",
" <td>189 days 01:00:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Longest duration</th>\n",
" <td>364 days 10:28:01</td>\n",
" <td>317 days 00:00:00</td>\n",
" <td>364 days 10:28:01</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Shortest duration</th>\n",
" <td>0 days 13:31:59</td>\n",
" <td>0 days 13:31:59</td>\n",
" <td>1 days 00:00:00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Return stats</th>\n",
" <th>All trades</th>\n",
" <th>Short trades</th>\n",
" <th>Long trades</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Avg returns all round_trips</th>\n",
" <td>0.07%</td>\n",
" <td>0.15%</td>\n",
" <td>0.00%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avg returns winning</th>\n",
" <td>0.10%</td>\n",
" <td>0.19%</td>\n",
" <td>0.02%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avg returns losing</th>\n",
" <td>-0.03%</td>\n",
" <td>-0.03%</td>\n",
" <td>-0.03%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Median returns all round_trips</th>\n",
" <td>0.01%</td>\n",
" <td>0.02%</td>\n",
" <td>0.00%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Median returns winning</th>\n",
" <td>0.02%</td>\n",
" <td>0.03%</td>\n",
" <td>0.01%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Median returns losing</th>\n",
" <td>-0.01%</td>\n",
" <td>-0.02%</td>\n",
" <td>-0.01%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Largest winning trade</th>\n",
" <td>8.37%</td>\n",
" <td>8.37%</td>\n",
" <td>0.10%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Largest losing trade</th>\n",
" <td>-0.19%</td>\n",
" <td>-0.13%</td>\n",
" <td>-0.19%</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Symbol stats</th>\n",
" <th>AMZN-16841</th>\n",
" <th>IBM-3766</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Avg returns all round_trips</th>\n",
" <td>0.00%</td>\n",
" <td>0.15%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avg returns winning</th>\n",
" <td>0.02%</td>\n",
" <td>0.19%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Avg returns losing</th>\n",
" <td>-0.03%</td>\n",
" <td>-0.03%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Median returns all round_trips</th>\n",
" <td>0.00%</td>\n",
" <td>0.02%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Median returns winning</th>\n",
" <td>0.01%</td>\n",
" <td>0.03%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Median returns losing</th>\n",
" <td>-0.01%</td>\n",
" <td>-0.02%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Largest winning trade</th>\n",
" <td>0.10%</td>\n",
" <td>8.37%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Largest losing trade</th>\n",
" <td>-0.19%</td>\n",
" <td>-0.13%</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>Profitability (PnL / PnL total) per name</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>AMZN-16841</th>\n",
" <td>73.44%</td>\n",
" </tr>\n",
" <tr>\n",
" <th>IBM-3766</th>\n",
" <td>26.56%</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA9YAAAT3CAYAAAAMvuivAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3WmgVXWh9/HfPkwyhAICjhRqRqYgkVOKOBSa1+41vWYp\ngz6WliihhYrlkE9eBbNupuZjclNAzXkW7cmL5ozihDiloojGeBE4ghzgrOeFDyeOIqLrwBH4fN7o\nXmfttf/r7MU++7vXsCtFURQBAAAAPpWqxh4AAAAArM2ENQAAAJQgrAEAAKAEYQ0AAAAlCGsAAAAo\nQVgDAABACU0bewBriwkTJjT2EAAAAGhAvXr1apDlCOtPoKF+6QAAADSuhtx56lBwAAAAKEFYAwAA\nQAnCGgAAAEoQ1gAAAFCCsAYAAIAShDUAAACUIKwBAACgBGENAAAAJQhrAAAAKEFYAwAAQAnCGgAA\nAEoQ1gAAAFCCsAYAAIAShDUAAACUIKwBAACgBGENAAAAJQhrAAAAKEFYAwAAQAnCGgAAAEoQ1gAA\nAFCCsAYAAIAShDUAAACUIKwBAACgBGENAAAAJQhrAAAAKEFYAwAAQAnCGgAAAEoQ1gAAAFCCsAYA\nAIAShDUAAACUIKwBAACgBGENAAAAJQhrAAAAKEFYAwAAQAnCGgAAAEoQ1gAAAFCCsAYAAIAShDUA\nAACUIKwBAACgBGENAAAAJQhrAAAAKEFYAwAAQAnCGgAAAEoQ1gAAAFCCsAYAAI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AA\nAFCCsAYAAIASmjb2ANY
"text/plain": [
"<matplotlib.figure.Figure at 0x7f63df33c668>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pf.create_round_trip_tear_sheet(bt_returns, bt_positions, bt_transactions);"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.5",
"language": "python",
"name": "py35"
},
"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.5.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}