Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 25.536% Drawdown 5.500% Expectancy 0 Net Profit 23.260% Sharpe Ratio 1.671 Probabilistic Sharpe Ratio 72.812% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0.106 Annual Variance 0.011 Information Ratio 1.671 Tracking Error 0.106 Treynor Ratio 0 Total Fees $1.34 Estimated Strategy Capacity $88000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# Take Profit and Stop Loss with LastTradeProfit # 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.Minute).Symbol def OnData(self, data): if not self.IsMarketOpen(self.stock): return pnl = self.Portfolio[self.stock].LastTradeProfit 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)