本文主要是介绍K线形态识别_下跌三颗星,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
写在前面:
1. 本文中提到的“K线形态查看工具”的具体使用操作请查看该博文;
2. K线形体所处背景,诸如处在上升趋势、下降趋势、盘整等,背景内容在K线形态策略代码中没有体现;
3. 文中知识内容来自书籍《K线技术分析》by邱立波。
目录
解说
技术特征
技术含义
K线形态策略代码
结果
解说
下跌三颗星是在下跌行情初期和中期出现的,由一根大阴线或中阴线及下方收出的三根小K线组成。小K线可以是十字线、十字星,也可以是小阳线、小阴线。
技术特征
1)出现在下跌行情初期和中期。
2)由四根K线组成,前面是一根大阴线或中阴线,然后阴线下方收出三根小K线。小K线可以是十字星、十字线,也可以是小阴线、小阳线。
技术含义
下跌三颗星是卖出信号,后市看跌。
下跌三颗星表明多方的抵抗非常虚弱,仅仅迟滞了一下空方前进的脚步。在多空双方胜负已分的情况下,空仓的交易者要继续观望,持仓的交易者应及时离场。
K线形态策略代码
def excute_strategy(daily_file_path):'''名称:下跌三颗星识别:由一根大阴线或中阴线及下方收出的三根小K线组成。小K线可以是十字线、十字星,也可以是小阳线、小阴线。自定义:1. 阴线下方=》阴线实体底部三分之一以下前置条件:计算时间区间 2021-01-01 到 2022-01-01:param daily_file_path: 股票日数据文件路径:return:'''import pandas as pdimport osstart_date_str = '2021-01-01'end_date_str = '2022-01-01'df = pd.read_csv(daily_file_path,encoding='utf-8')# 删除停牌的数据df = df.loc[df['openPrice'] > 0].copy()df['o_date'] = df['tradeDate']df['o_date'] = pd.to_datetime(df['o_date'])df = df.loc[(df['o_date'] >= start_date_str) & (df['o_date']<=end_date_str)].copy()# 保存未复权收盘价数据df['close'] = df['closePrice']# 计算前复权数据df['openPrice'] = df['openPrice'] * df['accumAdjFactor']df['closePrice'] = df['closePrice'] * df['accumAdjFactor']df['highestPrice'] = df['highestPrice'] * df['accumAdjFactor']df['lowestPrice'] = df['lowestPrice'] * df['accumAdjFactor']# 开始计算df['type'] = 0df.loc[df['closePrice'] >= df['openPrice'], 'type'] = 1df.loc[df['closePrice'] < df['openPrice'], 'type'] = -1df['body_length'] = abs(df['closePrice']-df['openPrice'])df['median_body_yeah'] = 0df.loc[(df['type']==-1) & (df['body_length']/df['closePrice'].shift(1)>0.02),'median_body_yeah'] = 1df['small_body_yeah'] = 0df.loc[df['body_length']/df['closePrice'].shift(1)<=0.015,'small_body_yeah'] = 1df['four_yeah'] = 0df.loc[(df['median_body_yeah']==1) & (df['small_body_yeah'].shift(-1)==1) & (df['small_body_yeah'].shift(-2)==1) & (df['small_body_yeah'].shift(-3)==1),'four_yeah'] = 1df['signal'] = 0df['signal_name'] = ''df.loc[(df['four_yeah']==1) & (df['body_length']*0.33+df['closePrice']>df['highestPrice'].shift(-1)) & (df['body_length']*0.33+df['closePrice']>df['highestPrice'].shift(-2)) & (df['body_length']*0.33+df['closePrice']>df['highestPrice'].shift(-3)),'signal'] = 1file_name = os.path.basename(daily_file_path)title_str = file_name.split('.')[0]line_data = {'title_str':title_str,'whole_header':['日期','收','开','高','低'],'whole_df':df,'whole_pd_header':['tradeDate','closePrice','openPrice','highestPrice','lowestPrice'],'start_date_str':start_date_str,'end_date_str':end_date_str,'signal_type':'duration','duration_len':[-2],'temp':len(df.loc[df['signal']==1])}return line_data
结果
这篇关于K线形态识别_下跌三颗星的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!