Overall Statistics |
Total Trades 13 Average Win 5.16% Average Loss -5.62% Compounding Annual Return 49.958% Drawdown 9.800% Expectancy 0.598 Net Profit 22.480% Sharpe Ratio 2.607 Probabilistic Sharpe Ratio 76.357% Loss Rate 17% Win Rate 83% Profit-Loss Ratio 0.92 Alpha 0.02 Beta 0.996 Annual Standard Deviation 0.208 Annual Variance 0.043 Information Ratio 2.184 Tracking Error 0.008 Treynor Ratio 0.544 Total Fees $23.14 |
class MultidimensionalDynamicComputer(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 4, 20) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.AddEquity("SPY", Resolution.Hour) self.BuyIn = 0.0 def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' CurrentPrice = self.Securities["SPY"].Price if not self.Portfolio.Invested: self.BuyIn = CurrentPrice self.SetHoldings("SPY", 1) # A market buy return if CurrentPrice > self.BuyIn*(1+0.05) or CurrentPrice < self.BuyIn*(1-0.05): # Sell/buy if +/- 5 pct from buy self.SetHoldings("SPY", 0) # A market sell return # Will repurchase upon next "OnData"