Python 量化(一)分析股票上涨的重现周期

import tushare as ts


df=ts.get_hist_data('002230')


#df1=ts.get_hist_data('000002',start='2017-04-25',end='2017-06-30')

print(df.columns)

df2=df[df['p_change']>3]

df3=df2[['open','high','close','low','p_change','turnover']]

print(df3)

import datetime
from dateutil.parser import parse
from matplotlib.pylab import date2num

date_list=list(df3.index)

b=list(map(parse,date_list))

c=[]
for k in range(len(b)-1):
    c.append((b[k]-b[k+1]).days)

print('period=',c)
period= [1, 14, 18, 10, 4, 28, 22, 19, 3, 8, 4, 2, 1, 6, 5, 3, 21, 20, 25, 4, 5, 1, 1, 6, 12, 7, 1, 16, 4, 1, 2, 11, 21, 10, 55, 14, 1, 13, 15, 3, 1, 105, 10, 56, 61, 7, 2, 3, 3, 13, 65, 6, 6, 1, 15, 11, 2, 4, 11, 4, 2, 25, 3, 26, 13, 2, 9, 4, 2, 5, 3, 3, 1, 10, 7, 5, 7, 1, 11, 9, 6, 3, 3, 3, 6, 7, 2, 3, 3, 1, 10, 3, 7, 21, 1, 6, 8, 7, 3, 10, 15, 3, 3, 6]

可以看出科大讯飞最近的上涨的重现周期是15天左右

posted @ 2022-08-19 22:58  luoganttcc  阅读(7)  评论(0编辑  收藏  举报