{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import xalpha as xa\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 多基金或指数的综合分析" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "sz50, hs300, zz500, cyb = (\n", " xa.indexinfo(\"0000016\"),\n", " xa.indexinfo(\"0000300\"),\n", " xa.indexinfo(\"0000905\"),\n", " xa.indexinfo(\"1399006\"),\n", ")\n", "# 四个基本指数的数据获取" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "comparison = xa.evaluate(sz50, hs300, zz500, cyb)\n", "# 综合分析,未指定 start 参数的化,比较的开始时间默认为最新的指数的开始时间" ] }, { "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", "
date0000016000030000009051399006
19872018-08-021.2766931.2284111.2410021.551620
19882018-08-031.2626681.2081231.2245431.522355
19892018-08-061.2590231.1928131.1985851.480422
19902018-08-071.2973411.2276501.2312801.520130
19912018-08-081.2801911.2078401.2123261.487575
19922018-08-091.3103351.2380941.2431781.538795
19932018-08-101.3095971.2408231.2495721.553284
\n", "
" ], "text/plain": [ " date 0000016 0000300 0000905 1399006\n", "1987 2018-08-02 1.276693 1.228411 1.241002 1.551620\n", "1988 2018-08-03 1.262668 1.208123 1.224543 1.522355\n", "1989 2018-08-06 1.259023 1.192813 1.198585 1.480422\n", "1990 2018-08-07 1.297341 1.227650 1.231280 1.520130\n", "1991 2018-08-08 1.280191 1.207840 1.212326 1.487575\n", "1992 2018-08-09 1.310335 1.238094 1.243178 1.538795\n", "1993 2018-08-10 1.309597 1.240823 1.249572 1.553284" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "comparison.totprice[comparison.totprice[\"date\"] > \"2018-08-01\"] # 这一类的核心数据,是归一化过的净值表" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "comparison.v_netvalue() # 指数起点归一化净值的变动情况,神创威武" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "comparison.v_correlation() # 指数之间的相关系数,创业板比较独立" ] }, { "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", " \n", " \n", " \n", "
0000016000030000009051399006
00000161.0000000.9437970.6561250.466339
00003000.9437971.0000000.8498730.670656
00009050.6561250.8498731.0000000.881827
13990060.4663390.6706560.8818271.000000
\n", "
" ], "text/plain": [ " 0000016 0000300 0000905 1399006\n", "0000016 1.000000 0.943797 0.656125 0.466339\n", "0000300 0.943797 1.000000 0.849873 0.670656\n", "0000905 0.656125 0.849873 1.000000 0.881827\n", "1399006 0.466339 0.670656 0.881827 1.000000" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "comparison.correlation_table() # 嫌图花哨可以直接看相关系数的数据" ] } ], "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 }