{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.insert(0, \"../../\")\n", "from pyecharts import online\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": [ "# 同一基金的A类C类份额研究" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "一般来讲A和C份额的区别,就是A收申购费赎回费,C不收,不过每日净值中收取销售服务费,两者的持有平衡点在一年左右" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "广发中证500ETF联接A" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gf500a = xa.fundinfo('162711')\n", "gf500a" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "广发中证500ETF联接C" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gf500c = xa.fundinfo('002903')\n", "gf500c" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "fund name: 广发中证500ETF联接A\n", "fund code: 162711\n", "fund purchase fee: 0.12%\n", "fund redemption fee info: ['小于7天', '1.50%', '大于等于7天,小于1年', '0.50%', '大于等于1年,小于2年', '0.30%', '大于等于2年', '0.00%']\n" ] } ], "source": [ "gf500a.info()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "fund name: 广发中证500ETF联接C\n", "fund code: 002903\n", "fund purchase fee: 0.0%\n", "fund redemption fee info: ['小于等于7天', '1.50%', '大于7天', '0.00%']\n" ] } ], "source": [ "gf500c.info() # 即使C类,由于国家新规,所有场外基金七天内报复性收取1.5%的赎回费是不可避免的" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "至于销售服务费的部分,直接反应在了净值的走势里,下面直接比较两者净值区别" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "gf500c.bcmkset(gf500a)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gf500c.v_netvalue()\n", "# 由此可见,两者净值高度吻合,但C类对应的红线,随着时间变化,渐渐靠下" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-0.0018000000000000099" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gf500c.total_annualized_returns()-gf500c.benchmark_annualized_returns()\n", "# C类的年化收益相交基准A类少了0.18%,和0.2%每年的销售服务费基本吻合" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "下面我们将讨论这两种基金真实持有的时间平衡点,考虑到 xirr 年化计算时,\n", "自带扣除赎回费的虚拟卖出功能,可以直接比较两者 xirr 收益率何时交叉" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "# 首先制作一个买入并持有的交易单\n", "sta = xa.policy.buyandhold(gf500a, start='2017-01-01')\n", "stc = xa.policy.buyandhold(gf500c, start='2017-01-01')" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "# 分别实际交易\n", "gf500a_t = xa.trade(gf500a, sta.status)\n", "gf500c_t = xa.trade(gf500c, stc.status)" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-0.00948902317486472" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 持有半年对比,C类更划算,接近跑赢1%!\n", "gf500a_t.xirrrate('2017-06-30')-gf500c_t.xirrrate('2017-06-30')" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "-8.546973222126053e-06" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gf500a_t.xirrrate('2018-04-30')-gf500c_t.xirrrate('2018-04-30')" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.6879065194576326e-05" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 由此可知对于广发中证500,持有不同份额的平衡点是17个月左右,超过17个月,A份额更具吸引力\n", "gf500a_t.xirrrate('2018-05-03')-gf500c_t.xirrrate('2018-05-03')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "下面我们看下进行网格交易时,两者对收益率的影响" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "gra = xa.policy.grid(gf500a,[3,3,3,3,3,3],[5,5,5,5,5,5],'2017-01-01', '2018-08-03')\n", "grc = xa.policy.grid(gf500c,[3,3,3,3,3,3],[5,5,5,5,5,5],'2017-01-01', '2018-08-03')\n", "# 每一仓位都是跌3%入,涨5%卖,总金额都是采用函数默认的100,000" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "## 实际交易\n", "gfa_grid_t = xa.trade(gf500a, gra.status) \n", "gfc_grid_t = xa.trade(gf500c, grc.status) " ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(0.507412374501354, 0.6003244855718297)" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gfa_grid_t.xirrrate('2018-04-01'),gfc_grid_t.xirrrate('2018-04-01')\n", "# 截止18年愚人节,采用C份额进行的网格年化收益率比A份额高出了10个百分点!网格当之无愧要选择C类基金" ] } ], "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 }