Overall Statistics |
Total Trades 229 Average Win 3.09% Average Loss -1.17% Compounding Annual Return 11.493% Drawdown 23.000% Expectancy 0.466 Net Profit 72.418% Sharpe Ratio 0.732 Probabilistic Sharpe Ratio 24.747% Loss Rate 60% Win Rate 40% Profit-Loss Ratio 2.63 Alpha 0.082 Beta 0.429 Annual Standard Deviation 0.183 Annual Variance 0.034 Information Ratio 0.06 Tracking Error 0.197 Treynor Ratio 0.313 Total Fees $1660.26 |
from EtfSmaAlphaModel import EtfSmaAlphaModel class ParticleQuantumChamber(QCAlgorithm): def Initialize(self): self.SetStartDate(2015, 6, 15) self.SetEndDate(2020, 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.Hour)