提交 f993b77e 编写于 作者: Z zengbin93

修改当下笔和线段成立的假设


Former-commit-id: 58fb28cae2c4d1a6583368d16c5eb05b2bf11cc8
上级 3343405d
......@@ -3,7 +3,7 @@
from .analyze import KlineAnalyze, SolidAnalyze
__version__ = "0.1.5"
__version__ = "0.1.6"
__author__ = "zengbin93"
__email__ = "zeng_bin8888@163.com"
......
......@@ -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:
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册