Overall Statistics |
Total Trades 222 Average Win 9.90% Average Loss -1.05% Compounding Annual Return 13.482% Drawdown 31.100% Expectancy 1.718 Net Profit 500.753% Sharpe Ratio 0.762 Probabilistic Sharpe Ratio 13.908% Loss Rate 74% Win Rate 26% Profit-Loss Ratio 9.46 Alpha 0.098 Beta 0.534 Annual Standard Deviation 0.211 Annual Variance 0.044 Information Ratio 0.215 Tracking Error 0.204 Treynor Ratio 0.301 Total Fees $4387.66 |
from EtfSmaAlphaModel import EtfSmaAlphaModel class ParticleQuantumChamber(QCAlgorithm): def Initialize(self): self.SetStartDate(2006, 6, 15) self.SetCash(100000) self.sso = Symbol.Create('SSO', SecurityType.Equity, Market.USA) # SSO = 2x levered SPX self.shy = Symbol.Create('SHY', SecurityType.Equity, Market.USA) # SHY = short term Treasury ETF self.SetWarmup(200) self.SetBenchmark('SPY') self.UniverseSettings.Resolution = Resolution.Hour self.SetAlpha(EtfSmaAlphaModel(self.sso, self.shy)) self.SetUniverseSelection(ManualUniverseSelectionModel([self.sso, self.shy])) self.SetExecution(ImmediateExecutionModel()) self.SetBrokerageModel(AlphaStreamsBrokerageModel()) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
class EtfSmaAlphaModel(AlphaModel): def __init__(self, main_symbol, alt_symbol): self.main_symbol = main_symbol self.alt_symbol = alt_symbol self.day = -1 def Update(self, algorithm, data): if self.day == algorithm.Time.day or not algorithm.IsMarketOpen(self.main_symbol): return [] insights = [] if data.ContainsKey(self.main_symbol): period = timedelta(1) if data[self.main_symbol].Close > self.sma.Current.Value: insights.append(Insight.Price(self.main_symbol, period, InsightDirection.Up)) insights.append(Insight.Price(self.alt_symbol, period, InsightDirection.Flat)) else: insights.append(Insight.Price(self.alt_symbol, period, InsightDirection.Up)) insights.append(Insight.Price(self.main_symbol, period, InsightDirection.Flat)) if insights: self.day = algorithm.Time.day return insights def OnSecuritiesChanged(self, algorithm, changed): if self.main_symbol in [added.Symbol for added in changed.AddedSecurities]: self.sma = algorithm.SMA(self.main_symbol, 200, Resolution.Daily)