Time Weighted Average Python