| Overall Statistics |
|
Total Trades 116 Average Win 10.80% Average Loss -1.64% Compounding Annual Return 201.266% Drawdown 44.000% Expectancy 1.885 Net Profit 260.963% Sharpe Ratio 2.018 Loss Rate 62% Win Rate 38% Profit-Loss Ratio 6.60 Alpha 0.894 Beta -0.405 Annual Standard Deviation 0.423 Annual Variance 0.179 Information Ratio 1.731 Tracking Error 0.437 Treynor Ratio -2.107 Total Fees $3618.85 |
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(2016, 6, 1) #Set Start Date
self.SetEndDate(2017, 7, 1) #Set End Date
self.SetCash(10000) #Set Strategy Cash
self.SetBrokerageModel(BrokerageName.GDAX)
self.AddCrypto("BTCUSD", Resolution.Daily)
# create a bollinger band
self.Bolband = self.BB("BTCUSD", 20, 2, MovingAverageType.Simple, Resolution.Daily)
# set warmup period
self.SetWarmUp(20)
def OnData(self, data):
holdings = self.Portfolio["BTCUSD"].Quantity
price = self.Securities["BTCUSD"].Close
# buy if price closes above upper bollinger band
if holdings <= 0:
if price > self.Bolband.LowerBand.Current.Value:
self.SetHoldings("BTCUSD", 1.0)
# sell if price closes below middle bollinger band
if holdings > 0 and price < self.Bolband.MiddleBand.Current.Value:
self.Liquidate()