sthoooon
2/8/2016 - 5:46 PM

Calculate Volume-Weighted Average Price

Calculate Volume-Weighted Average Price

import numpy as np
c,v = np.loadtxt('data.csv', delimiter=',', usecols=(6,7),unpack=True)
vwap = np.average(c, weights=v) #Mean with weights parameter
print "VWAP =", vwap