{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "\n", "sys.path.insert(0, \"../../\")\n", "from pyecharts import online\n", "\n", "online()\n", "# 演示必要的准备代码,使用该库时不需重复此单元格命令" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import xalpha as xa\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 策略制定类\n", "生成简单的策略投资交易单,并储存在 self.status 中" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 一次性买入并持有" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "jshs = xa.fundinfo(\"000311\")\n", "# 选择投资标的" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "bah = xa.policy.buyandhold(jshs, start=\"2017-01-01\", totmoney=100000)\n", "# 简单的一次性买入类,从 start 日买入后就一直持有,始终选择分红再投入" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
000311date
0100000.002017-01-03
10.052017-08-04
20.052017-08-15
\n", "
" ], "text/plain": [ " 000311 date\n", "0 100000.00 2017-01-03\n", "1 0.05 2017-08-04\n", "2 0.05 2017-08-15" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bah.status\n", "# 第二三列表示此两日恰为分红日,选择了分红再投入" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[Timestamp('2017-08-04 00:00:00'), Timestamp('2017-08-15 00:00:00')]" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jshs.fenhongdate\n", "# 验证该两日确实分红" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "bah.sellout(\"2018-06-01\") # 选定日期全部卖出" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
000311date
0100000.0002017-01-03
10.0502017-08-04
20.0502017-08-15
3-0.0052018-06-01
\n", "
" ], "text/plain": [ " 000311 date\n", "0 100000.000 2017-01-03\n", "1 0.050 2017-08-04\n", "2 0.050 2017-08-15\n", "3 -0.005 2018-06-01" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bah.status" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "jshstrade = xa.trade(jshs, bah.status) # 尝试交易一下" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.15629726951248488" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "jshstrade.xirrrate()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 定投类" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "工银中证传媒指数分级" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 依旧先制定标的\n", "zzcm = xa.fundinfo(\"164818\")\n", "zzcm" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "auto = xa.policy.scheduled(\n", " zzcm, 1000, pd.date_range(\"2015-07-01\", \"2018-07-01\", freq=\"W-THU\")\n", ")\n", "# 按照每周四定额定投1000,生成交易单" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "# 按上面的策略单子交易下\n", "cm_t3 = xa.trade(zzcm, auto.status)" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cm_t3.v_tradevolume() # 交易情况可视化,那些明显的缝隙对应了小长假等,当次定投下单会被自动延后到下一个交易日" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
基金名称基金代码当日净值单位成本持有份额基金现值基金总申购历史最大占用基金持有成本基金分红与赎回换手率基金收益总额投资收益率
0工银中证传媒指数分级1648180.9351.614196030.8289788.82155000.0155000.0155000.00.00.161791-65211.18-42.0717
\n", "
" ], "text/plain": [ " 基金名称 基金代码 当日净值 单位成本 持有份额 基金现值 基金总申购 历史最大占用 \\\n", "0 工银中证传媒指数分级 164818 0.935 1.6141 96030.82 89788.82 155000.0 155000.0 \n", "\n", " 基金持有成本 基金分红与赎回 换手率 基金收益总额 投资收益率 \n", "0 155000.0 0.0 0.161791 -65211.18 -42.0717 " ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cm_t3.dailyreport(\"2018-08-03\") ## 截止到2018.08.03, 定投已经浮亏了 40% 多" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "还可以根据指数位置设置定期不定额的定投策略生成,这里就不仔细展开,只给一个例子:" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "auto2 = xa.policy.scheduled_tune(\n", " zzcm,\n", " 1000,\n", " pd.date_range(\"2015-07-01\", \"2018-07-01\", freq=\"M\"),\n", " [(0.9, 2), (1.2, 1)],\n", ") # 净值0.9以下加倍定投,1.2以上不再定投,中间正常定投" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "cm_t4 = xa.trade(zzcm, auto2.status)" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cm_t4.v_tradevolume()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 网格类" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "广发中证500ETF联接C" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc = xa.fundinfo(\"002903\")\n", "gfc\n", "# 场外网格最好选择基金的C份额" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "gr = xa.policy.grid(\n", " gfc, [3, 3, 3, 3, 3, 3], [6, 6, 6, 6, 6, 6], \"2017-01-01\", \"2018-08-03\"\n", ")\n", "# 制定一个 17年开始,18年8月结束的,以开始日期价格为基准,每下跌3%买入一仓,每仓买入上涨6%后卖出的网格策略,一共设置6档\n", "## 注意网格对应的总金额可通过 totmoney= 参数设置,这里默认值是100000\n", "## 卖出实际并不严格对应每次买入的份额,而是买入均分金额分仓,卖出均分持有份额分仓" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "([1.09791196,\n", " 1.0649746012000001,\n", " 1.0330253631639998,\n", " 1.0020346022690798,\n", " 0.97197356420100745,\n", " 0.9428143572749772],\n", " [1.035766,\n", " 1.0046930199999999,\n", " 0.97455222939999986,\n", " 0.94531566251799981,\n", " 0.91695619264245976,\n", " 0.88944750686318597])" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gr.sellpts, gr.buypts # 网格计划对应的卖点和买点净值" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
commentdatenetvaluetotvalue
52402018-08-070.86290.8629
52502018-08-080.85030.8503
52602018-08-090.87130.8713
\n", "
" ], "text/plain": [ " comment date netvalue totvalue\n", "524 0 2018-08-07 0.8629 0.8629\n", "525 0 2018-08-08 0.8503 0.8503\n", "526 0 2018-08-09 0.8713 0.8713" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc.price.iloc[-4:-1] # 事实上中证500已大幅跌破网格底线" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "gfc_t = xa.trade(gfc, gr.status) # 请开始你的交易" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc_t.v_tradevolume(bar_category_gap=\"90%\") # 交易情况可视化" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.5110637968744924" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc_t.xirrrate(\"2018-04-01\") # 截止指定日期的年化收益率超过50%" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-0.031232122333919685" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc_t.xirrrate() # 随着18年六七月份市场大跌,网格被跌穿,收益年化转负" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc_t.v_totvalue() # 网格投资持有基金的总值情况" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# 考虑到网格的闲置资金可以在货基中吃收益,于是使用投资组合分析\n", "gfc_cb = xa.mulfix(\n", " gfc_t, cashobj=xa.cashinfo(start=\"2016-10-01\")\n", ") # 恰好 mulfix 类的默认 totmoney 也是 100000,我们无需在额外设置" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
基金名称基金代码当日净值单位成本持有份额基金现值基金总申购历史最大占用基金持有成本基金分红与赎回换手率基金收益总额投资收益率
0广发中证500ETF联接C0029030.8758000.8860106310.3093106.56183333.3794193.0594193.0589140.320.922938-1086.49-1.1535
1货币基金mf1.0701480.59759719.3310401.12172473.65103397.465806.95166666.701.0464934594.174.4432
2总计totalNaNNaNNaN103507.68355807.02100000.00100000.00255807.020.3190563507.683.5077
\n", "
" ], "text/plain": [ " 基金名称 基金代码 当日净值 单位成本 持有份额 基金现值 基金总申购 \\\n", "0 广发中证500ETF联接C 002903 0.875800 0.8860 106310.30 93106.56 183333.37 \n", "1 货币基金 mf 1.070148 0.5975 9719.33 10401.12 172473.65 \n", "2 总计 total NaN NaN NaN 103507.68 355807.02 \n", "\n", " 历史最大占用 基金持有成本 基金分红与赎回 换手率 基金收益总额 投资收益率 \n", "0 94193.05 94193.05 89140.32 0.922938 -1086.49 -1.1535 \n", "1 103397.46 5806.95 166666.70 1.046493 4594.17 4.4432 \n", "2 100000.00 100000.00 255807.02 0.319056 3507.68 3.5077 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc_cb.combsummary()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.022243013394994196" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfc_cb.xirrrate() # 系统总计收益年化勉强为正" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 技术指标交叉类\n", "利用模块内置的海量技术指标,可以制定各种基于不同技术指标的交叉进行交易的策略,同样的也可以指定基于净值和单个技术指标交叉的策略" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "hs300 = xa.indexinfo(\"0000300\") # 获取指数作为假想的无摩擦成本的投资标的" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "hs300.ma(window=14) # 生成指数14天的均线" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "date 2018-08-16 00:00:00\n", "netvalue 2.48904\n", "totvalue 3276.73\n", "comment 0\n", "MA14 2.5641\n", "Name: 4032, dtype: object" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300.price.iloc[-1] # 此时 info 类的 price 表将自动添加一列 MA14" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300.v_techindex(col=[\"MA14\"], is_symbol_show=False) # 均线和指数的纠缠" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "st = xa.policy.indicator_cross(hs300, start=\"2013-01-01\", col=(\"netvalue\", \"MA14\"))\n", "# col 参量为一个两字符串的 tuple,每个代表标的价格表的一列名,当前者上穿后者时买入,反之卖出\n", "# 具体到这里,就是最经典的一个趋势短线策略,价格涨过某条均线就买入,反之卖出" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "hs300_t = xa.trade(hs300, st.status) # 模拟真实交易" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
基金名称基金代码当日净值单位成本持有份额基金现值基金总申购历史最大占用基金持有成本基金分红与赎回换手率基金收益总额投资收益率
0沪深30000003002.48904500.00.09800000.0112302.79-41009.619841009.6116.04727741009.6136.517
\n", "
" ], "text/plain": [ " 基金名称 基金代码 当日净值 单位成本 持有份额 基金现值 基金总申购 历史最大占用 基金持有成本 \\\n", "0 沪深300 0000300 2.489045 0 0.0 0.0 9800000.0 112302.79 -41009.61 \n", "\n", " 基金分红与赎回 换手率 基金收益总额 投资收益率 \n", "0 9841009.61 16.047277 41009.61 36.517 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300_t.dailyreport() # 盈利一般" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300_t.v_tradevolume() # 交易详情,相当高频,换手率 16 代表每笔的持有时间约为 1/16 年,即不到一个月" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300_t.v_tradecost(is_symbol_show=False) # 持仓成本降低缓慢" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "sti = xa.policy.indicator_cross(hs300, start=\"2013-01-01\", col=(\"MA14\", \"netvalue\"))\n", "# 我们看下交易策略彻底反转会发生什么" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "hs300_ti = xa.trade(hs300, sti.status)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
基金名称基金代码当日净值单位成本持有份额基金现值基金总申购历史最大占用基金持有成本基金分红与赎回换手率基金收益总额投资收益率
0沪深30000003002.4890452.59738187.1795049.579900000.0113045.0299170.719800829.2915.870778-4121.14-3.6456
\n", "
" ], "text/plain": [ " 基金名称 基金代码 当日净值 单位成本 持有份额 基金现值 基金总申购 历史最大占用 \\\n", "0 沪深300 0000300 2.489045 2.597 38187.17 95049.57 9900000.0 113045.02 \n", "\n", " 基金持有成本 基金分红与赎回 换手率 基金收益总额 投资收益率 \n", "0 99170.71 9800829.29 15.870778 -4121.14 -3.6456 " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300_ti.dailyreport() # 跌穿均线买入涨出均线卖出,果然赔钱,噗" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 基于技术指标点位的策略\n", "除了指标间的交叉,我们还可以给定几个不同的点位来买卖,其中也可以不给卖的点位,这相当于可以模拟熊市的网格底仓" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "hs300.roc(window=20) # 先生成一个追涨杀跌的动量类变动率指标" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "scrolled": true }, "outputs": [], "source": [ "st = xa.policy.indicator_points(\n", " hs300,\n", " start=\"2016-01-01\",\n", " col=\"ROC20\",\n", " buy=[(-0.08, 1), (-0.11, 2)],\n", " sell=[(0.06, 1), (0.1, 1)],\n", " buylow=True,\n", ")\n", "# 这个策略的含义时,跌破点位买,涨破点位跌, 这是 buylow 这个布尔量的意义,默认就是 true\n", "# 点位看的是 ROC20 一栏,这是 col 参数决定的,交易从 16年开始,默认昨天结束\n", "# 买点分别是 ROC 的值为 -8% 和 -11%, 分别买1/3,和2/3\n", "# 卖点分别是 ROC 为 6% 和 8%, 各卖一半" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "hs300_t = xa.trade(hs300, st.status)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
基金名称基金代码当日净值单位成本持有份额基金现值基金总申购历史最大占用基金持有成本基金分红与赎回换手率基金收益总额投资收益率
0沪深30000003002.4890452.757737516.893380.99200000.0103461.1103461.196538.90.549453-10080.11-9.7429
\n", "
" ], "text/plain": [ " 基金名称 基金代码 当日净值 单位成本 持有份额 基金现值 基金总申购 历史最大占用 \\\n", "0 沪深300 0000300 2.489045 2.7577 37516.8 93380.99 200000.0 103461.1 \n", "\n", " 基金持有成本 基金分红与赎回 换手率 基金收益总额 投资收益率 \n", "0 103461.1 96538.9 0.549453 -10080.11 -9.7429 " ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300_t.dailyreport() # 追跌杀涨好像效果一般" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hs300_t.v_totvalue() # 持有总金额的变化" ] } ], "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.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }