Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zengbin93
czsc
提交
f493add7
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,发现更多精彩内容 >>
提交
f493add7
编写于
2月 20, 2020
作者:
Z
zengbin93
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改当下线段成立的判断
Former-commit-id: 3bba73ba7b1757c3107a2e213ef30fb4a9923086
上级
ba9cf072
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
27 deletion
+30
-27
chan/analyze.py
chan/analyze.py
+30
-27
未找到文件。
chan/analyze.py
浏览文件 @
f493add7
...
...
@@ -181,16 +181,17 @@ class KlineAnalyze(object):
2)如果最后一个笔标记为底分型,最近一个顶分型在这个底分型下方,该标记无效;
"""
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
):
...
...
@@ -241,17 +242,20 @@ class KlineAnalyze(object):
def
__last_potential_xd
(
self
,
k_xd
):
"""最后一个线段结束的概率"""
k_bi
=
self
.
bi
k_bi
=
deepcopy
(
self
.
bi
)
fx_mark
=
k_xd
[
-
1
][
'fx_mark'
]
if
fx_mark
==
'd'
:
direction
=
"up"
last_bi
=
[
x
for
x
in
self
.
bi
if
x
[
'fx_mark'
]
==
'g'
][
-
1
]
if
k_bi
[
-
1
][
'fx_mark'
]
==
'd'
:
k_bi
.
pop
(
-
1
)
elif
fx_mark
==
'g'
:
direction
=
"down"
last_bi
=
[
x
for
x
in
self
.
bi
if
x
[
'fx_mark'
]
==
'd'
][
-
1
]
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'
],
...
...
@@ -259,7 +263,7 @@ class KlineAnalyze(object):
'prob'
:
0
}
zs1
=
[
k_xd
[
-
1
][
'dt'
],
k_bi
[
-
1
]
[
'dt'
]]
# 走势1:尚未完成的线段
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'
]]
...
...
@@ -277,6 +281,8 @@ class KlineAnalyze(object):
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
):
...
...
@@ -324,7 +330,7 @@ class KlineAnalyze(object):
# 判断当下线段是否有结束的可能
last_xd
=
self
.
__last_potential_xd
(
xd_v
)
if
last_xd
[
'prob'
]
>
0
:
if
last_xd
[
'prob'
]
>
0
.4
:
self
.
last_xd_end_prob
=
last_xd
.
pop
(
'prob'
)
xd_v
.
append
(
last_xd
)
...
...
@@ -344,16 +350,17 @@ 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
):
...
...
@@ -392,17 +399,14 @@ class KlineAnalyze(object):
zs_g
=
min
([
x
[
'xd'
]
for
x
in
zs_xd
if
x
[
'fx_mark'
]
==
'g'
])
if
xd_p
[
'fx_mark'
]
==
"d"
and
xd_p
[
'xd'
]
>
zs_g
:
# print(i, "三买")
# 线段在中枢上方结束,形成三买
k_zs
.
append
({
'zs'
:
(
zs_d
,
zs_g
),
"zs_xd"
:
deepcopy
(
zs_xd
)})
zs_xd
=
deepcopy
(
k_xd
[
i
-
2
:
i
+
1
])
elif
xd_p
[
'fx_mark'
]
==
"g"
and
xd_p
[
'xd'
]
<
zs_d
:
# 线段在中枢下方结束,形成三卖
# print(i, "三卖")
k_zs
.
append
({
'zs'
:
(
zs_d
,
zs_g
),
"zs_xd"
:
deepcopy
(
zs_xd
)})
zs_xd
=
deepcopy
(
k_xd
[
i
-
2
:
i
+
1
])
else
:
# print(i, "延伸")
zs_xd
.
append
(
deepcopy
(
xd_p
))
if
len
(
zs_xd
)
>=
4
:
...
...
@@ -418,7 +422,6 @@ class KlineAnalyze(object):
k1
=
kn_map
.
get
(
k
[
'dt'
],
None
)
if
k1
:
k
[
'fx_mark'
],
k
[
'fx'
],
k
[
'bi'
],
k
[
'xd'
]
=
k1
[
'fx_mark'
],
k1
[
'fx'
],
k1
[
'bi'
],
k1
[
'xd'
]
# k.update(k1)
def
cal_bei_chi
(
self
,
zs1
,
zs2
,
direction
=
"down"
,
mode
=
"bi"
):
"""判断 zs1 对 zs2 是否有背驰
...
...
@@ -458,9 +461,9 @@ class KlineAnalyze(object):
macd_sum2
=
sum
([
abs
(
x
)
for
x
in
k2
.
macd
if
x
>
0
])
else
:
raise
ValueError
(
'direction value error'
)
if
macd_sum1
<
macd_sum2
and
abs
(
k1
.
dea
.
iloc
[
-
1
])
<
abs
(
k2
.
dea
.
iloc
[
-
1
]):
if
macd_sum1
<
macd_sum2
:
bc
=
True
else
:
raise
ValueError
(
"mode value error"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录