Overall Statistics |
Total Trades 1389 Average Win 0.16% Average Loss -0.17% Compounding Annual Return 12.884% Drawdown 4.100% Expectancy 0.097 Net Profit 11.790% Sharpe Ratio 1.678 Probabilistic Sharpe Ratio 75.419% Loss Rate 43% Win Rate 57% Profit-Loss Ratio 0.93 Alpha 0 Beta 0 Annual Standard Deviation 0.053 Annual Variance 0.003 Information Ratio 1.678 Tracking Error 0.053 Treynor Ratio 0 Total Fees $1779.25 Estimated Strategy Capacity $94000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# Take Profit and Stop Loss with UnrealizedProfit # https://www.quantconnect.com/forum/discussion/12754/stop-market-and-limit-order-both-filling-how-to-manage-sl-and-tp # ------------------------------------------------ STOCK = 'SPY'; LEV = 1.00; PT = 0.004; SL = -0.004; # ------------------------------------------------ class MuscularSkyBlueLlama(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetCash(100000) self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) self.stock = self.AddEquity(STOCK, Resolution.Hour).Symbol def OnData(self, data): if not self.IsMarketOpen(self.stock): return pnl = self.Portfolio[self.stock].UnrealizedProfit if not self.Securities[self.stock].Invested: self.SetHoldings(self.stock, LEV) elif self.Securities[self.stock].Invested: if pnl >= PT or pnl < SL: self.SetHoldings(self.stock, 0)