Overall Statistics |
Total Orders 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 100000 End Equity 100000 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.806 Tracking Error 0.138 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
# region imports from AlgorithmImports import * # endregion class ObjectStoreCustomDataAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2012, 9, 13) self.set_end_date(2021, 6, 20) self.set_cash(100000) if not self.object_store.contains_key(Bitstamp.KEY): url = "https://raw.githubusercontent.com/QuantConnect/Documentation/master/Resources/datasets/custom-data/bitstampusd.csv" content = self.download(url) self.object_store.save(Bitstamp.KEY, content) # Define the symbol and "type" of our generic data: self.custom_data_symbol = self.add_data(Bitstamp, "BTC").symbol history = self.history(Bitstamp, self.custom_data_symbol, 200, Resolution.DAILY) self.debug(f"We got {len(history)} items from historical data request of {self.custom_data_symbol}.") def on_data(self, slice): data = slice.get(Bitstamp).get( self.custom_data_symbol) if not data: return self.log(f'{data.end_time}: Close: {data.close}') self.plot(self.custom_data_symbol, 'Price', data.close) class Bitstamp(PythonData): KEY = 'bitstampusd.csv' def get_source(self, config, date, isLiveMode): return SubscriptionDataSource(Bitstamp.KEY, SubscriptionTransportMedium.OBJECT_STORE) def reader(self, config, line, date, isLiveMode): # Example Line Format: # Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price # 2011-09-13 5.8 6.0 5.65 5.97 58.37138238, 346.0973893944 5.929230648356 if not line[0].isdigit(): return None coin = Bitstamp() coin.symbol = config.symbol data = line.split(',') # If value is zero, return None coin.value = float(data[4]) if coin.value == 0: return None coin.time = datetime.strptime(data[0], "%Y-%m-%d") coin.end_time = coin.time + timedelta(1) coin["Open"] = float(data[1]) coin["High"] = float(data[2]) coin["Low"] = float(data[3]) coin["Close"] = coin.value coin["VolumeBTC"] = float(data[5]) coin["VolumeUSD"] = float(data[6]) coin["WeightedPrice"] = float(data[7]) return coin