目录
前置
代码
视频&月数据
前置
1 A股月数据趋势大致判断,做一个粗略的筛选
2 逻辑:
1)取最近一次历史最高点
2)以1)中最高点为分界点,只看右侧数据,取最近一次最低点
3)计算最新K线最高点相对 1)和2)中最高点和最低点之间的分位数
4)分位数小,可能为下降趋势,或在底部横盘;分位数在中下部,可能为下行后开始上行,或在底部宽幅震荡;分位数在中部,可能为正在上行,或长期宽幅震荡;分位数大,股价在高位。
代码
import os,traceback
import pandas as pddef temp_000():pre_dir = r'E:/temp005/'file_list = os.listdir(pre_dir)res_data_list = []for file_one in file_list:ticker = file_one[0:6]file_path = pre_dir + ticker + '.csv'df = pd.read_csv(file_path,encoding='utf-8')df = df.loc[df['turnoverVol']>0]df = df.loc[:, ['tradeDate', 'openPrice', 'highestPrice', 'lowestPrice', 'closePrice']]df['o_date'] = pd.to_datetime(df['tradeDate'])df.sort_values(by='o_date',ascending=True,inplace=True)df['num'] = range(len(df))max_num = res_maxnum(df.copy())if max_num>=len(df)-1:print(f'{ticker},最新月份为最大值')continuemin_num = res_minnum(df.loc[df['num']>=max_num].copy())if max_num == min_num:print(f'{ticker}, 最大值和最小值在同一根K线')continueright_max = df.iloc[max_num]['highestPrice']right_min = df.iloc[min_num]['lowestPrice']end_max = df.iloc[-1]['highestPrice']location = round(((end_max-right_min)/(right_max-right_min))*100,4)one_node = {'ticker':ticker,'len':len(df),'right_max_date':df.iloc[max_num]['tradeDate'],'right_max':right_max,'right_min_date':df.iloc[min_num]['tradeDate'],'right_min':right_min,'end_max':df.iloc[-1]['highestPrice'],'end_date':df.iloc[-1]['tradeDate'],'location':location,'max_min_len':min_num-max_num,'min_end_len':len(df)-min_num}res_data_list.append(one_node)passres_df = pd.DataFrame(data=res_data_list)res_df.sort_values(by=['location','len'],ascending=[True,False],inplace=True)res_df.to_csv(pre_dir+'000.csv',encoding='utf-8',index=False)passdef res_maxnum(df:pd.DataFrame):max_h = df['highestPrice'].max()max_num_list = df.loc[df['highestPrice']==max_h,'num'].to_list()max_num = max(max_num_list)return max_numdef res_minnum(df:pd.DataFrame):min_l = df['lowestPrice'].min()min_num_list = df.loc[df['lowestPrice'] == min_l, 'num'].to_list()min_num = max(min_num_list)return min_numif __name__ == '__main__':temp_000()pass
视频&月数据
https://www.bilibili.com/video/BV1vSLmzEEUa/
通过网盘分享的文件:A股前复权月数据_截至20250425.rar
链接: https://pan.baidu.com/s/1EsxJZ9qmUkYNCshBOIXsaA?pwd=xgqw 提取码: xgqw