• K线形态识别_T字线和倒T字线


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

    目录

    解说

    技术特征

    技术含义

    K线形态策略代码

    结果


    解说

            T字线因为K线形状像英文字母“T”而得名,又称蜻蜓线。T字线是只有下影线没有上影线,或上影线非常短的同价位线。单日的T字线表明在多方打击下,空方已无力杀跌,股价或指数将会继续上升。

            倒T字线因为K线形状像倒写的英文字母“T”而得名,倒T字线是只有上影线没有下影线,或下影线非常短的同价位线。单日的倒T字线表明在空方打击下,多方已无力将股价或指数推高,后市可能会下跌。

             由于沪深股市实行涨跌停板制度,所以绝大数T字线和倒T字线都是以涨停或跌停收盘的。不论T字线和倒T字线是否是停板,大多都是主力操控股价的结果,因为只有主力才可以做到让股价以自己想要的价格开盘和收盘。在多空双方互不相让、激烈博弈的情况下,仅仅以巧合来解释T字线和倒T字线的成因,是很难让人信服的。

    技术特征

    1)T字线的开盘价、收盘价和最高价相同,呈“一”字形。

    2)T字线的下影线较长,一般没有上影线,或上影线非常短,形成T字形状。

    3)倒T字线的开盘价、收盘价和最低价相同,呈“一”字形。

    4)倒T字线的上影线较长,一般没有下影线,或下影线非常短,形成倒T字形状。

    技术含义

    1)在股价或指数已有较大涨幅后出现T字线,是见顶信号。

    2)在股价或指数已有较大跌幅后出现T字线,是见底信号。

    3)在上涨途中出现T字线,后市继续看涨。是持仓信号。

    4)在下跌途中出现T字线,后市继续看跌。持币观望。

    K线形态策略代码

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

    结果

  • 相关阅读:
    发明专利和实用新型专利的区别
    Java随笔-TCP/IP网络数据传输
    【计算机网络系列】数据链路层①:数据链路层的三个基本问题(封装成帧、透明传输和差错检测)
    mybatis的一对一和一对多实现
    qmt量化交易策略小白学习笔记第43期【qmt编程之期货数据--如何获取历史主力合约--原生python】
    Java基础之《HTML5标签(1)》
    基于PHP+MySQL超市库存管理系统的设计与实现
    敏捷开发流程【Scrum】
    【ansible第二次作业】
    docker pull速度慢解决办法
  • 原文地址:https://blog.csdn.net/m0_37967652/article/details/127726311