• K线形态识别_倒锤头线和射击之星(流星、扫帚星)


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

    目录

    解说 

    技术特征

    技术含义

    K线形态策略代码

    结果


    解说 

            倒锤头线是K线实体很小,没有下影线或者下影线非常短,上影线一般大于或等于实体两倍的小阴线和小阳线。倒锤头线因K线形状像个倒转的锤头而得名。

            射击之星又称流星、扫帚星,它们的K线形状和倒锤头线完全相同。不同之处在于:出现在股价大幅下跌之后的位置就是倒锤头线,出现在股价大幅上升之后的位置就是射击之星(流星、扫帚星)。

             倒锤头线和射击之星都是转势信号,其中倒锤头线是见底信号,射击之星是见顶信号。

    技术特征

    1)倒锤头线出现在下跌图中,射击之星出现在上涨途中。

    2)阳线或阴线实体很小,上影线大于或等于实体的两倍。

    3)下影线很短或没有。

    技术含义

    1)股价或指数大幅下跌后出现倒锤头线,止跌回升的可能性较大。

    2)股价或指数大幅上涨后出现射击之星,见顶回落的可能性较大。

    K线形态策略代码

    1. def excute_strategy(daily_file_path):
    2. '''
    3. 名称:倒锤头线和射击之星(流星、扫帚星)
    4. 识别:
    5. 1. 锤头线是K线实体很小,没有下影线或下影线很短,上影线一般大于或等于实体两倍的小阴线和小阳线
    6. 自定义:
    7. 1. 实体很小的小阳线和小阴线=》实体长度超过上一交易日价格0.5%但不到1.5%的K线
    8. 2. 影线很短 =》不超过上一交易日价格 0.5%
    9. 前置条件:计算时间区间 2021-01-01 到 2022-01-01
    10. :param daily_file_path: 股票日数据文件路径
    11. :return:
    12. '''
    13. import pandas as pd
    14. import os
    15. start_date_str = '2021-01-01'
    16. end_date_str = '2022-01-01'
    17. df = pd.read_csv(daily_file_path,encoding='utf-8')
    18. # 删除停牌的数据
    19. df = df.loc[df['openPrice'] > 0].copy()
    20. df['o_date'] = df['tradeDate']
    21. df['o_date'] = pd.to_datetime(df['o_date'])
    22. df = df.loc[(df['o_date'] >= start_date_str) & (df['o_date']<=end_date_str)].copy()
    23. # 保存未复权收盘价数据
    24. df['close'] = df['closePrice']
    25. # 计算前复权数据
    26. df['openPrice'] = df['openPrice'] * df['accumAdjFactor']
    27. df['closePrice'] = df['closePrice'] * df['accumAdjFactor']
    28. df['highestPrice'] = df['highestPrice'] * df['accumAdjFactor']
    29. df['lowestPrice'] = df['lowestPrice'] * df['accumAdjFactor']
    30. # 开始计算
    31. df.loc[df['closePrice']>=df['openPrice'],'type'] = 1
    32. df.loc[df['closePrice']'openPrice'],'type'] = -1
    33. df['body_length'] = abs(df['closePrice'] - df['openPrice'])
    34. df.loc[df['type']==1,'top_shadow_length'] = df['highestPrice'] - df['closePrice']
    35. df.loc[df['type']==-1,'top_shadow_length'] = df['highestPrice'] - df['openPrice']
    36. df.loc[df['type']==1,'bottom_shadow_length'] = df['openPrice'] - df['lowestPrice']
    37. df.loc[df['type']==-1,'bottom_shadow_length'] = df['closePrice'] - df['lowestPrice']
    38. df['signal'] = 0
    39. df['signal_name'] = 0
    40. short_len = 0.005
    41. df.loc[(df['body_length']/df['closePrice'].shift(1)>0.005) & (df['body_length']/df['closePrice'].shift(1)<0.015) & (df['bottom_shadow_length']/df['closePrice'].shift(1)'bottom_shadow_length']/df['closePrice'].shift(1)'top_shadow_length']/df['body_length']>=2),'signal'] = 1
    42. df.loc[(df['body_length']/df['closePrice'].shift(1)>0.005) & (df['body_length']/df['closePrice'].shift(1)<0.015) & (df['bottom_shadow_length']/df['closePrice'].shift(1)'bottom_shadow_length']/df['closePrice'].shift(1)'top_shadow_length']/df['body_length']>=2),'signal_name'] = df['top_shadow_length']/df['body_length']
    43. df = df.round({'signal_name': 2})
    44. file_name = os.path.basename(daily_file_path)
    45. title_str = file_name.split('.')[0]
    46. line_data = {
    47. 'title_str':title_str,
    48. 'whole_header':['日期','收','开','高','低'],
    49. 'whole_df':df,
    50. 'whole_pd_header':['tradeDate','closePrice','openPrice','highestPrice','lowestPrice'],
    51. 'start_date_str':start_date_str,
    52. 'end_date_str':end_date_str,
    53. 'signal_type':'line'
    54. }
    55. return line_data

    结果

  • 相关阅读:
    【深度学习】Mini-Batch梯度下降法
    【Web基础】Servlet——生命周期及其请求响应
    Dynamic CRM一对多关系的数据删除时设置自动删除关联的数据
    Go工作空间
    Linux | Linux权限详解
    java入坑之类加载器
    思维,序列和
    Laravel框架进阶:掌握队列系统,优化应用性能
    猿创征文 | 如何使用原生AJAX请求数据
    Clion 2019 搭配 Visual C++ Build Tools 搭建MSVC开发环境
  • 原文地址:https://blog.csdn.net/m0_37967652/article/details/127727229