Overall Statistics |
Total Orders 1 Average Win 0% Average Loss 0% Compounding Annual Return 139.121% Drawdown 42.800% Expectancy 0 Start Equity 100000.00 End Equity 240170.62 Net Profit 140.171% Sharpe Ratio 3.098 Sortino Ratio 4.067 Probabilistic Sharpe Ratio 79.219% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -1.045 Beta 0.75 Annual Standard Deviation 0.556 Annual Variance 0.309 Information Ratio -9.795 Tracking Error 0.201 Treynor Ratio 2.298 Total Fees $399.00 Estimated Strategy Capacity $130000.00 Lowest Capacity Asset BTCUSD 2XR Portfolio Turnover 0.13% |
from AlgorithmImports import * from QuantConnect.DataSource import * from QuantConnect.Data.UniverseSelection import * class CoinAPIDataAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2020, 6, 1) self.set_end_date(2021, 6, 1) self.set_cash(100000) self.universe_settings.asynchronous = True # Coinbase accepts Cash account type only, AccountType.MARGIN will result in an exception. self.set_brokerage_model(BrokerageName.COINBASE, AccountType.CASH) # Warm up the security with the last known price to avoid conversion error self.set_security_initializer(lambda security: security.set_market_price(self.get_last_known_price(security))) # Requesting data crypto = self.add_crypto("BTCUSD", Resolution.MINUTE, Market.COINBASE) self.btcusd = crypto.symbol self.minimum_order_size = crypto.symbol_properties.minimum_order_size self.threshold = 0.5 # Historical data history = self.history(self.btcusd, 30, Resolution.DAILY) self.debug(f"We got {len(history)} items from our history request") # Add Crypto Universe Selection self._universe = self.add_universe(CryptoUniverse.coinbase(self.universe_selection_filter)) # Historical Universe data universe_history = self.history(self._universe, 30, Resolution.DAILY) self.debug(f"We got {len(universe_history)} items from our universe history request") for (univere_symbool, time), universe_day in universe_history.items(): for universe_item in universe_day: self.debug(f"{universe_item.symbol} price at {universe_item.end_time}: {universe_item.close}") def universe_selection_filter(self, universe_day): return [universe_item.symbol for universe_item in universe_day if universe_item.volume >= 100 and universe_item.volume_in_usd > 10000] def on_data(self, slice: Slice) -> None: if self.portfolio.cash_book['BTC'].amount == 0: free_cash = self.portfolio.cash_book['USD'].amount * (1-self.settings.free_portfolio_value_percentage) quantity = self.threshold*free_cash / slice[self.btcusd].price quantity -= quantity % self.minimum_order_size if quantity > 0: self.market_order(self.btcusd, quantity)