Overall Statistics |
Total Orders 65 Average Win 4.76% Average Loss -1.29% Compounding Annual Return 10.027% Drawdown 17.500% Expectancy 0.609 Start Equity 1000000 End Equity 1504789.55 Net Profit 50.479% Sharpe Ratio 0.504 Sortino Ratio 0.459 Probabilistic Sharpe Ratio 22.747% Loss Rate 66% Win Rate 34% Profit-Loss Ratio 3.68 Alpha 0.023 Beta 0.321 Annual Standard Deviation 0.103 Annual Variance 0.011 Information Ratio -0.243 Tracking Error 0.15 Treynor Ratio 0.162 Total Fees $1044.65 Estimated Strategy Capacity $1000000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X Portfolio Turnover 4.16% |
# region imports from AlgorithmImports import * # endregion class QuantLeague(QCAlgorithm): def initialize(self): self.set_start_date(2020, 1, 1) self.set_cash(1000000) self.symbol = self.add_equity("SPY", Resolution.Daily).Symbol self.fast_moving_average = self.sma(self.symbol, 50, Resolution.Daily) self.last_action = None def on_data(self, data): # Ensure we have enough data to calculate the moving average if not self.fast_moving_average.is_ready: return price = data[self.symbol].Close # Buy if the price is above the moving average if price > self.fast_moving_average.current.value: if not self.portfolio.invested or self.last_action == "Sell": self.set_holdings(self.symbol, 1) self.last_action = "Buy" # Sell if the price is below the moving average elif price < self.fast_moving_average.current.value: if self.portfolio.invested and self.last_action == "Buy": self.liquidate(self.symbol) self.last_action = "Sell"