# -*- coding: utf-8 -*- """ Created on Wed May 24 15:47:51 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_ALF(df,N=10): ''' 过滤指标 原理: 同RC指标 用法: 1、以0为多空分界点,指标由负转正时,买入。 2、以0为多空分界点,指标由正转负时,卖出。 3、当股价创新高时,ALF未能创新高,出现背离,表示头部形成。 4、当股价创新低时,ALF未能创新低,出现背离,表示底部形成。''' df['alf']=100*(df['close']/df['close'].shift(N)-1) return df get_ALF(df) df.tail()