• K线形态识别_跛脚阳线


    写在前面:
    1. 本文中提到的“K线形态查看工具”的具体使用操作请查看该博文
    2. K线形体所处背景,诸如处在上升趋势、下降趋势、盘整等,背景内容在K线形态策略代码中没有体现;
    3. 文中知识内容来自书籍《K线技术分析》by邱立波。

    目录

    解说

    技术特征

    技术含义

    K线形态策略代码

    结果


    解说

            跛脚阳线出现在涨势中,由三根阳线组成,其中前两根一般是大阳线或中阳线,后两根是低开阳线,第三根阳线实体很小,收盘价低于前一根阳线的收盘价。

    技术特征

    1)出现在上涨趋势中。

    2)由三根或三根以上阳线组成。

    3)前两根是大阳线或中阳线。

    4)后两根阳线都是低开。

    5)第三根阳线的实体很小,且收盘价比前面一根阳线的收盘价低。

    技术含义

            坡脚阳线是滞涨信号。

            在涨势中出现坡脚阳线,说明多方遭遇到上方沉重的抛压,后市看淡。

    K线形态策略代码

    1. def excute_strategy(daily_file_path):
    2. '''
    3. 名称:跛脚阳线
    4. 识别:
    5. 1. 由三根阳线组成,前两根一般是大阳线或中阳线,后两根是低开阳线
    6. 2. 第三根阳线实体很小,收盘价低于前一个阳线的收盘价
    7. 前置条件:计算时间区间 2021-01-01 到 2022-01-01
    8. :param daily_file_path: 股票日数据文件路径
    9. :return:
    10. '''
    11. import pandas as pd
    12. import os
    13. start_date_str = '2013-01-01'
    14. end_date_str = '2014-01-01'
    15. df = pd.read_csv(daily_file_path,encoding='utf-8')
    16. # 删除停牌的数据
    17. df = df.loc[df['openPrice'] > 0].copy()
    18. df['o_date'] = df['tradeDate']
    19. df['o_date'] = pd.to_datetime(df['o_date'])
    20. df = df.loc[(df['o_date'] >= start_date_str) & (df['o_date']<=end_date_str)].copy()
    21. # 保存未复权收盘价数据
    22. df['close'] = df['closePrice']
    23. # 计算前复权数据
    24. df['openPrice'] = df['openPrice'] * df['accumAdjFactor']
    25. df['closePrice'] = df['closePrice'] * df['accumAdjFactor']
    26. df['highestPrice'] = df['highestPrice'] * df['accumAdjFactor']
    27. df['lowestPrice'] = df['lowestPrice'] * df['accumAdjFactor']
    28. # 开始计算
    29. df['type'] = 0
    30. df.loc[df['closePrice'] > df['openPrice'], 'type'] = 1
    31. df.loc[df['closePrice'] < df['openPrice'], 'type'] = -1
    32. df['body_length'] = abs(df['closePrice']-df['openPrice'])
    33. df['three_yeah'] = 0
    34. df.loc[(df['type']==1) & (df['type'].shift(-1)==1) & (df['type'].shift(-2)==1),'three_yeah'] = 1
    35. df['ext_yeah'] = 0
    36. df.loc[(df['three_yeah']==1) & (df['body_length']/df['closePrice'].shift(1)>0.02) & (df['body_length'].shift(-1)/df['closePrice']>0.02) & (df['closePrice']'closePrice'].shift(-1)) & (df['closePrice']>df['openPrice'].shift(-1)),'ext_yeah'] = 1
    37. df['ext_yeah0'] = 0
    38. df.loc[(df['ext_yeah']==1) & (df['closePrice'].shift(-1)>df['closePrice'].shift(-2)) & (df['body_length'].shift(-1)>df['body_length'].shift(-2)),'ext_yeah0'] = 1
    39. df['signal'] = 0
    40. df['signal_name'] = ''
    41. df.loc[df['ext_yeah0'] == 1, 'signal'] = 1
    42. file_name = os.path.basename(daily_file_path)
    43. title_str = file_name.split('.')[0]
    44. line_data = {
    45. 'title_str':title_str,
    46. 'whole_header':['日期','收','开','高','低'],
    47. 'whole_df':df,
    48. 'whole_pd_header':['tradeDate','closePrice','openPrice','highestPrice','lowestPrice'],
    49. 'start_date_str':start_date_str,
    50. 'end_date_str':end_date_str,
    51. 'signal_type':'duration',
    52. 'duration_len':[-1],
    53. 'temp':len(df.loc[df['signal']==1])
    54. }
    55. return line_data

    结果

  • 相关阅读:
    kubernetes集群编排——istio
    你的哪些骚操作会导致Segmentation Fault😂
    windows电脑彻底删除文件怎么恢复?可尝试这2种恢复办法!
    第七章 规范化:Eslint + Prettier + Husky
    线性回归模型(OLS)3
    TFN SDH传输分析仪 的优劣势分析
    golang流程控制:if分支、switch分支和fallthrough switch穿透
    ZL_P3_1函数 数制转换
    Java实现单链表
    刚入职,软件测试岗,有点迷茫不知道下一步怎么提升自己
  • 原文地址:https://blog.csdn.net/m0_37967652/article/details/127780246