目錄
前置
代碼?
視頻&月數據
前置
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