Overall Statistics |
Total Trades 586 Average Win 0.19% Average Loss -0.10% Compounding Annual Return 72.970% Drawdown 8.200% Expectancy 0.869 Net Profit 31.411% Sharpe Ratio 2.854 Probabilistic Sharpe Ratio 83.348% Loss Rate 33% Win Rate 67% Profit-Loss Ratio 1.77 Alpha 0.642 Beta -0.079 Annual Standard Deviation 0.215 Annual Variance 0.046 Information Ratio 1.019 Tracking Error 0.251 Treynor Ratio -7.781 Total Fees $791.58 Estimated Strategy Capacity $110000000.00 |
from random import random class RetrospectiveBrownDogfish(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 11, 5) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.UniverseSettings.Resolution = Resolution.Daily symbols = [ Symbol.Create(ticker, SecurityType.Equity, Market.USA) for ticker in ['SPY', 'TSLA', 'F', 'FB', 'XLK'] ] self.AddUniverseSelection( ManualUniverseSelectionModel(symbols) ) self.SetAlpha(MyAlpha()) self.SetPortfolioConstruction(BlackLittermanOptimizationPortfolioConstructionModel()) self.SetExecution(ImmediateExecutionModel()) class MyAlpha(AlphaModel): symbols = [] def Update(self, algorithm, data): insights = [] for symbol in self.symbols: if not (data.ContainsKey(symbol) and data[symbol] is not None): continue # The BlackLittermanOptimizationPortfolioConstructionModel uses the insight magnitude to optimize # the portfolio allocations magnitude = round(random(), 4) insight = Insight.Price(symbol, timedelta(days=1), InsightDirection.Up, magnitude, confidence=1, sourceModel='MyAlpha', weight=0.1) insights.append(insight) return insights def OnSecuritiesChanged(self, algorithm, changes): for security in changes.AddedSecurities: self.symbols.append(security.Symbol) for security in changes.RemovedSecurities: if security.Symbol in self.symbols: self.symbols.remove(security.Symbol)