Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
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