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.164
Tracking Error
0.327
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
# difference between the stock price and the vwap

from System.Drawing import Color

class VerticalTransdimensionalCoreWave(QCAlgorithm):

    def Initialize(self):
        
        # self.SetTimeZone("America/New_York")
        self.SetStartDate(2021, 7, 16)
        self.SetEndDate(2021, 7, 20)
        res = Resolution.Minute
        self.stock = self.AddEquity("SPY", res).Symbol

        self.Vwap = self.VWAP(self.stock)  # OK
        
        self.PriceMA = SimpleMovingAverage(1)
        self.RegisterIndicator(self.stock, self.PriceMA, res) # OK
        self.DiffMA = IndicatorExtensions.Minus(self.PriceMA, self.Vwap) # BUG

        self.PriceID = Identity("stock") 
        self.RegisterIndicator(self.stock, self.PriceID, res) # OK
        self.DiffID = IndicatorExtensions.Minus(self.PriceID, self.Vwap) # BUG

        stockPlot = Chart("Trade Plot")
        stockPlot.AddSeries(Series("Price Close", SeriesType.Line, 0))
        stockPlot.AddSeries(Series('Buy', SeriesType.Scatter, '$', Color.Green, ScatterMarkerSymbol.Triangle))
        stockPlot.AddSeries(Series('Sell', SeriesType.Scatter, '$', Color.Red, ScatterMarkerSymbol.TriangleDown))
        self.AddChart(stockPlot)

        
    def OnData(self, data): 
        if not self.CurrentSlice.Bars.ContainsKey(self.stock): return
    
        price = data[self.stock].Value        # OK
        priceID = self.PriceID.Current.Value  # OK        
        priceMA = self.PriceMA.Current.Value  # OK
        
        wvap = self.Vwap.Current.Value   # OK
        
        diff = float(price - wvap)       # OK
        diff_ID = float(priceID - wvap)  # OK
        diff_MA = float(priceMA - wvap)  # OK

        self.Plot("Trade Plot", "VWAP", wvap)
        self.Plot("Trade Plot", "Price Close", price)
        self.Plot("Trade Plot", "Price ID", self.PriceID.Current.Value)        
        self.Plot("Trade Plot", "Price MA", self.PriceMA.Current.Value)
        
        # self.Plot("Try", "Difference ID", self.DiffID.Current.Value) # BUG
        # self.Plot("Try", "Difference MA", self.DiffMA.Current.Value) # BUG
        self.Plot("Try", "diff", diff)
        self.Plot("Try", "diff_ID", diff_ID)
        self.Plot("Try", "diff_MA", diff_MA)