Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zengbin93
czsc
提交
f993b77e
C
czsc
项目概览
zengbin93
/
czsc
通知
23
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
czsc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f993b77e
编写于
2月 18, 2020
作者:
Z
zengbin93
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改当下笔和线段成立的假设
Former-commit-id: 58fb28cae2c4d1a6583368d16c5eb05b2bf11cc8
上级
3343405d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
57 deletion
+75
-57
chan/__init__.py
chan/__init__.py
+1
-1
chan/analyze.py
chan/analyze.py
+72
-52
test/test_kline_analyze.py
test/test_kline_analyze.py
+2
-4
未找到文件。
chan/__init__.py
浏览文件 @
f993b77e
...
...
@@ -3,7 +3,7 @@
from
.analyze
import
KlineAnalyze
,
SolidAnalyze
__version__
=
"0.1.
5
"
__version__
=
"0.1.
6
"
__author__
=
"zengbin93"
__email__
=
"zeng_bin8888@163.com"
...
...
chan/analyze.py
浏览文件 @
f993b77e
...
...
@@ -213,12 +213,16 @@ class KlineAnalyze(object):
"""
last_bi
=
bi
[
-
1
]
fx_last_d
=
[
x
for
x
in
self
.
fx
if
x
[
'fx_mark'
]
==
"d"
][
-
1
]
fx_last_g
=
[
x
for
x
in
self
.
fx
if
x
[
'fx_mark'
]
==
"g"
][
-
1
]
if
(
last_bi
[
'fx_mark'
]
==
'g'
and
fx_last_d
[
'fx'
]
>=
last_bi
[
'bi'
])
or
\
(
last_bi
[
'fx_mark'
]
==
'd'
and
fx_last_g
[
'fx'
]
<=
last_bi
[
'bi'
]):
last_k
=
self
.
kline_new
[
-
1
]
if
(
last_bi
[
'fx_mark'
]
==
'g'
and
last_k
[
'high'
]
>=
last_bi
[
'bi'
])
or
\
(
last_bi
[
'fx_mark'
]
==
'd'
and
last_k
[
'low'
]
<=
last_bi
[
'bi'
]):
bi
.
pop
()
# fx_last_d = [x for x in self.fx if x['fx_mark'] == "d"][-1]
# fx_last_g = [x for x in self.fx if x['fx_mark'] == "g"][-1]
# if (last_bi['fx_mark'] == 'g' and fx_last_d['fx'] >= last_bi['bi']) or \
# (last_bi['fx_mark'] == 'd' and fx_last_g['fx'] <= last_bi['bi']):
# bi.pop()
return
bi
def
_find_bi
(
self
,
version
=
'v2'
):
...
...
@@ -321,12 +325,16 @@ class KlineAnalyze(object):
"""
last_xd
=
xd_v
[
-
1
]
bi_last_d
=
[
x
for
x
in
self
.
bi
if
x
[
'fx_mark'
]
==
"d"
][
-
1
]
bi_last_g
=
[
x
for
x
in
self
.
bi
if
x
[
'fx_mark'
]
==
"g"
][
-
1
]
if
(
last_xd
[
'fx_mark'
]
==
'g'
and
bi_last_d
[
'bi'
]
>=
last_xd
[
'xd'
])
or
\
(
last_xd
[
'fx_mark'
]
==
'd'
and
bi_last_g
[
'bi'
]
<=
last_xd
[
'xd'
]):
last_k
=
self
.
kline_new
[
-
1
]
if
(
last_xd
[
'fx_mark'
]
==
'g'
and
last_k
[
'high'
]
>=
last_xd
[
'xd'
])
or
\
(
last_xd
[
'fx_mark'
]
==
'd'
and
last_k
[
'low'
]
<=
last_xd
[
'xd'
]):
xd_v
.
pop
()
# bi_last_d = [x for x in self.bi if x['fx_mark'] == "d"][-1]
# bi_last_g = [x for x in self.bi if x['fx_mark'] == "g"][-1]
# if (last_xd['fx_mark'] == 'g' and bi_last_d['bi'] >= last_xd['xd']) or \
# (last_xd['fx_mark'] == 'd' and bi_last_g['bi'] <= last_xd['xd']):
# xd_v.pop()
return
xd_v
def
_find_xd
(
self
):
...
...
@@ -650,15 +658,18 @@ class KlineAnalyze(object):
def
is_potential_third_buy
(
self
):
"""判断当下是否是潜在的三买"""
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'g'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
zs_g
=
min
([
x
[
'xd'
]
for
x
in
self
.
xd
[
-
5
:]
if
x
[
'fx_mark'
]
==
'g'
])
if
potential_xd
[
'xd'
]
>
zs_g
:
return
True
else
:
try
:
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'g'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
zs_g
=
min
([
x
[
'xd'
]
for
x
in
self
.
xd
[
-
5
:]
if
x
[
'fx_mark'
]
==
'g'
])
if
potential_xd
[
'xd'
]
>
zs_g
:
return
True
else
:
return
False
except
:
return
False
def
is_third_sell
(
self
):
"""判断当下是否是三卖"""
...
...
@@ -670,15 +681,18 @@ class KlineAnalyze(object):
def
is_potential_third_sell
(
self
):
"""判断当下是否是潜在的三卖"""
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'd'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
zs_d
=
max
([
x
[
'xd'
]
for
x
in
self
.
xd
[
-
5
:]
if
x
[
'fx_mark'
]
==
'd'
])
if
potential_xd
[
'xd'
]
<
zs_d
:
return
True
else
:
try
:
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'd'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
zs_d
=
max
([
x
[
'xd'
]
for
x
in
self
.
xd
[
-
5
:]
if
x
[
'fx_mark'
]
==
'd'
])
if
potential_xd
[
'xd'
]
<
zs_d
:
return
True
else
:
return
False
except
:
return
False
def
is_xd_buy
(
self
):
"""判断当下是否是线段买点(即同级别分解买点)"""
...
...
@@ -691,20 +705,23 @@ class KlineAnalyze(object):
def
is_potential_xd_buy
(
self
):
"""判断当下是否是潜在的线段买点(即同级别分解买点)"""
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'g'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
k_xd
=
self
.
xd
direction
=
"down"
zs1
=
[
k_xd
[
-
1
][
'dt'
],
potential_xd
[
'dt'
]]
zs2
=
[
k_xd
[
-
3
][
'dt'
],
k_xd
[
-
2
][
'dt'
]]
bc
=
self
.
cal_bei_chi
(
zs1
,
zs2
,
direction
,
mode
=
'xd'
)
if
bc
==
"背驰"
or
potential_xd
[
'xd'
]
>=
self
.
xd
[
-
2
][
'xd'
]:
return
True
else
:
try
:
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'g'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
k_xd
=
self
.
xd
direction
=
"down"
zs1
=
[
k_xd
[
-
1
][
'dt'
],
potential_xd
[
'dt'
]]
zs2
=
[
k_xd
[
-
3
][
'dt'
],
k_xd
[
-
2
][
'dt'
]]
bc
=
self
.
cal_bei_chi
(
zs1
,
zs2
,
direction
,
mode
=
'xd'
)
if
bc
==
"背驰"
or
potential_xd
[
'xd'
]
>=
self
.
xd
[
-
2
][
'xd'
]:
return
True
else
:
return
False
except
:
return
False
def
is_xd_sell
(
self
):
"""判断当下是否是线段卖点(即同级别分解卖点)"""
...
...
@@ -717,20 +734,23 @@ class KlineAnalyze(object):
def
is_potential_xd_sell
(
self
):
"""判断当下是否是潜在的线段卖点(即同级别分解卖点)"""
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'd'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
k_xd
=
self
.
xd
direction
=
"up"
zs1
=
[
k_xd
[
-
1
][
'dt'
],
potential_xd
[
'dt'
]]
zs2
=
[
k_xd
[
-
3
][
'dt'
],
k_xd
[
-
2
][
'dt'
]]
bc
=
self
.
cal_bei_chi
(
zs1
,
zs2
,
direction
,
mode
=
'xd'
)
if
bc
==
"背驰"
or
potential_xd
[
'xd'
]
<=
self
.
xd
[
-
2
][
'xd'
]:
return
True
else
:
try
:
potential_xd
=
self
.
xd_end_potential
()
if
potential_xd
[
'fx_mark'
]
==
'd'
or
potential_xd
[
'prob'
]
==
0
:
return
False
else
:
k_xd
=
self
.
xd
direction
=
"up"
zs1
=
[
k_xd
[
-
1
][
'dt'
],
potential_xd
[
'dt'
]]
zs2
=
[
k_xd
[
-
3
][
'dt'
],
k_xd
[
-
2
][
'dt'
]]
bc
=
self
.
cal_bei_chi
(
zs1
,
zs2
,
direction
,
mode
=
'xd'
)
if
bc
==
"背驰"
or
potential_xd
[
'xd'
]
<=
self
.
xd
[
-
2
][
'xd'
]:
return
True
else
:
return
False
except
:
return
False
class
SolidAnalyze
:
...
...
test/test_kline_analyze.py
浏览文件 @
f993b77e
...
...
@@ -2,7 +2,8 @@
import
tushare
as
ts
from
datetime
import
datetime
,
timedelta
import
sys
sys
.
path
.
insert
(
0
,
'C:\git_repo\zengbin93\chan'
)
sys
.
path
.
insert
(
0
,
'.'
)
sys
.
path
.
insert
(
0
,
'..'
)
from
chan.analyze
import
KlineAnalyze
...
...
@@ -46,9 +47,6 @@ def get_kline(ts_code, end_date, freq='30min', asset='E'):
"""
start_date
=
_get_start_date
(
end_date
,
freq
)
start_date
=
start_date
.
date
().
__str__
().
replace
(
"-"
,
""
)
end_date
=
datetime
.
strptime
(
end_date
,
'%Y%m%d'
)
end_date
=
end_date
+
timedelta
(
days
=
1
)
end_date
=
end_date
.
date
().
__str__
().
replace
(
"-"
,
""
)
df
=
ts
.
pro_bar
(
ts_code
=
ts_code
,
freq
=
freq
,
start_date
=
start_date
,
end_date
=
end_date
,
adj
=
'qfq'
,
asset
=
asset
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录