Overall Statistics
from QuantConnect.Indicators import VolumeWeightedAveragePriceIndicator

class HorizontalVentralAntennaArray(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 11, 1)
        self.SetEndDate(2019, 11, 1)
        self.SetCash(100000)
        self.sym = self.AddEquity("SPY", Resolution.Minute).Symbol

        self.base = VolumeWeightedAveragePriceIndicator("SPY", 10)
        self.derived = VWAPDerived("SPY", 10)

        self.shown = False

    def OnData(self, data):
        if "SPY" not in data.Bars:
            return
        
        bar = data['SPY']
        close = bar.Close
        
        self.base.Update(bar)
        self.derived.Update(bar)
        
        if (self.base.IsReady or self.derived.IsReady) and not self.shown:
            self.shown = True
            self.Log(f"Base VWAP   : {self.base.Current.Value}")
            self.Log(f"Derived VWAP: {self.derived.Current.Value}\n")
            
            self.Log(f"Base TWAP   : {self.base.GetTimeWeightedAveragePrice(bar)}")
            self.Log(f"Derived TWAP: {self.derived.GetTimeWeightedAveragePrice(bar)}")
            self.Log(f"Close       : {close}")
            


class VWAPDerived(VolumeWeightedAveragePriceIndicator):
    def __init__(self, name, period):
        super().__init__(name, period)
    
    def GetTimeWeightedAveragePrice(self, input):
        return input.Close