def check(): if request.method == 'GET': data_json = {} return render_template('check.html', data_list=data_json) id = request.form['ID'] data_json = getRecord.getRecord(id) return render_template('check.html', data_list=data_json)
# # vol = volatility(indexPrice,calc='yang.zhang') # # import getRecord as gr # indexPrice = gr.getRecord(100000001,'23020') # # #aa =AMAi(indexPrice,1,20,250,2) # #print(aa) import pandas.io.data as web from PyQuantRisk import ReturnAnalysis as ra HS300=web.DataReader(name='000300.SS',data_source='yahoo',start='2006-01-01',end='2015-11-10') SH=web.DataReader(name='000001.SS',data_source='yahoo',start='2006-01-01',end='2015-11-10') dr1=HS300['Close'].pct_change() dr2=SH['Close'].pct_change() ra.Return_excess(dr1,dr2) import getRecord as gr SH= gr.getRecord(100000001,'23020') HS300=gr.getRecord(100000300,'232') SH=SH.set_index('settledate',drop=True) HS300=HS300.set_index('settledate',drop=True) dr1=HS300['close']['2006-01-01':'2015-11-10'].pct_change() dr2=SH['close']['2006-01-01':'2015-11-10'].pct_change() print(ra.Return_annualized(dr1,scale=252)) print(ra.TrackingError(dr1,dr2,252))
def AMAi(Pricevector,FastMaLength,SlowMALength,ERlength,depth): Fast=2/(FastMaLength+1) Slow=2/(SlowMALength+1) Pricevector=Pricevector.set_index('settledate') closeprice=Pricevector['close']['2005-04-08':] ERI=ERi(closeprice,ERlength) Ci=(ERI*(Fast-Slow)+Slow)**depth #amai=df(columns=closeprice.columns) #amai=df() #amai=df(columns=['close'],index=Pricevector['close'][ERlength]) #amai=closeprice[:'2006-4-19'] amai=closeprice #for i in closeprice['2006-4-20':].index: for i in range(ERlength,len(closeprice)): amai[i]=amai[i-1]+Ci[i]*(closeprice[i]-amai[i-1]) # newAMAi=pd.Series(amai.tail(1)+Ci[i]*(closeprice[i]-amai.tail(1))) # newAMAi.index=[i] # amai=amai.append(newAMAi) return amai import getRecord as gr indexPrice = gr.getRecord(201023,'23020') aa =AMAi(indexPrice,1,20,250,2) print(aa)