Overall Statistics |
Total Trades 10 Average Win 0.01% Average Loss -5.34% Compounding Annual Return -2.767% Drawdown 21.000% Expectancy -0.800 Net Profit -0.926% Sharpe Ratio 0.106 Probabilistic Sharpe Ratio 28.560% Loss Rate 80% Win Rate 20% Profit-Loss Ratio 0.00 Alpha 0.026 Beta -0.132 Annual Standard Deviation 0.343 Annual Variance 0.118 Information Ratio 0.171 Tracking Error 0.657 Treynor Ratio -0.277 Total Fees $14.14 |
class VerticalNadionGearbox(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 2, 20) # Set Start Date self.SetCash(100000) # Set Strategy Cash symbols = [ Symbol.Create("SPY", SecurityType.Equity, Market.USA) ] self.SetUniverseSelection( ManualUniverseSelectionModel(symbols) ) self.UniverseSettings.Resolution = Resolution.Daily self.AddAlpha(MyAlphaModel(symbols[0])) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) self.SetRiskManagement(MaximumDrawdownPercentPerSecurityCustom(0.05)) self.SetExecution(ImmediateExecutionModel()) class MyAlphaModel(AlphaModel): def __init__(self, symbol): self.symbol = symbol def Update(self, algorithm, data): if algorithm.Portfolio.Invested: return [] return [Insight.Price("SPY", timedelta(365), InsightDirection.Up)] class MaximumDrawdownPercentPerSecurityCustom(RiskManagementModel): def __init__(self, maximumDrawdownPercent = 0.05, reenter_after_days = 5): self.maximumDrawdownPercent = -abs(maximumDrawdownPercent) self.liquidated_dates_by_symbol = {} self.reenter_after_days = timedelta(reenter_after_days) def ManageRisk(self, algorithm, targets): symbols_to_pop = [] for symbol, liquidation_date in self.liquidated_dates_by_symbol.items(): if algorithm.Time - liquidation_date >= self.reenter_after_days: symbols_to_pop.append(symbol) for symbol in symbols_to_pop: self.liquidated_dates_by_symbol.pop(symbol, None) targets = [] for kvp in algorithm.Securities: security = kvp.Value pnl = security.Holdings.UnrealizedProfitPercent if pnl < self.maximumDrawdownPercent or security.Symbol in self.liquidated_dates_by_symbol: # liquidate targets.append(PortfolioTarget(security.Symbol, 0)) if algorithm.Securities[security.Symbol].Invested: self.liquidated_dates_by_symbol[security.Symbol] = algorithm.Time return targets