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 -8.672 Tracking Error 0.143 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
from AlgorithmImports import * import numpy as np class SimpleBreakoutExample(QCAlgorithm): def Initialize(self): self.SetCash(100000) self.SetStartDate(2022,8,31) self.SetEndDate(2022,9,10) self.symbol = self.AddEquity("PIXY", Resolution.Second).Symbol self.Consolidate(self.symbol, Resolution.Minute, self.BarHandler) self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.At(15, 0), self.Liquidate) self.opening1minBar = None def OnData(self, data): # if within 10 mins of first bar & price goes above opening1minhigh, buy and set stop loss at opening1minlow. if not self.Portfolio.Invested and self.opening1minBar is not None or data.Time.hour == 9 and data.Time.minute <= 11 and self.Securities[self.symbol].Close > self.opening1minBar.high: self.SetHoldings("PIXY", 1) stocknumber = self.CalculateOrderQuantity("PIXY", -1) self.Highprice = self.opening1minBar.High self.Quit() # trail exit price once the price exceeds a certain amount. if self.Portfolio.Invested: self.stopMarketTicket = self.StopMarketOrder("PIXY", stocknumber, self.opening1minBar.Low) if self.Securities["PIXY"].Close > self.Highprice: Highprice = self.Securities["PIXY"].Close updateFields = UpdateOrderFields() updateFields.StopPrice = self.Securities["PIXY"].Close * 0.9 self.stopMarketticket.Update(updateFields) def BarHandler(self, bar): if bar.Time.hour == 9 and bar.Time.minute == 1: self.opening1minBar = bar