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 -29.475 Tracking Error 0.04 Treynor Ratio 0 Total Fees $0.00 |
class BootCampTask(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 10, 2) self.SetEndDate(2017, 10, 5) self.SetCash(100000) self.SetSecurityInitializer(self.CustomSecurityInitializer) tickers = ['TSLA', 'SPY'] self.symbol_data_by_symbol = {} for ticker in tickers: symbol = self.AddEquity(ticker, Resolution.Minute).Symbol self.symbol_data_by_symbol[symbol] = SymbolData() #self.Consolidate(symbol, timedelta(minutes=30), self.OnDataConsolidated) #3. Create a scheduled event triggered at 13:30 calling the ClosePositions function #schedule_symbol = list(self.symbol_data_by_symbol.keys())[0] #self.Schedule.On(self.DateRules.EveryDay(schedule_symbol), self.TimeRules.At(13,30), self.ClosePositions) def CustomSecurityInitializer(self, security): security.SetDataNormalizationMode(DataNormalizationMode.Raw) def OnData(self, data): for symbol, symbol_data in self.symbol_data_by_symbol.items(): if not data.ContainsKey(symbol) or data[symbol] is None: continue # 1. Plot the current price to "Data Chart" on series "Asset Price" self.Plot("Data Chart", str(symbol), data[symbol].Close) #if symbol_data_by_symbol.openingBar is None: # continue #if not self.Portfolio.Invested: # self.MarketOrder("SPY", 500) # self.stopMarketTicket = self.StopMarketOrder("SPY", -500, 0.9 * self.Securities["SPY"].Close) #if data["TSLA"].Close > self.openingBar.High and not self.Portfolio.Invested: # self.Debug("high of 30m bar: " + str(self.openingBar.High)) # print the high of the 30 minute bar # self.Debug("opening price bar where signal triggered " + str(data["TSLA"].Open)) # print the opening of the first minute bar after the initial 30 minute bar # #self.SetHoldings("TSLA", .5) # invest half of cash into it # self.MarketOrder("TSLA", 500) # orders 500 shares # self.Debug("price paid avg: " + str(self.Portfolio["TSLA"].AveragePrice)) class SymbolData: def __init__(self): # Order ticket for our stop order, Datetime when stop order was last hit stopMarketTicket = None stopMarketOrderFillTime = datetime.min highestPrice = 0 openingBar = None