Overall Statistics |
Total Trades 228 Average Win 1.05% Average Loss -2.06% Compounding Annual Return -99.763% Drawdown 83.400% Expectancy -0.576 Net Profit -79.480% Sharpe Ratio -0.589 Probabilistic Sharpe Ratio 0.685% Loss Rate 72% Win Rate 28% Profit-Loss Ratio 0.51 Alpha -0.766 Beta 0.738 Annual Standard Deviation 1.601 Annual Variance 2.562 Information Ratio -0.454 Tracking Error 1.547 Treynor Ratio -1.276 Total Fees $228.00 |
class SpyTrendAlphaModel(AlphaModel): def __init__(self): pass def OnSecuritiesChanged(self, algorithm, changes): self.symbols = [x.Symbol for x in changes.AddedSecurities] def Update(self, algorithm, data): insights = [] self.spy = ["SPY R735QTJ8XC9X"] for x in self.symbols: history = algorithm.History(self.symbols, 7, Resolution.Daily) price = history.loc["SPY"]["close"] TF_3 = price.pct_change(3)[-1] if TF_3 > 0: if x not in self.spy: insights.append(Insight.Price(x, timedelta(3), InsightDirection.Up)) return insights # for x in history: # # if x not in self.spy: # insights.append(Insight.Price(x, timedelta(1), InsightDirection.Up)) # # # # def CheckTrend(self, algorithm, data): # # # # return TF_check == 1 # else : # return TF_check == 0
# Inspired by the theory here: # https://seekingalpha.com/article/4299701-leveraged-etfs-for-long-term-investing import pandas as pd from SpyTrendAlphaModel import SpyTrendAlphaModel class MultidimensionalTransdimensionalPrism(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 2, 1) # Earliest start date for all ETFs in universe 2/1/10 self.SetEndDate(2020, 5, 6) self.SetCash(10000) symbols = [Symbol.Create("SPY", SecurityType.Equity, Market.USA), Symbol.Create("UST", SecurityType.Equity, Market.USA), Symbol.Create("TQQQ", SecurityType.Equity, Market.USA), Symbol.Create("UBT", SecurityType.Equity, Market.USA)] self.SetUniverseSelection(ManualUniverseSelectionModel(symbols)) self.SetAlpha(SpyTrendAlphaModel()) self.SetRiskManagement(CompositeRiskManagementModel( MaximumUnrealizedProfitPercentPerSecurity(0.2), MaximumDrawdownPercentPerSecurity(0.3) )) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) self.SetExecution(ImmediateExecutionModel()) self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday), self.TimeRules.At(12, 0), self.Sell) def Sell(self): self.Liquidate()