Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 2.460% Drawdown 0.000% Expectancy 0 Net Profit 0.077% Sharpe Ratio 12.55 Probabilistic Sharpe Ratio 99.323% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.017 Beta 0.011 Annual Standard Deviation 0.002 Annual Variance 0 Information Ratio -6.809 Tracking Error 0.063 Treynor Ratio 2.015 Total Fees $1.00 Estimated Strategy Capacity $790000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
class MuscularFluorescentOrangeParrot(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 8, 1) self.SetCash(100000) self.AddEquity("SPY", Resolution.Hour) # variable tracking "in-market" time self.inMarketTime = 0 self.previousinMarketTime = None # variable tracking total time self.startTime = self.Time def OnData(self, data): # add "in-market" time if we're invested in something if self.Portfolio.Invested: if self.previousinMarketTime: self.inMarketTime += (self.Time - self.previousinMarketTime).total_seconds() self.previousinMarketTime = self.Time else: self.previousinMarketTime = None # variable of % of time we're invested in something self.percentageTimeInMarket = self.inMarketTime / (self.Time - self.startTime).total_seconds() # log the message self.Log(f'Overall in market time % is {self.percentageTimeInMarket*100}%') # hold SPY to test if self.Time.day == 5: self.SetHoldings("SPY", 0.1)