股票数据分析代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
%matplotlib inline
import pandas as pd
import numpy as np
import os
import matplotlib.pyplot as plt
pd.read_table('Desktop/1.csv')
data=pd.read_csv('Desktop/1.csv',index_col="Date",parse_dates=True)
data
adj_price=data['Adj Close']
adj_price
resampled=adj_price.resample('m',how='ohlc')
resampled
ripple=(resampled.high-resampled.low)/resampled.low
ripple
ripple.mean()
adj_price.plot(figsize=(8,6))
(adj_price.max()-adj_price.min())/(adj_price.min())
total_growth=adj_price.ix[0]/adj_price.ix[-1]
total_growth
old_date=adj_price.index[-1]
new_date=adj_price.index[0]
old_date.year, new_date.year
total_growth**(1.0/(new_date.year-old_date.year))-1
prince_in_year=adj_price.to_period('A').groupby(level=0).first()
prince_in_year
prince_in_year.plot()
diff=prince_in_year.diff()
diff
rate=diff/(prince_in_year-diff)
rate
rate.plot(kind='bar')