Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.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): for x in self.symbols: history = algorithm.History(x, 7, Resolution.Daily) price = history["close"] TF_3 = price.pct_change(3)[-1] if TF_3 > 0: return Insight.Price(price.index[0][0], timedelta(1), InsightDirection.Up) else : return Insight.Price(price.index[0][0], timedelta(1), InsightDirection.Down)
# 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("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(NullExecutionModel())