提交 31f729ed 编写于 作者: Z zengbin93

0.5.4 新增jupyter notebook example

上级 e8ae5a3f
......@@ -7,7 +7,7 @@ __pycache__/
*.xlsx
*.html
*.png
*.ipynb_checkpoints/
# C extensions
*.so
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## 使用 `czsc` 进行选股\n",
"---\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import traceback\n",
"from czsc.analyze import KlineAnalyze"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# 导入聚宽数据\n",
"from czsc.data.jq import *\n",
"\n",
"# 如果是第一次使用需要设置 token\n",
"# set_token(\"手机号\", \"登录密码\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### 缠论日线笔中枢三买选股\n",
"---"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"def selector(symbols):\n",
" \"\"\"输入symbols,选出有符合要求买点的股票列表\"\"\"\n",
" res = []\n",
" for symbol in symbols:\n",
" try:\n",
" kline = get_kline(symbol=symbol, end_date=datetime.now(), freq=\"D\", count=1000)\n",
" ka = KlineAnalyze(kline, ma_params=(5, 34, 120, 233))\n",
" points = ka.bi_list[-6:]\n",
" if points[-1]['fx_mark'] == \"d\":\n",
" zs_g = min([x['bi'] for x in points[:4] if x['fx_mark'] == 'g'])\n",
" zs_d = max([x['bi'] for x in points[:4] if x['fx_mark'] == 'd'])\n",
"\n",
" if points[-1]['bi'] > zs_g > zs_d:\n",
" res.append(symbol)\n",
" except:\n",
" traceback.print_exc()\n",
" return res\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"res = selector(symbols=[\"000001.XSHG\", \"300803.XSHE\"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 日线笔中枢形态选股\n",
"---\n",
"\n",
"中枢如果能当下确认,基本逻辑如下:\n",
"1. ma 233<close<ma 60 ---得 codes_list1\n",
"2. codes_list1中选择 符合日线笔中枢形态的,得codes_list2\n",
" * 2.1 笔中枢形态:方向下: 日线中枢完成,第四笔底分型\n",
"3. codes_list2 中中枢第一笔到第四笔得日期跨度 date1\n",
"4. date1时间跨度中,codes_list2 ma233 cross的个数,并标注 codes_list3"
]
},
{
"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": 1
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册