Overall Statistics |
Total Trades 133 Average Win 0.03% Average Loss -0.01% Compounding Annual Return 0.486% Drawdown 2.400% Expectancy 0.969 Net Profit 0.622% Sharpe Ratio 0.202 Probabilistic Sharpe Ratio 13.932% Loss Rate 47% Win Rate 53% Profit-Loss Ratio 2.71 Alpha -0.01 Beta 0.121 Annual Standard Deviation 0.017 Annual Variance 0 Information Ratio -0.947 Tracking Error 0.11 Treynor Ratio 0.029 Total Fees $133.00 Estimated Strategy Capacity $640000000.00 Lowest Capacity Asset QQQ RIWIV7K5Z9LX Portfolio Turnover 0.12% |
#region imports from AlgorithmImports import * #endregion class VWAPwithSTD(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetEndDate(2022, 4, 12) self.SetCash(100_000) self.symbols = ["QQQ", "SPY", "AAPL", "AMZN"] # list of symbols to trade self.vwaps = {} self.stds = {} for symbol in self.symbols: equity = self.AddEquity(symbol, Resolution.Minute) self.vwaps[symbol] = self.VWAP(equity.Symbol, 14, Resolution.Daily) self.stds[symbol] = self.STD(equity.Symbol, 14, Resolution.Daily) self.SetWarmUp(30, Resolution.Daily) def OnData(self, data): if self.IsWarmingUp or not all(std.IsReady for std in self.stds.values()): return for symbol in self.symbols: price = self.Securities[symbol].Price vwap = self.vwaps[symbol].Current.Value std = self.stds[symbol].Current.Value ub1 = vwap + std ub2 = vwap + 2*std lb1 = vwap - std lb2 = vwap - 2*std self.Plot(symbol, 'price', price) self.Plot(symbol, 'vwap', vwap) self.Plot(symbol, 'ub2', ub2) self.Plot(symbol, 'ub1', ub1) self.Plot(symbol, 'lb1', lb1) self.Plot(symbol, 'lb2', lb2) # implement trading logic for each stock here # e.g., if price < lb2: buy the stock # if price > ub2: sell the stock # otherwise, hold the stock if symbol == "QQQ" and price < lb2: self.SetHoldings(symbol, .1, False, "Buy Signal")