Overall Statistics |
Total Trades 7 Average Win 4.65% Average Loss -3.87% Compounding Annual Return -96.034% Drawdown 9.500% Expectancy -0.266 Net Profit -4.887% Sharpe Ratio -1.57 Probabilistic Sharpe Ratio 28.145% Loss Rate 67% Win Rate 33% Profit-Loss Ratio 1.20 Alpha 0.715 Beta 3.641 Annual Standard Deviation 0.579 Annual Variance 0.335 Information Ratio -1.031 Tracking Error 0.449 Treynor Ratio -0.249 Total Fees $32.06 Estimated Strategy Capacity $29000000.00 Lowest Capacity Asset TSLA UNU3P8Y3WFAD |
# Stop Loss and Take Profit # ----------------------------------- STOCK = "TSLA"; SL = 0.02; TP = 0.04; # ----------------------------------- class StopLossTakeProfit(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 4, 3) self.SetEndDate(2022, 4, 8) self.SetCash(1000000) self.stock = self.AddEquity(STOCK, Resolution.Minute).Symbol self.price = 0 def OnData(self, data): if self.Time.hour < 10 or self.Time.minute != 1: return if self.Time.hour >= 16 or self.Time.minute != 1: return if not self.Portfolio[self.stock].Invested: self.SetHoldings(self.stock, 1.0) self.price = data[self.stock].Price elif self.Portfolio[self.stock].Invested: if self.price > 0: curr_price = data[self.stock].Price if curr_price >= self.price*(1 + TP): self.Liquidate(self.stock, "Take Profit") self.price = 0 elif curr_price < self.price*(1 - SL): self.Liquidate(self.stock, "Stop Loss") self.price = 0