{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#%%\n", "from datetime import datetime\n", "from importlib import reload\n", "from vnpy.app.portfolio_strategy import BacktestingEngine\n", "from vnpy.trader.constant import Interval\n", "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "symbols = {\n", " #\"SHFE\": [\"CU\", \"AL\", \"ZN\", \"PB\", \"NI\", \"SN\", \"AU\", \"AG\", \"RB\", \"HC\", \"BU\", \"RU\",],\n", " #\"DCE\": [\"C\", \"CS\", \"A\", \"B\", \"M\", \"Y\", \"P\", \"BB\", \"JD\", \"L\", \"V\", \"PP\", \"J\", \"JM\", \"I\"],\n", " #\"CZCE\": [\"SR\", \"CF\",\"PM\",\"WH\", \"RI\", \"LR\", \"JR\",\"OI\", \"RS\", \"RM\", \"TA\", \"MA\", \"FG\", \"SF\", \"ZC\", \"SM\"], # \"CY\", \n", " \"CFFEX\": [\"IC\", \"IF\",\"IH\"]\n", "}\n", "contract_type = \"99\" # 99代表指数合约" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "vt_symbols = []\n", "for k, v in symbols.items():\n", " for i in v:\n", " symbol = i + contract_type + \".\" + k\n", " vt_symbols.append(symbol)\n", " \n", "def set_ratio(num):\n", " d = {}\n", " for i in vt_symbols:\n", " d[i] = num\n", " return d\n", "\n", "def show_result(strategy):\n", " engine = BacktestingEngine()\n", " rates = set_ratio(0)\n", " engine.set_parameters(\n", " vt_symbols=vt_symbols,\n", " interval=Interval.MINUTE,\n", " start=datetime(2020, 6, 1),\n", " end=datetime(2020, 12, 30),\n", " rates=set_ratio(1/1000),\n", " slippages=set_ratio(0),\n", " sizes=set_ratio(1),\n", " priceticks=set_ratio(0.01),\n", " capital=5_000_000,\n", " )\n", "\n", " engine.add_strategy(strategy, {})\n", " engine.load_data()\n", " engine.run_backtesting()\n", " df = engine.calculate_result()\n", " engine.calculate_statistics()\n", " engine.show_chart()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2021-02-26 22:11:46.987576\t开始加载历史数据\n", "2021-02-26 22:11:52.388571\t所有历史数据加载完成\n", "2021-02-26 22:11:53.362600\t逐日盯市盈亏计算完成\n", "2021-02-26 22:11:53.362600\t开始计算策略统计指标\n", "2021-02-26 22:11:53.374571\t------------------------------\n", "2021-02-26 22:11:53.374571\t首个交易日:\t2020-06-01\n", "2021-02-26 22:11:53.375572\t最后交易日:\t2020-12-29\n", "2021-02-26 22:11:53.375572\t总交易日:\t144\n", "2021-02-26 22:11:53.375572\t盈利交易日:\t65\n", "2021-02-26 22:11:53.375572\t亏损交易日:\t59\n", "2021-02-26 22:11:53.375572\t起始资金:\t5,000,000.00\n", "2021-02-26 22:11:53.375572\t结束资金:\t5,001,925.09\n", "2021-02-26 22:11:53.375572\t总收益率:\t0.04%\n", "2021-02-26 22:11:53.375572\t年化收益:\t0.06%\n", "2021-02-26 22:11:53.375572\t最大回撤: \t-1,310.90\n", "2021-02-26 22:11:53.375572\t百分比最大回撤: -0.03%\n", "2021-02-26 22:11:53.375572\t最长回撤天数: \t11\n", "2021-02-26 22:11:53.375572\t总盈亏:\t1,925.09\n", "2021-02-26 22:11:53.375572\t总手续费:\t12.74\n", "2021-02-26 22:11:53.375572\t总滑点:\t0.00\n", "2021-02-26 22:11:53.375572\t总成交金额:\t12,740.00\n", "2021-02-26 22:11:53.375572\t总成交笔数:\t3\n", "2021-02-26 22:11:53.375572\t日均盈亏:\t13.37\n", "2021-02-26 22:11:53.375572\t日均手续费:\t0.09\n", "2021-02-26 22:11:53.375572\t日均滑点:\t0.00\n", "2021-02-26 22:11:53.375572\t日均成交金额:\t88.47\n", "2021-02-26 22:11:53.375572\t日均成交笔数:\t0.020833333333333332\n", "2021-02-26 22:11:53.375572\t日均收益率:\t0.00%\n", "2021-02-26 22:11:53.375572\t收益标准差:\t0.00%\n", "2021-02-26 22:11:53.375572\tSharpe Ratio:\t1.06\n", "2021-02-26 22:11:53.375572\t收益回撤比:\t1.47\n", "2021-02-26 22:11:53.375572\t策略统计指标计算完成\n" ] }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "lines", "name": "Balance", "type": "scatter", "x": [ "2020-06-01", "2020-06-02", "2020-06-03", "2020-06-04", "2020-06-05", "2020-06-08", "2020-06-09", "2020-06-10", "2020-06-11", "2020-06-12", "2020-06-15", "2020-06-16", "2020-06-17", "2020-06-18", "2020-06-19", "2020-06-22", "2020-06-23", "2020-06-24", "2020-06-29", "2020-06-30", "2020-07-01", "2020-07-02", "2020-07-03", "2020-07-06", "2020-07-07", "2020-07-08", "2020-07-09", "2020-07-10", "2020-07-13", "2020-07-14", "2020-07-15", "2020-07-16", "2020-07-17", "2020-07-20", "2020-07-21", "2020-07-22", "2020-07-23", "2020-07-24", "2020-07-27", "2020-07-28", "2020-07-29", "2020-07-30", "2020-07-31", "2020-08-03", "2020-08-04", "2020-08-05", "2020-08-06", "2020-08-07", "2020-08-10", "2020-08-11", "2020-08-12", "2020-08-13", "2020-08-14", "2020-08-17", "2020-08-18", "2020-08-19", "2020-08-20", "2020-08-21", "2020-08-24", "2020-08-25", "2020-08-26", "2020-08-27", "2020-08-28", "2020-08-31", "2020-09-01", "2020-09-02", "2020-09-03", "2020-09-04", "2020-09-07", "2020-09-08", "2020-09-09", "2020-09-10", "2020-09-11", "2020-09-14", "2020-09-15", "2020-09-16", "2020-09-17", "2020-09-18", "2020-09-21", "2020-09-22", "2020-09-23", "2020-09-24", "2020-09-25", "2020-09-28", "2020-09-29", "2020-09-30", "2020-10-09", "2020-10-12", "2020-10-13", "2020-10-14", "2020-10-15", "2020-10-16", "2020-10-19", "2020-10-20", "2020-10-21", "2020-10-22", "2020-10-23", "2020-10-26", "2020-10-27", "2020-10-28", "2020-10-29", "2020-10-30", "2020-11-02", "2020-11-03", "2020-11-04", "2020-11-05", "2020-11-06", "2020-11-09", "2020-11-10", "2020-11-11", "2020-11-12", "2020-11-13", "2020-11-16", "2020-11-17", "2020-11-18", "2020-11-19", "2020-11-20", "2020-11-23", "2020-11-24", "2020-11-25", "2020-11-26", "2020-11-27", "2020-11-30", "2020-12-01", "2020-12-02", "2020-12-03", "2020-12-04", "2020-12-07", "2020-12-08", "2020-12-09", "2020-12-10", "2020-12-11", "2020-12-14", "2020-12-15", "2020-12-16", "2020-12-17", "2020-12-18", "2020-12-21", "2020-12-22", "2020-12-23", "2020-12-24", "2020-12-25", "2020-12-28", "2020-12-29" ], "xaxis": "x", "y": [ 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000000, 5000127.4145, 5000480.0977, 5000736.7102, 5001675.6506, 5001681.4898, 5001859.9336, 5002138.3918, 5001934.7485, 5002260.269, 5002044.1975, 5001812.9793, 5001072.2158, 5001173.6267, 5001517.6371, 5001563.3635, 5001643.838, 5001657.4419, 5000949.3643, 5000999.0619, 5001088.1683, 5001558.1877, 5001450.0077, 5001548.8201, 5001817.23, 5001828.9733, 5001829.7492, 5001824.8111, 5001665.6834, 5001745.8323, 5001523.4332, 5001420.98, 5001399.6041, 5001730.7907, 5001986.4636, 5001993.9981, 5001709.5711, 5001571.8597, 5001642.5787, 5001661.7194, 5001685.3021, 5001500.6762, 5001623.2157, 5001997.4039, 5001815.8711, 5001948.0272, 5001868.4408, 5001826.4748, 5001721.0924, 5001392.102, 5001540.7396, 5001209.7086, 5001119.6665, 5001221.2953, 5001305.134, 5001368.0953, 5001271.1939, 5001220.5814, 5001609.5467, 5001429.9617, 5001242.3729, 5001270.7518, 5001019.8729, 5001079.5573, 5001072.0601, 5001132.4674, 5001001.7473, 5001329.4753, 5001815.03, 5001809.8499, 5001745.0695, 5001692.3521, 5001640.4084, 5001486.6287, 5001587.266, 5001550.5031, 5001492.4546, 5001364.3467, 5001269.5831, 5001272.3221, 5001377.5385, 5001460.0691, 5001163.9353, 5001227.1663, 5001398.781, 5001446.085, 5001691.0887, 5001637.4674, 5001896.7114, 5001813.7566, 5001699.8417, 5001690.7417, 5001578.6818, 5001728.3619, 5001679.825, 5001686.5555, 5001810.2372, 5001872.5752, 5002050.68, 5001988.5526, 5001805.0252, 5001830.4163, 5002000.1181, 5001886.0593, 5002204.0709, 5002166.4264, 5002174.863, 5002209.2776, 5002066.4806, 5002040.509, 5001863.869, 5001839.0581, 5001634.9895, 5001757.748, 5001771.955, 5001769.8689, 5001999.2205, 5001895.9567, 5002054.5697, 5001815.1562, 5001911.908, 5001836.3144, 5001972.6929, 5001958.0117, 5001925.0918 ], "yaxis": "y" }, { "fill": "tozeroy", "fillcolor": "red", "mode": "lines", "name": "Drawdown", "type": "scatter", "x": [ "2020-06-01", "2020-06-02", "2020-06-03", "2020-06-04", "2020-06-05", "2020-06-08", "2020-06-09", "2020-06-10", "2020-06-11", "2020-06-12", "2020-06-15", "2020-06-16", "2020-06-17", "2020-06-18", "2020-06-19", "2020-06-22", "2020-06-23", "2020-06-24", "2020-06-29", "2020-06-30", "2020-07-01", "2020-07-02", "2020-07-03", "2020-07-06", "2020-07-07", "2020-07-08", "2020-07-09", "2020-07-10", "2020-07-13", "2020-07-14", "2020-07-15", "2020-07-16", "2020-07-17", "2020-07-20", "2020-07-21", "2020-07-22", "2020-07-23", "2020-07-24", "2020-07-27", "2020-07-28", "2020-07-29", "2020-07-30", "2020-07-31", "2020-08-03", "2020-08-04", "2020-08-05", "2020-08-06", "2020-08-07", "2020-08-10", "2020-08-11", "2020-08-12", "2020-08-13", "2020-08-14", "2020-08-17", "2020-08-18", "2020-08-19", "2020-08-20", "2020-08-21", "2020-08-24", "2020-08-25", "2020-08-26", "2020-08-27", "2020-08-28", "2020-08-31", "2020-09-01", "2020-09-02", "2020-09-03", "2020-09-04", "2020-09-07", "2020-09-08", "2020-09-09", "2020-09-10", "2020-09-11", "2020-09-14", "2020-09-15", "2020-09-16", "2020-09-17", "2020-09-18", "2020-09-21", "2020-09-22", "2020-09-23", "2020-09-24", "2020-09-25", "2020-09-28", "2020-09-29", "2020-09-30", "2020-10-09", "2020-10-12", "2020-10-13", "2020-10-14", "2020-10-15", "2020-10-16", "2020-10-19", "2020-10-20", "2020-10-21", "2020-10-22", "2020-10-23", "2020-10-26", "2020-10-27", "2020-10-28", "2020-10-29", "2020-10-30", "2020-11-02", "2020-11-03", "2020-11-04", "2020-11-05", "2020-11-06", "2020-11-09", "2020-11-10", "2020-11-11", "2020-11-12", "2020-11-13", "2020-11-16", "2020-11-17", "2020-11-18", "2020-11-19", "2020-11-20", "2020-11-23", "2020-11-24", "2020-11-25", "2020-11-26", "2020-11-27", "2020-11-30", "2020-12-01", "2020-12-02", "2020-12-03", "2020-12-04", "2020-12-07", "2020-12-08", "2020-12-09", "2020-12-10", "2020-12-11", "2020-12-14", "2020-12-15", "2020-12-16", "2020-12-17", "2020-12-18", "2020-12-21", "2020-12-22", "2020-12-23", "2020-12-24", "2020-12-25", "2020-12-28", "2020-12-29" ], "xaxis": "x2", "y": [ 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, -203.64330000057817, 0, -216.0715000005439, -447.2897000005469, -1188.0531999999657, -1086.6423000004143, -742.6319000003859, -696.9055000003427, -616.4309999998659, -602.8271000003442, -1310.9047000007704, -1261.2071000002325, -1172.100700000301, -702.0813000006601, -810.2613000003621, -711.4489000001922, -443.03899999987334, -431.295700000599, -430.5197999998927, -435.4579000007361, -594.5855999998748, -514.4367000004277, -736.8358000004664, -839.2889999998733, -860.6649000002071, -529.4783000005409, -273.8053999999538, -266.27089999988675, -550.6979000000283, -688.4093000004068, -617.6902999999002, -598.5496000004932, -574.9669000003487, -759.5928000006825, -637.0533000007272, -262.86510000005364, -444.3979000002146, -312.24179999995977, -391.82820000033826, -433.79420000035316, -539.1765999998897, -868.1670000003651, -719.5294000003487, -1050.5604000007734, -1140.6025000000373, -1038.9736999999732, -955.1350000007078, -892.1737000001594, -989.0751000000164, -1039.6876000007614, -650.7223000004888, -830.3073000004515, -1017.8961000004783, -989.5172000005841, -1240.3961000004783, -1180.7116999998689, -1188.2088999999687, -1127.8015999998897, -1258.5217000003904, -930.7937000002712, -445.2390000000596, -450.41910000052303, -515.1995000001043, -567.916900000535, -619.8606000002474, -773.6403000000864, -673.0030000004917, -709.7658999999985, -767.8144000004977, -895.922300000675, -990.685899999924, -987.9468999998644, -882.730500000529, -800.1999000003561, -1096.3337000003085, -1033.1027000006288, -861.4879999998957, -814.1840000003576, -569.1803000001237, -622.8015999998897, -363.5575999999419, -446.51240000035614, -560.4273000005633, -569.5273000001907, -681.5871999999508, -531.9071000004187, -580.4440000001341, -573.7135000005364, -450.031799999997, -387.69380000047386, -209.5890000006184, -271.71640000026673, -455.2438000002876, -429.85270000062883, -260.1509000007063, -374.20970000047237, -56.19810000061989, -93.8426000000909, -85.40600000042468, -50.99140000063926, -193.78839999996126, -219.7600000007078, -396.40000000037253, -421.21090000029653, -625.2795000001788, -502.5210000006482, -488.31400000024587, -490.40010000020266, -261.0485000004992, -364.31230000033975, -205.69930000044405, -445.11280000023544, -348.3610000004992, -423.954600000754, -287.5761000001803, -302.25730000063777, -335.17720000073314 ], "yaxis": "y2" }, { "name": "Daily Pnl", "type": "bar", "xaxis": "x3", "y": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127.4145000000001, 352.68319999999994, 256.6124999999997, 938.9404, 5.839200000000346, 178.4438, 278.45820000000003, -203.64329999999973, 325.52049999999963, -216.07150000000001, -231.2181999999998, -740.7635000000005, 101.41090000000031, 344.0104000000001, 45.72640000000001, 80.47449999999935, 13.603900000000067, -708.0775999999996, 49.697599999999966, 89.10639999999967, 470.0194000000006, -108.18000000000029, 98.8123999999998, 268.40990000000056, 11.74329999999918, 0.7759000000005472, -4.938099999999395, -159.1277000000009, 80.14890000000014, -222.39909999999963, -102.45320000000038, -21.375899999999547, 331.1866, 255.67290000000003, 7.534499999999753, -284.4269999999992, -137.71140000000105, 70.7190000000005, 19.140699999999924, 23.582699999999022, -184.62589999999864, 122.53949999999895, 374.1882000000014, -181.5328000000004, 132.1560999999988, -79.58640000000014, -41.96599999999944, -105.3823999999995, -328.9903999999997, 148.63760000000002, -331.03100000000086, -90.04210000000012, 101.62880000000041, 83.83870000000024, 62.96129999999994, -96.9014000000002, -50.61250000000064, 388.9653000000012, -179.58500000000095, -187.58879999999908, 28.37889999999925, -250.87889999999925, 59.68439999999964, -7.497200000000248, 60.407300000000305, -130.72010000000046, 327.72800000000007, 485.55470000000014, -5.180099999999584, -64.78040000000101, -52.717399999998634, -51.94370000000072, -153.77970000000005, 100.63729999999987, -36.76290000000017, -58.04849999999897, -128.10789999999997, -94.76360000000113, 2.7390000000000327, 105.2164000000007, 82.5305999999996, -296.13380000000006, 63.23100000000022, 171.61470000000008, 47.30399999999963, 245.0037000000002, -53.62130000000025, 259.24400000000014, -82.95479999999998, -113.91489999999976, -9.100000000000364, -112.05989999999929, 149.68009999999913, -48.53689999999915, 6.73050000000012, 123.68169999999918, 62.33800000000019, 178.10480000000052, -62.12740000000031, -183.52739999999994, 25.39109999999937, 169.70179999999982, -114.05879999999888, 318.0115999999989, -37.644499999999425, 8.436600000000453, 34.41459999999961, -142.79700000000003, -25.971599999999853, -176.63999999999987, -24.8109000000004, -204.0685999999996, 122.75849999999946, 14.207000000000335, -2.086099999999533, 229.3515999999995, -103.26379999999972, 158.61299999999937, -239.41349999999966, 96.7518, -75.5936000000006, 136.37850000000026, -14.681199999999535, -32.91989999999987 ], "yaxis": "y3" }, { "name": "Days", "nbinsx": 100, "type": "histogram", "x": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127.4145000000001, 352.68319999999994, 256.6124999999997, 938.9404, 5.839200000000346, 178.4438, 278.45820000000003, -203.64329999999973, 325.52049999999963, -216.07150000000001, -231.2181999999998, -740.7635000000005, 101.41090000000031, 344.0104000000001, 45.72640000000001, 80.47449999999935, 13.603900000000067, -708.0775999999996, 49.697599999999966, 89.10639999999967, 470.0194000000006, -108.18000000000029, 98.8123999999998, 268.40990000000056, 11.74329999999918, 0.7759000000005472, -4.938099999999395, -159.1277000000009, 80.14890000000014, -222.39909999999963, -102.45320000000038, -21.375899999999547, 331.1866, 255.67290000000003, 7.534499999999753, -284.4269999999992, -137.71140000000105, 70.7190000000005, 19.140699999999924, 23.582699999999022, -184.62589999999864, 122.53949999999895, 374.1882000000014, -181.5328000000004, 132.1560999999988, -79.58640000000014, -41.96599999999944, -105.3823999999995, -328.9903999999997, 148.63760000000002, -331.03100000000086, -90.04210000000012, 101.62880000000041, 83.83870000000024, 62.96129999999994, -96.9014000000002, -50.61250000000064, 388.9653000000012, -179.58500000000095, -187.58879999999908, 28.37889999999925, -250.87889999999925, 59.68439999999964, -7.497200000000248, 60.407300000000305, -130.72010000000046, 327.72800000000007, 485.55470000000014, -5.180099999999584, -64.78040000000101, -52.717399999998634, -51.94370000000072, -153.77970000000005, 100.63729999999987, -36.76290000000017, -58.04849999999897, -128.10789999999997, -94.76360000000113, 2.7390000000000327, 105.2164000000007, 82.5305999999996, -296.13380000000006, 63.23100000000022, 171.61470000000008, 47.30399999999963, 245.0037000000002, -53.62130000000025, 259.24400000000014, -82.95479999999998, -113.91489999999976, -9.100000000000364, -112.05989999999929, 149.68009999999913, -48.53689999999915, 6.73050000000012, 123.68169999999918, 62.33800000000019, 178.10480000000052, -62.12740000000031, -183.52739999999994, 25.39109999999937, 169.70179999999982, -114.05879999999888, 318.0115999999989, -37.644499999999425, 8.436600000000453, 34.41459999999961, -142.79700000000003, -25.971599999999853, -176.63999999999987, -24.8109000000004, -204.0685999999996, 122.75849999999946, 14.207000000000335, -2.086099999999533, 229.3515999999995, -103.26379999999972, 158.61299999999937, -239.41349999999966, 96.7518, -75.5936000000006, 136.37850000000026, -14.681199999999535, -32.91989999999987 ], "xaxis": "x4", "yaxis": "y4" } ], "layout": { "annotations": [ { "font": { "size": 16 }, "showarrow": false, "text": "Balance", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 1, "yanchor": "bottom", "yref": "paper" }, { "font": { "size": 16 }, "showarrow": false, "text": "Drawdown", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.7350000000000001, "yanchor": "bottom", "yref": "paper" }, { "font": { "size": 16 }, "showarrow": false, "text": "Daily Pnl", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.47000000000000003, "yanchor": "bottom", "yref": "paper" }, { "font": { "size": 16 }, "showarrow": false, "text": "Pnl Distribution", "x": 0.5, "xanchor": "center", "xref": "paper", "y": 0.20500000000000002, "yanchor": "bottom", "yref": "paper" } ], "height": 1000, "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, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "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, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "width": 1000, "xaxis": { "anchor": "y", "domain": [ 0, 1 ] }, "xaxis2": { "anchor": "y2", "domain": [ 0, 1 ] }, "xaxis3": { "anchor": "y3", "domain": [ 0, 1 ] }, "xaxis4": { "anchor": "y4", "domain": [ 0, 1 ] }, "yaxis": { "anchor": "x", "domain": [ 0.7949999999999999, 1 ] }, "yaxis2": { "anchor": "x2", "domain": [ 0.53, 0.7350000000000001 ] }, "yaxis3": { "anchor": "x3", "domain": [ 0.265, 0.47000000000000003 ] }, "yaxis4": { "anchor": "x4", "domain": [ 0, 0.20500000000000002 ] } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#%%\n", "import demo_strategy\n", "reload(demo_strategy)\n", "show_result(demo_strategy.DemoStrategy)" ] }, { "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.1" } }, "nbformat": 4, "nbformat_minor": 2 }