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.557 Tracking Error 0.202 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
# region imports from AlgorithmImports import * # endregion class VolumeProfileAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.SetStartDate(2022, 1, 1) self.SetEndDate(2022, 12, 31) self.SetCash(100000) self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.vp = self.VP(self.symbol, 10, 0.70, 0.05) self.vah_window = RollingWindow[float](2) self.val_window = RollingWindow[float](2) self.WarmUpIndicator(self.symbol, self.vp) self.Log("Time, Price, vah, val, d_vah, d_val, percentVal") def OnData(self, data: Slice) -> None: # find value area bounds and related values if not self.vp.IsReady: return vah = self.vp.ValueAreaHigh val = self.vp.ValueAreaLow self.vah_window.Add(vah) self.val_window.Add(val) if not self.vah_window.IsReady or not self.val_window.IsReady: return d_vah = (self.vah_window[0] - self.vah_window[1]) / self.vah_window[1] d_val = (self.val_window[0] - self.val_window[1]) / self.val_window[1] # find asset price and related values if not data.Bars.ContainsKey(self.symbol): return price = data[self.symbol].Close percentVal = (price-val) / (vah-val) # update plots self.Plot("Price Chart", "Asset Price", data[self.symbol].Close) self.Plot("Price Chart", "POC", self.vp.POCPrice) self.Plot("Price Chart", "Value area high", vah) self.Plot("Price Chart", "Value area low", val) self.Plot("Volume Chart", "Value area volume", self.vp.ValueAreaVolume) # update logs self.Log(f"{self.Time},{price},{vah},{val},{d_vah},{d_val},{percentVal}")