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 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 |
import numpy as np from datetime import timedelta ### <summary> ### The algorithm selects the crypto with a clear trend over the three resolutions of 1, 5 and 15 minutes, looks at the rate of return and returns the crypto with the highest rate of return ### The algo buys that crypto and follows the trend with a trailing stop loss untill the stop loss at twice the standard . ### </summary> class BasicTemplateAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' # Set the market and brokerage model self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash) #initialize Dates etc self.SetStartDate(2017, 12, 10) #Set Start Date self.SetEndDate(2017, 12, 12) #Set End Date self.SetCash(5000) #Set Strategy Cash #All Crypto Pairs #Add currencies Crypto = self.AddCrypto("BTCUSD", Resolution.Minute) self._Symbol=Crypto.Symbol consolidator5=TradeBarConsolidator(timedelta(minutes=5)) self._low20 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] #Add 5 Minute Consolidation self.SubscriptionManager.AddConsolidator(self._Symbol, consolidator5) consolidator5.DataConsolidated += self.FiveMinuteBarHandler #self.RegisterIndicator("BTCUSD", self.low, consolidator5) self._bb = self.BB(self._Symbol, 20, 2, MovingAverageType.Simple, Resolution.Minute); self._rsi = self.RSI(self._Symbol, 14, MovingAverageType.Simple, Resolution.Minute); self.RegisterIndicator(self._Symbol, self._rsi, consolidator5) self._adx=self.ADX(self._Symbol, 14) def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. ''' #history = self.History(self._5MinuteBar, 20) #self.lowhistory = history.loc[self._5MinuteBar] # print the price of the three currencies if not self.Portfolio.Invested: self.Log("The price is at time {0}".format(self.Time)) #self.SetHoldings(format(self._Symbol[0]), 1.0) def FiveMinuteBarHandler(self, sender, bar): self._low20[0] = bar.Low for i in range(0,18): self._low20[i+1] = self._low20[i] #self.Debug(str(self.Time) + " > New Bar! and the low is ")