Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 7.998% Drawdown 57.900% Expectancy 0 Net Profit 8.749% Sharpe Ratio 0.467 Probabilistic Sharpe Ratio 23.417% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.324 Beta -0.273 Annual Standard Deviation 0.615 Annual Variance 0.378 Information Ratio 0.216 Tracking Error 0.699 Treynor Ratio -1.049 Total Fees $0.00 |
from clr import AddReference AddReference("System") AddReference("QuantConnect.Algorithm") AddReference("QuantConnect.Common") AddReference("QuantConnect.Indicators") from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Brokerages import * from QuantConnect.Orders import * from QuantConnect.Indicators import * import decimal as d ### <summary> ### In this example we are looking for price to breakout above the bollinger bands ### and look to buy when we see that. We hold our position until price touches the ### middle band of the bollinger bands. ### class BollingerBreakoutAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 6, 1) #Set Start Date self.SetEndDate(2020, 7, 1) #Set End Date self.SetCash(100000) #Set Strategy Cash self.SetCash('BTC', 100) #self.SetBrokerageModel(BrokerageName.GDAX) self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash) # define crypto we want to trade on # ETHUSD, LTCUSD or BTCUSD self.target_crypto = "ETHBTC" self.AddCrypto(self.target_crypto, Resolution.Daily) # create a bollinger band self.Bolband = self.BB(self.target_crypto, 20, 2, MovingAverageType.Simple, Resolution.Daily) # Plot Bollinger band self.PlotIndicator( "Indicators", self.Bolband.LowerBand, self.Bolband.MiddleBand, self.Bolband.UpperBand, ) # create a momentum indicator over 3 days self.mom = self.MOM(self.target_crypto, 5) #self.mom = self.MOM(self.target_crypto, 3) # Plot Momentum self.PlotIndicator( "Indicators", self.mom ) # set warmup period self.SetWarmUp(20) def OnData(self, data): holdings = self.Portfolio[self.target_crypto].Quantity price = self.Securities[self.target_crypto].Close mom = self.mom.Current.Value # buy if price closes above upper bollinger band if holdings <= 0: if price < self.Bolband.LowerBand.Current.Value: #num = self.GetBuyingPower("BTCUSD", OrderDirection.Buy) self.SetHoldings(self.target_crypto, 1) # sell if price closes below middle bollinger band if holdings > 0 and price > self.Bolband.UpperBand.Current.Value: self.Liquidate()