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 Probabilistic 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 -4.327 Tracking Error 0.138 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class FiveOneFractalBreakoutCopy(QCAlgorithm): consolidator_by_symbol = {} def Initialize(self): self.SetStartDate(2021, 12, 1) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.contracts = [] self.symbolData = dict() for ticker in [ Futures.Metals.Gold, Futures.Energies.CrudeOilWTI, Futures.Metals.Copper, Futures.Energies.NaturalGas, Futures.Indices.NASDAQ100EMini]: future = self.AddFuture(ticker, Resolution.Minute) future.SetFilter(lambda x: x.FrontMonth().OnlyApplyFilterAtMarketOpen()) # VARIABLES & LIST # THESE DICTIONARY NAMES CANNOT CHANGE. THE CUSTOM LIBRARY DEPENDS ON IT... self.rulesDict = {} self.bearFiveDict = {} self.bullFiveDict = {} self.bullOneDict = {} self.bearOneDict = {} self.FiveUpDict = {} self.FiveDownDict = {} self.first_lowDict = {} self.second_lowDict = {} self.first_highDict = {} self.second_highDict = {} #Used to check if the first trade in a thesis was a loser. self.bull_losing_outcomeDict = {} self.bear_losing_outcomeDict = {} #A set of variables used to limit re-entries to only happen once per thesis self.first_position_bullDict = {} self.second_position_bullDict = {} self.first_position_bearDict = {} self.second_position_bearDict = {} #Used for making sure re-entries happen on a new fractal self.entry_minuteDict = {} #DIRECTION VARIABLES self.supportDict = {} self.resistanceDict = {} self.breakoutDict = {} self.breakdownDict = {} # ORDER VARIABLES self.short_stopDict = {} self.second_short_stopDict = {} self.long_stopDict = {} self.second_long_stopDict = {} self.long_entryDict = {} self.second_long_entryDict = {} self.short_entryDict = {} self.second_short_entryDict = {} self.long_exitDict = {} self.second_long_exitDict = {} self.short_exitDict = {} self.second_short_exitDict = {} self.longOrdersDict = {} self.shortOrdersDict = {} self.partial_exit_fill_safety_longDict = {} self.partial_fill_liq_priceDict = {} self.partial_exit_fill_safety_shortDict = {} self.risk_targetDict = {} self.buying_powerDict = {} self.share_sizeDict = {} self.dollar_sizeDict = {} self.max_price_longDict = {} self.max_price_shortDict = {} self.trading_hoursDict = {} self.symbolEntryPriceDict = {} self.symbolStopPriceDict = {} self.symbolExitPriceDict = {} self.longDict = {} self.shortDict = {} self.portfolioAmmount = self.Portfolio.Cash def OnSecuritiesChanged(self, changes): for security in changes.AddedSecurities: contractString = str(security.Symbol) # Don't consolidate or add the actual future. if contractString[0] == "/": continue market = contractString.split()[0] # Don't add the same contract twice. if security.Symbol in self.consolidator_by_symbol.keys(): continue # Create list of symbol strings. stringContracts = [] for prevContract in self.consolidator_by_symbol.keys(): stringContracts.append(str(prevContract)) # Only allow one contract per Future to be added. if any(market in s for s in stringContracts): continue # Make check to ensure it's only adding valid contracts. # When converting a symbol to a string the string length is normally 15 characters long for valid contracts. # This check is probably unnecessary. if (len(contractString) > 10): self.Log("Adding consolidator for: " + str(security.Symbol)) # Set the Rolling Windows for the contract self.symbolData[security.Symbol] = SymbolData() # Consolidate the contract consolidator = QuoteBarConsolidator(timedelta(minutes=5)) consolidator.DataConsolidated += self.OnDataConsolidated self.SubscriptionManager.AddConsolidator(security.Symbol, consolidator) # Add contract consolidator to dictionary self.consolidator_by_symbol[security.Symbol] = consolidator # Add contract to contract list. self.contracts.append(security.Symbol) def OnDataConsolidated(self, sender, quoteBar): pass class SymbolData(object): def __init__(self): self.quickTradeBarWindow = RollingWindow[QuoteBar](5) self.longTradeBarWindow = RollingWindow[QuoteBar](5)