예제 #1
0
def get_ma(cl, days=25):
    startd = days
    lenc = len(cl)
    avg = []
    
    for d in range(startd, lenc):
        i = d - startd
        avg.append(np.mean(cl[i:d+1]))
    
    zeros = [0]*startd
    avg = zeros + avg
    return avg
예제 #2
0
def get_bollinger(cl, days=20):
    startd = days
    lenc = len(cl)
    
    theta = []
    avg = []
    bollp2 = []
    bollm2 = []
    
    for d in range(startd, lenc):
        i = d - startd
        avg.append(np.mean(cl[i:d+1]))
        theta.append(np.std(cl[i:d+1]))
    
    bollp2 = (np.array(avg) + np.array(theta)*2).tolist()
    bollm2 = (np.array(avg) - np.array(theta)*2).tolist()
    
    zeros = [0]*startd
    avg = zeros + avg
    bollp2 = zeros + bollp2
    bollm2 = zeros + bollm2
    
    return (avg, bollp2, bollm2)