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.65 Tracking Error 0.174 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
# region imports from AlgorithmImports import * from io import StringIO import pandas as pd from dateutil import parser class SquareTanBaboon(QCAlgorithm): def Initialize(self): self.SetTimeZone(TimeZones.NewYork) self.SetStartDate(2019, 2, 1) # Set Start Date #self.SetEndDate(2022, 3, 1) self.SetCash(100000) # Set Strategy Cash self.spx = self.AddIndex("SPX", Resolution.Minute).Symbol self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.BeforeMarketClose(self.spx, 0), self.print_close) url_2022_2023 = "https://www.dropbox.com/s/sv3hb4nwhth03fl/Download%20Data%20-%20INDEX_US_S%26P%20US_SPX%20%281%29.csv?dl=1" url_2021_2022 = "https://www.dropbox.com/s/2yhmh8ti2ky09vg/downloaddatapartial%20%281%29.csv?dl=1" url_2020_2021 = "https://www.dropbox.com/s/zlmf47x3seq0tbm/Download%20Data%20-%20INDEX_US_S%26P%20US_SPX%20%282%29.csv?dl=1" url_2019_2020 = "https://www.dropbox.com/s/ikr3seg8qsyz4pn/Download%20Data%20-%20INDEX_US_S%26P%20US_SPX%20%283%29.csv?dl=1" urls = [url_2019_2020, url_2020_2021, url_2021_2022, url_2022_2023] self.data_frames = {} for url in urls: file = self.Download(url) df = pd.read_csv(StringIO(file)) first_date = df.iloc[-1]['Date'] last_date = df.iloc[0]['Date'] self.data_frames[first_date] = (df, first_date, last_date) def print_close(self): selected_df = None format_1 = parser.parse(self.Time.strftime("%m/%d/%Y")) for date, df in self.data_frames.items(): if format_1 >= parser.parse(df[1]): if format_1 <= parser.parse(df[2]): selected_df = df[0] break if selected_df is not None: date_to_search = self.Time.strftime("%m/%d/%Y") if date_to_search in selected_df['Date'].values: row = selected_df.loc[selected_df['Date'] == date_to_search] close_price = row['Close'].values[0] string_without_commas = float(close_price.replace(",", "")) qc_close = self.Securities[self.spx].Close difference = abs(string_without_commas - qc_close) if difference >= 1: self.Debug(f"{self.Time} QC {qc_close} MarketWatch {string_without_commas} Difference {difference}") else: date_to_search = self.Time.strftime("%m.%d.%Y") if date_to_search in selected_df['Date'].values: row = selected_df.loc[selected_df['Date'] == date_to_search] close_price = row['Close'].values[0] string_without_commas = float(close_price.replace(",", "")) qc_close = self.Securities[self.spx].Close difference = abs(string_without_commas - qc_close) if difference >= 1: self.Debug(f"{self.Time} QC {qc_close} MarketWatch {string_without_commas} Difference {difference}") def OnData(self, data: Slice): pass # if self.Time.year == 2022 and self.Time.month == 2 and self.Time.day == 25: # self.Debug(f"{self.Time} {self.Securities[self.spx].Close}")