-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
302 additions
and
59 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Name: pyecharts\n", | ||
"Version: 1.8.1\n", | ||
"Summary: Python options, make charting easier\n", | ||
"Home-page: https://github.com/pyecharts/pyecharts\n", | ||
"Author: chenjiandongx\n", | ||
"Author-email: [email protected]\n", | ||
"License: MIT\n", | ||
"Location: c:\\users\\zengb\\anaconda3\\lib\\site-packages\n", | ||
"Requires: simplejson, prettytable, jinja2\n", | ||
"Required-by: \n" | ||
] | ||
}, | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"系统找不到指定的路径。\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"!pip show pyecharts \n", | ||
"\n", | ||
"import warnings\n", | ||
"warnings.filterwarnings(\"ignore\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## pyecharts 可视化分析结果\n", | ||
"---" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"0.5.4\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import sys\n", | ||
"sys.path.insert(0, \".\")\n", | ||
"sys.path.insert(0, \"..\")\n", | ||
"\n", | ||
"import czsc\n", | ||
"print(czsc.__version__)\n", | ||
"\n", | ||
"from datetime import datetime\n", | ||
"from typing import List\n", | ||
"import traceback\n", | ||
"import pandas as pd\n", | ||
"import numpy as np\n", | ||
"from tqdm import tqdm_notebook as tqdm\n", | ||
"from czsc.analyze import KlineAnalyze\n", | ||
"from pyecharts import options as opts\n", | ||
"from pyecharts.commons.utils import JsCode\n", | ||
"from pyecharts.charts import Kline, Line, Bar, Grid\n", | ||
"\n", | ||
"# 如果需要实盘行情,导入聚宽数据\n", | ||
"# from czsc.data.jq import *\n", | ||
"\n", | ||
"# 导入 tushare 数据\n", | ||
"from czsc.data.ts import *" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"kline = get_kline(\"300803.SZ-E\", end_date=\"20200913\", freq='30min')\n", | ||
"ka = KlineAnalyze(kline, name=\"30分钟\", bi_mode=\"new\", max_xd_len=20, ma_params=(5, 34, 120), verbose=False)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## pyecharts 绘图\n", | ||
"---" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def plot_kline(kline):\n", | ||
" \n", | ||
" x_data = [x['dt'] for x in kline]\n", | ||
" y_data = [[x['']]]\n", | ||
" # 基础配置\n", | ||
" bar_opts = opts.ItemStyleOpts(\n", | ||
" color=\"#ef232a\",\n", | ||
" color0=\"#14b143\",\n", | ||
" border_color=\"#ef232a\",\n", | ||
" border_color0=\"#14b143\",\n", | ||
" )\n", | ||
" \n", | ||
" mark_opts = \n", | ||
" \n", | ||
" \n", | ||
" draw = Kline()\n", | ||
" draw.add_xaxis(xaxis_data=data[\"times\"])\n", | ||
" draw.add_yaxis()\n", | ||
" \n", | ||
" draw.add_yaxis(series_name=\"K线\",\n", | ||
" y_axis=data[\"datas\"],\n", | ||
" itemstyle_opts=opts.ItemStyleOpts(\n", | ||
" color=\"#ef232a\",\n", | ||
" color0=\"#14b143\",\n", | ||
" border_color=\"#ef232a\",\n", | ||
" border_color0=\"#14b143\",\n", | ||
" ),\n", | ||
" markpoint_opts=opts.MarkPointOpts(\n", | ||
" data=[\n", | ||
" opts.MarkPointItem(type_=\"max\", name=\"最大值\"),\n", | ||
" opts.MarkPointItem(type_=\"min\", name=\"最小值\"),\n", | ||
" ]\n", | ||
" ),\n", | ||
" markline_opts=opts.MarkLineOpts(\n", | ||
" label_opts=opts.LabelOpts(\n", | ||
" position=\"middle\", color=\"blue\", font_size=15\n", | ||
" ),\n", | ||
" data=split_data_part(),\n", | ||
" symbol=[\"circle\", \"none\"],\n", | ||
" ),\n", | ||
" )\n", | ||
" .set_series_opts(\n", | ||
" markarea_opts=opts.MarkAreaOpts(is_silent=True, data=split_data_part())\n", | ||
" )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<czsc.analyze.KlineAnalyze at 0x175566e8d30>" | ||
] | ||
}, | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"ka" | ||
] | ||
}, | ||
{ | ||
"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.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.