Overall Statistics |
Total Orders 1 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 100000 End Equity 104089 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 FUT0_J2209.MyCustomDataType 2S Portfolio Turnover 47.87% |
# region imports from AlgorithmImports import * # endregion class MyContinuousFuture(QCAlgorithm): def initialize(self): self.set_start_date(2022, 5, 19) self.set_end_date(2022, 5, 21) self.set_cash(100000) # add debugging self.j77 = self.add_data(MyCustomDataType, "Fut0_J2209", Resolution.Second).symbol self.debug(f"Added custom data with symbol: {self.j77}") # Create chart (only once) chart = Chart("MyCustomChart") chart.add_series(Series("Last", SeriesType.LINE)) self.add_chart(chart) def on_data(self, slice:Slice): self.debug(f"on_data called with slice keys: {list(slice.keys())}") if self.j77 in slice: data_point = slice[self.j77] self.plot("MyCustomChart", "Last", data_point.Last) self.debug(f"Plotting LastPrice: {data_point.Last} at time {data_point.Time}") self.SetHoldings(self.j77, 1) else: self.debug(f"Symbol {self.j77} not found in slice") class MyCustomDataType(PythonData): def get_source(self, config: SubscriptionDataConfig, date: datetime, is_live: bool) -> SubscriptionDataSource: source = "https://raw.githubusercontent.com/ohuhohou/QCtestdata/refs/heads/master/j77_220519.csv" #self.debug(f"Attempting to load data from: {source} for date: {date}") return SubscriptionDataSource(source, SubscriptionTransportMedium.REMOTE_FILE) def reader(self, config: SubscriptionDataConfig, line: str, date: datetime, is_live: bool) -> BaseData: # Skip empty lines or header lines if not line.strip(): return None try: data = line.split(',') # Check if this is a header row or invalid data if len(data) < 7 or not data[6].strip(): return None # try-catch: parsing the timestamp to validate it's a data row try: timestamp = datetime.strptime(data[6], "%Y-%m-%d %H:%M:%S") except ValueError: return None tick = MyCustomDataType() tick.Symbol = config.Symbol # Parse time and convert from UTC-5 to UTC tick.Time = timestamp + timedelta(hours=5) # **from UTC-5 to UTC** tick.EndTime = tick.Time # Parse numeric fields with error handling try: tick.Value = float(data[2]) # Last price as the value tick.Open = float(data[1]) tick.Last = float(data[2]) tick.BidPrice = float(data[5]) tick.AskPrice = float(data[4]) tick.Volume = int(data[3]) except (ValueError, IndexError) as e: #self.debug(f"err parsing numeric data: {e}") return None return tick except Exception as e: #self.debug(f"Exception in reader: {str(e)}") return None def data_time_zone(self): # Specify the time zone of your data return TimeZones.Utc