Overall Statistics |
Total Trades 2447 Average Win 0.00% Average Loss 0.00% Compounding Annual Return 0.008% Drawdown 0.200% Expectancy 0.019 Net Profit 0.078% Sharpe Ratio 0.098 Probabilistic Sharpe Ratio 0.031% Loss Rate 56% Win Rate 44% Profit-Loss Ratio 1.30 Alpha -0 Beta 0.002 Annual Standard Deviation 0.001 Annual Variance 0 Information Ratio -0.887 Tracking Error 0.134 Treynor Ratio 0.035 Total Fees $2468.40 Estimated Strategy Capacity $4800000000.00 Lowest Capacity Asset AAPL R735QTJ8XC9X |
class CreativeTanFly(QCAlgorithm): def Initialize(self): self.SetStartDate(2012, 1, 1) # Set Start Date self.SetCash(1000000) # Set Strategy Cash self.AddUniverse(self.CoarseSelectionFilter) self.UniverseSettings.Resolution = Resolution.Minute self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw self.symbol_data_by_symbol={} def CoarseSelectionFilter(self, coarse): sortedByDollarVolume = sorted(coarse, key=lambda c: c.DollarVolume, reverse=True) return [x.Symbol for x in sortedByDollarVolume[:10]] def OnSecuritiesChanged(self, changes): for security in changes.RemovedSecurities: symbol = security.Symbol if security.Invested: self.Liquidate(symbol) symbol_data = self.symbol_data_by_symbol.pop(symbol, None) if symbol_data: symbol_data.dispose() for security in changes.AddedSecurities: symbol = security.Symbol self.symbol_data_by_symbol[symbol] = SymbolData(self, symbol) def OnData(self, data): for symbol, symbol_data in self.symbol_data_by_symbol.items(): if not (data.ContainsKey(symbol) and data[symbol] is not None and symbol_data.openingBar is not None and symbol_data.fhmin is not None): return # if current price greater than open at 1% - open long position if not self.Portfolio[symbol].Invested: if (self.Time.hour>=12): if (data[symbol].Close > symbol_data.openingBar.Open*(1+1.6/100) and not symbol_data.wastrade): self.SetHoldings(symbol, 1/500) symbol_data.wastrade = True else: # close if current price less than 1HMin. if ((self.Time.hour==10 and self.Time.minute >=30) or (self.Time.hour>10)): if (data[symbol].Low < symbol_data.fhmin): self.Liquidate(symbol) class SymbolData: openingBar = None def __init__(self, algorithm, symbol): self.algorithm = algorithm self.symbol = symbol self.fhmin = None self.wastrade = False # Setup minute consolidator self.five_minute_consolidator = TradeBarConsolidator(timedelta(minutes=5)) self.five_minute_consolidator.DataConsolidated += self.five_minute_consolidation_handler algorithm.SubscriptionManager.AddConsolidator(symbol, self.five_minute_consolidator) def five_minute_consolidation_handler(self, sender, bar): if bar.Time.hour == 9 and bar.Time.minute == 30: self.openingBar = bar self.fhmin = bar.Low self.wastrade = False else: if (bar.Time.hour == 9 and bar.Time.minute >30) or (bar.Time.hour==10 and bar.Time.minute <=30): if (self.fhmin!= None and bar.Low < self.fhmin): self.fhmin = bar.Low def dispose(self): self.algorithm.SubscriptionManager.RemoveConsolidator(self.symbol, self.five_minute_consolidator)