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 Sortino 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 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
from AlgorithmImports import * class OHLCDataPrinter(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 8, 13) # Set an end date for demonstration purposes self.SetCash(100000) # Add symbol self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol # Set New York timezone self.SetTimeZone("America/New_York") # Set brokerage Model self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) # Flag to track if it's a trading day self.is_trading_day = False # Initialize 200-period SMA indicator self.sma = self.SMA("SPY", 200, Resolution.Daily) # Warm up the SMA indicator self.WarmUpIndicator("SPY", self.sma, timedelta(days=200)) def OnData(self, data): if self.symbol in data: current_bar = data[self.symbol] if current_bar is not None: # Print the OHLC data for the current day self.Debug(f"Time: {self.Time}, Symbol: {self.symbol}, O: {current_bar.Open}, H: {current_bar.High}, L: {current_bar.Low}, C: {current_bar.Close}, V: {current_bar.Volume}") # self.Debug(f"Date: {self.Time.date()} | Open: {current_bar.Open} | High: {current_bar.High} | Low: {current_bar.Low} | Close: {current_bar.Close}") # Print the value of the 200-period SMA self.Debug(f"200-period SMA value: {self.sma.Current.Value}")