{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "from datetime import datetime\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "from turtleEngine import BacktestingEngine" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "16:07:40.112000:\t投资组合的合约代码['000300', '000905']\n", "16:07:40.112000:\t投资组合的初始价值10000000\n" ] } ], "source": [ "engine = BacktestingEngine()\n", "engine.setPeriod(datetime(2014, 1, 1), datetime(2018, 12, 30))\n", "engine.initPortfolio('test.csv', 10000000)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "16:07:40.182000:\t000300数据加载完成,总数据量:1185\n", "16:07:40.221000:\t000905数据加载完成,总数据量:1185\n", "16:07:40.221000:\t全部数据加载完成\n", "16:07:40.221000:\t开始回放K线数据\n", "16:07:40.355000:\tK线数据回放结束\n", "16:07:40.355000:\t开始统计回测结果\n", "16:07:40.362000:\t回测结果统计结束\n" ] } ], "source": [ "engine.loadData()\n", "engine.runBacktesting()\n", "engine.calculateResult()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEDCAYAAAA7jc+ZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VNX5+PHPk8m+EchC2COrIJRVBKyIiLuVqrVKrdW2Fq177fLV2trW1mr3/upat7or7lIFLSrugoR9R3YCAULIvs5yfn/MZDJJJmSS3Mlsz/v1m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EVk9Lqx5Nxxt1Ov9dw2AneE+tx68n0HJgCFnmO9AfQO9fn14LmnAqVAr1CfVw+f9++ALbgrNM8ASaE+vx48909wV2bWAqd39No6BYJSSkW5sGi6UUopFTya6JVSKsppoldKqSiniV4ppaKcJnqllIpymuiVUirKaaJXSqko9/8BV7SdCecSoxkAAAAASUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# 汇总每日盈亏,绘制简单资金曲线\n", "l = [result.totalPnl for result in engine.resultList]\n", "dateList = [result.date for result in engine.resultList]\n", "equity = np.cumsum(l)\n", "plt.plot(dateList, equity)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "# 查看逐笔的交易记录\n", "for dt, l in engine.tradeDict.items():\n", " for trade in l:\n", " print dt, trade.vtSymbol, trade.direction, trade.offset, trade.price, trade.volume" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" } }, "nbformat": 4, "nbformat_minor": 2 }