| Overall Statistics |
|
Total Trades 11 Average Win 38.72% Average Loss -2.95% Compounding Annual Return 40.264% Drawdown 24.400% Expectancy 7.482 Net Profit 139.899% Sharpe Ratio 1.2 Probabilistic Sharpe Ratio 53.753% Loss Rate 40% Win Rate 60% Profit-Loss Ratio 13.14 Alpha 0.272 Beta 0.319 Annual Standard Deviation 0.254 Annual Variance 0.064 Information Ratio 0.713 Tracking Error 0.283 Treynor Ratio 0.956 Total Fees $139.60 Estimated Strategy Capacity $79000000.00 Lowest Capacity Asset XON R735QTJ8XC9X |
# region imports
from AlgorithmImports import *
# endregion
class DonchianChannelBreakoutAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 1, 1)
self.SetEndDate(2022, 8, 1)
self.SetCash(100000)
self.symbol = self.AddEquity("XOM", Resolution.Daily).Symbol
self.EnableAutomaticIndicatorWarmUp = True
self.high = IndicatorExtensions.Of(Delay(1), self.MAX(self.symbol, 20, Resolution.Daily, Field.High))
self.low = IndicatorExtensions.Of(Delay(1), self.MIN(self.symbol, 20, Resolution.Daily, Field.Low))
self.can_short = False
def OnData(self, data: Slice):
if self.symbol not in data.Bars:
return
bar = data.Bars[self.symbol]
if bar.Close > self.high.Current.Value and not self.Portfolio[self.symbol].IsLong:
self.SetHoldings(self.symbol, 1)
elif bar.Close < self.low.Current.Value:
if self.can_short and not self.Portfolio[self.symbol].IsShort:
self.SetHoldings(self.symbol, -1)
if not self.can_short and self.Portfolio[self.symbol].IsLong:
self.SetHoldings(self.symbol, 0)