Overall Statistics |
Total Orders 1715 Average Win 0.42% Average Loss -0.38% Compounding Annual Return 2.013% Drawdown 35.400% Expectancy 0.006 Start Equity 100000 End Equity 102017.18 Net Profit 2.017% Sharpe Ratio 0.189 Sortino Ratio 0.224 Probabilistic Sharpe Ratio 16.582% Loss Rate 53% Win Rate 47% Profit-Loss Ratio 1.12 Alpha 0.201 Beta -0.863 Annual Standard Deviation 0.325 Annual Variance 0.106 Information Ratio -0.178 Tracking Error 0.562 Treynor Ratio -0.071 Total Fees $5787.70 Estimated Strategy Capacity $26000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X Portfolio Turnover 824.50% |
from AlgorithmImports import * class MultiResolutionAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) self.SetEndDate(2021, 1, 1) self.SetCash(100000) self.spy = self.AddEquity("SPY", Resolution.Hour) self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw) self.SetUniverseSelection(ManualUniverseSelectionModel(["SPY"])) self.SetAlpha(CompositeAlphaModel( HourlyStrategy(), DailyStrategy() )) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) self.SetExecution(ImmediateExecutionModel()) self.SetRiskManagement(NullRiskManagementModel()) def OnData(self, data): self.Log(f"OnData called at {self.Time}: Data type: {data.GetType().Name}") class HourlyStrategy(AlphaModel): def __init__(self): self.last_hour = None def Update(self, algorithm: QCAlgorithm, data: Slice) -> List[Insight]: if not data.ContainsKey("SPY"): return [] current_hour = algorithm.Time.hour if self.last_hour == current_hour: return [] self.last_hour = current_hour spy_data = data["SPY"] if spy_data is None or spy_data.Price == 0: return [] price = spy_data.Price insight = Insight.Price("SPY", timedelta(hours=1), InsightDirection.Up if current_hour % 2 == 0 else InsightDirection.Down) algorithm.Log(f"Hourly Strategy: Generated {'Up' if current_hour % 2 == 0 else 'Down'} insight at {algorithm.Time}. Price: {price}") return [insight] class DailyStrategy(AlphaModel): def __init__(self): self.last_date = None def Update(self, algorithm: QCAlgorithm, data: Slice) -> List[Insight]: if not data.ContainsKey("SPY"): return [] current_date = algorithm.Time.date() if self.last_date == current_date: return [] self.last_date = current_date spy_data = data["SPY"] if spy_data is None or spy_data.Price == 0: return [] price = spy_data.Price insight = Insight.Price("SPY", timedelta(days=1), InsightDirection.Up if current_date.day % 2 == 0 else InsightDirection.Down) algorithm.Log(f"Daily Strategy: Generated {'Up' if current_date.day % 2 == 0 else 'Down'} insight at {algorithm.Time}. Price: {price}") return [insight]