altair plots renderer changed

This commit is contained in:
Camilo1704
2020-02-07 11:55:18 -03:00
parent 5badef1f9f
commit b8e579234a
@@ -9,18 +9,26 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 1,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/anaconda3/lib/python3.7/site-packages/pyfolio/pos.py:27: UserWarning: Module \"zipline.assets\" not found; mutltipliers will not be applied to position notionals.\n",
" 'Module \"zipline.assets\" not found; mutltipliers will not be applied' +\n"
]
},
{
"data": {
"text/plain": [
"DataTransformerRegistry.enable('default')"
]
},
"execution_count": 18,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
@@ -37,7 +45,7 @@
"import pandas_datareader as pdr\n",
"import datetime\n",
"\n",
"#alt.renderers.enable('jpg')\n",
"alt.renderers.enable('kaggle')\n",
"alt.data_transformers.disable_max_rows()"
]
},
@@ -64,11 +72,28 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"env: TIINGO_API_KEY=1daeee45348833fa26a98a8e36993b8b9c8963b5\n"
]
}
],
"source": [
"%env TIINGO_API_KEY=1daeee45348833fa26a98a8e36993b8b9c8963b5\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"api_key = '1daeee45348833fa26a98a8e36993b8b9c8963b5'\n",
"api_key = os.environ[\"TIINGO_API_KEY\"]\n",
"\n",
"start = datetime.datetime(2010, 1, 1)\n",
"end = datetime.datetime(2019, 12, 31)\n",
@@ -78,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -90,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {
"scrolled": true
},
@@ -102,7 +127,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"metadata": {
"scrolled": true
},
@@ -113,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 11,
"metadata": {
"scrolled": true
},
@@ -121,10 +146,10 @@
{
"data": {
"text/plain": [
"<asset_backtester.portfolio.portfolio.Portfolio at 0x13a325310>"
"<asset_backtester.portfolio.portfolio.Portfolio at 0x13413dc50>"
]
},
"execution_count": 8,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -140,7 +165,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 12,
"metadata": {
"scrolled": true
},
@@ -150,7 +175,8 @@
"data = HistoricalAssetData(save_path)\n",
"bt = Backtest(schema)\n",
"bt.data = data\n",
"bt.portfolio = portfolio"
"bt.portfolio = portfolio\n",
"bt.initial_capital=1_000_000"
]
},
{
@@ -162,7 +188,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"metadata": {
"scrolled": true
},
@@ -172,7 +198,7 @@
"output_type": "stream",
"text": [
"0% [██████████████████████████████] 100% | ETA: 00:00:00\n",
"Total time elapsed: 00:00:43\n"
"Total time elapsed: 00:00:42\n"
]
},
{
@@ -727,14 +753,14 @@
"[2517 rows x 5 columns]"
]
},
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#periods = months between rebalance\n",
"bt.run(initial_capital=1_000_000, periods=6, sma_days= 100)"
"bt.run(periods=6, sma_days= 100)"
]
},
{
@@ -746,7 +772,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 14,
"metadata": {
"scrolled": true
},
@@ -755,10 +781,10 @@
"data": {
"text/html": [
"\n",
"<div id=\"altair-viz-13fc370fb27c42d79b50d11b8f2bafd2\"></div>\n",
"<div id=\"altair-viz-f32e1c2c0752433ab5fc2aa0e93f3853\"></div>\n",
"<script type=\"text/javascript\">\n",
" (function(spec, embedOpt){\n",
" const outputDiv = document.getElementById(\"altair-viz-13fc370fb27c42d79b50d11b8f2bafd2\");\n",
" const outputDiv = document.getElementById(\"altair-viz-f32e1c2c0752433ab5fc2aa0e93f3853\");\n",
" const paths = {\n",
" \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n",
" \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n",
@@ -806,7 +832,7 @@
"alt.LayerChart(...)"
]
},
"execution_count": 19,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@@ -824,17 +850,17 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<div id=\"altair-viz-86fc1bb9c7c8470a95420bd9e90c48b8\"></div>\n",
"<div id=\"altair-viz-94fc0defa7124752b12d20698bc838b6\"></div>\n",
"<script type=\"text/javascript\">\n",
" (function(spec, embedOpt){\n",
" const outputDiv = document.getElementById(\"altair-viz-86fc1bb9c7c8470a95420bd9e90c48b8\");\n",
" const outputDiv = document.getElementById(\"altair-viz-94fc0defa7124752b12d20698bc838b6\");\n",
" const paths = {\n",
" \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n",
" \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n",
@@ -882,7 +908,7 @@
"alt.VConcatChart(...)"
]
},
"execution_count": 12,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@@ -900,7 +926,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -1008,7 +1034,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 17,
"metadata": {
"scrolled": true
},
@@ -1018,7 +1044,7 @@
"output_type": "stream",
"text": [
"0% [██████████████████████████████] 100% | ETA: 00:00:00\n",
"Total time elapsed: 00:00:45\n"
"Total time elapsed: 00:00:43\n"
]
},
{
@@ -1573,13 +1599,13 @@
"[2517 rows x 5 columns]"
]
},
"execution_count": 14,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bt.run(initial_capital=1_000_000, periods=6, sma_days=None)"
"bt.run(periods=6, sma_days=None)"
]
},
{
@@ -1591,17 +1617,17 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<div id=\"altair-viz-f55371a8d77a40339d4beb9e2636908e\"></div>\n",
"<div id=\"altair-viz-d5adac920f6e49ddb631b615a29950ef\"></div>\n",
"<script type=\"text/javascript\">\n",
" (function(spec, embedOpt){\n",
" const outputDiv = document.getElementById(\"altair-viz-f55371a8d77a40339d4beb9e2636908e\");\n",
" const outputDiv = document.getElementById(\"altair-viz-d5adac920f6e49ddb631b615a29950ef\");\n",
" const paths = {\n",
" \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n",
" \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n",
@@ -1649,7 +1675,7 @@
"alt.VConcatChart(...)"
]
},
"execution_count": 15,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@@ -1667,7 +1693,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 19,
"metadata": {},
"outputs": [
{