Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zengbin93
czsc
提交
6075b9a5
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,发现更多精彩内容 >>
提交
6075b9a5
编写于
2月 22, 2020
作者:
Z
zengbin93
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
删除当下线段成立的判断
Former-commit-id: f7f96467359582907f4f5515b87aa73b14d2b242
上级
2e0060e5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
75 deletion
+22
-75
chan/__init__.py
chan/__init__.py
+1
-1
chan/analyze.py
chan/analyze.py
+18
-70
chan/ta.py
chan/ta.py
+3
-4
未找到文件。
chan/__init__.py
浏览文件 @
6075b9a5
...
...
@@ -3,7 +3,7 @@
from
.analyze
import
KlineAnalyze
,
SolidAnalyze
__version__
=
"0.1.
8
"
__version__
=
"0.1.
9
"
__author__
=
"zengbin93"
__email__
=
"zeng_bin8888@163.com"
...
...
chan/analyze.py
浏览文件 @
6075b9a5
...
...
@@ -182,16 +182,16 @@ class KlineAnalyze(object):
"""
last_bi
=
bi
[
-
1
]
# 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'
]):
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
):
...
...
@@ -240,51 +240,6 @@ class KlineAnalyze(object):
xd
=
[{
"dt"
:
x
[
'dt'
],
"fx_mark"
:
x
[
'fx_mark'
],
"xd"
:
x
[
'xd'
]}
for
x
in
xd
]
return
xd
def
__last_potential_xd
(
self
,
k_xd
):
"""最后一个线段结束的概率"""
k_bi
=
deepcopy
(
self
.
bi
)
fx_mark
=
k_xd
[
-
1
][
'fx_mark'
]
if
fx_mark
==
'd'
:
direction
=
"up"
if
k_bi
[
-
1
][
'fx_mark'
]
==
'd'
:
k_bi
.
pop
(
-
1
)
elif
fx_mark
==
'g'
:
direction
=
"down"
if
k_bi
[
-
1
][
'fx_mark'
]
==
'g'
:
k_bi
.
pop
(
-
1
)
else
:
raise
ValueError
last_bi
=
k_bi
[
-
1
]
potential_xd
=
{
'dt'
:
last_bi
[
'dt'
],
'fx_mark'
:
last_bi
[
'fx_mark'
],
'xd'
:
last_bi
[
'bi'
],
'prob'
:
0
}
zs1
=
[
k_xd
[
-
1
][
'dt'
],
last_bi
[
'dt'
]]
# 走势1:尚未完成的线段
zs2
=
[
k_xd
[
-
3
][
'dt'
],
k_xd
[
-
2
][
'dt'
]]
# 走势2:上一根同向线段
bi1
=
[
k_bi
[
-
2
][
'dt'
],
k_bi
[
-
1
][
'dt'
]]
bi2
=
[
k_bi
[
-
4
][
'dt'
],
k_bi
[
-
3
][
'dt'
]]
if
k_bi
[
-
4
][
'dt'
]
<=
k_xd
[
-
1
][
'dt'
]:
if
direction
==
'up'
and
k_bi
[
-
1
][
'fx_mark'
]
==
'g'
\
and
self
.
cal_bei_chi
(
bi1
,
bi2
,
direction
,
mode
=
'bi'
)
==
'背驰'
:
potential_xd
[
'prob'
]
+=
0.4
if
potential_xd
[
'xd'
]
>=
k_xd
[
-
2
][
'xd'
]
and
\
self
.
cal_bei_chi
(
zs1
,
zs2
,
direction
,
mode
=
'xd'
)
==
"背驰"
:
potential_xd
[
'prob'
]
+=
0.4
if
direction
==
'down'
and
k_bi
[
-
1
][
'fx_mark'
]
==
'd'
\
and
self
.
cal_bei_chi
(
bi1
,
bi2
,
direction
,
mode
=
'bi'
)
==
'背驰'
:
potential_xd
[
'prob'
]
+=
0.4
if
potential_xd
[
'xd'
]
<=
k_xd
[
-
2
][
'xd'
]
and
\
self
.
cal_bei_chi
(
zs1
,
zs2
,
direction
,
mode
=
'xd'
)
==
"背驰"
:
potential_xd
[
'prob'
]
+=
0.4
if
potential_xd
[
'prob'
]
>
0
:
print
(
'
\n\n
potential_xd: '
,
potential_xd
,
"
\n\n
"
)
return
potential_xd
def
__get_valid_xd
(
self
,
xd_p
):
bi
=
deepcopy
(
self
.
bi
)
xd_v
=
[]
...
...
@@ -327,13 +282,6 @@ class KlineAnalyze(object):
xd_v
.
append
(
p2
)
else
:
xd_v
.
append
(
p2
)
# 判断当下线段是否有结束的可能
last_xd
=
self
.
__last_potential_xd
(
xd_v
)
if
last_xd
[
'prob'
]
>
0
:
self
.
last_xd_end_prob
=
last_xd
.
pop
(
'prob'
)
xd_v
.
append
(
last_xd
)
return
xd_v
def
__handle_last_xd
(
self
,
xd_v
):
...
...
@@ -351,16 +299,16 @@ class KlineAnalyze(object):
"""
last_xd
=
xd_v
[
-
1
]
# 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'
]):
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
):
...
...
chan/ta.py
浏览文件 @
6075b9a5
...
...
@@ -15,7 +15,7 @@ def ma(kline, params=(5, 10, 20, 60, 120, 250)):
在原始数据中新增若干 MA 均线
"""
for
p
in
params
:
col
=
"ma"
+
str
(
p
)
col
=
"ma"
+
str
(
p
)
kline
[
col
]
=
kline
[
'close'
].
rolling
(
p
).
mean
()
kline
[
col
]
=
kline
[
col
].
apply
(
round
,
args
=
(
2
,))
return
kline
...
...
@@ -52,12 +52,11 @@ def boll(kline):
"""
kline
[
'boll-mid'
]
=
kline
[
'close'
].
rolling
(
26
).
mean
()
kline
[
'boll-tmp2'
]
=
kline
[
'close'
].
rolling
(
20
).
std
()
kline
[
'boll-top'
]
=
kline
[
'boll-mid'
]
+
2
*
kline
[
'boll-tmp2'
]
kline
[
'boll-bottom'
]
=
kline
[
'boll-mid'
]
-
2
*
kline
[
'boll-tmp2'
]
kline
[
'boll-top'
]
=
kline
[
'boll-mid'
]
+
2
*
kline
[
'boll-tmp2'
]
kline
[
'boll-bottom'
]
=
kline
[
'boll-mid'
]
-
2
*
kline
[
'boll-tmp2'
]
kline
[
'boll-mid'
]
=
kline
[
'boll-mid'
].
apply
(
round
,
args
=
(
2
,))
kline
[
'boll-tmp2'
]
=
kline
[
'boll-tmp2'
].
apply
(
round
,
args
=
(
2
,))
kline
[
'boll-top'
]
=
kline
[
'boll-top'
].
apply
(
round
,
args
=
(
2
,))
kline
[
'boll-bottom'
]
=
kline
[
'boll-bottom'
].
apply
(
round
,
args
=
(
2
,))
return
kline
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录