""" Created on Tue May 23 08:57:02 2017 @author: yunjinqi E-mail:yunjinqi@qq.com Differentiate yourself in the world from anyone else. """ import pandas as pd import numpy as np import datetime import time #获取数据 df=pd.read_csv('C:/Users/HXWD/Desktop/000001.csv',encoding='gbk') df.columns=['date','code','name','close','high','low','open','preclose', 'change','change_per','volume','amt'] df=df[['date','open','high','low','close','volume','amt']] df.head() def get_price_oscillator(df,short=12,long=26): df['price_oscillator']=100*((df['close'].rolling(short).mean()- df['close'].rolling(long).mean())/ df['close'].rolling(short).mean()) return df get_price_oscillator(df) df.tail()