Overall Statistics |
Total Orders 781 Average Win 0.42% Average Loss -0.37% Compounding Annual Return 18.320% Drawdown 6.000% Expectancy 0.129 Start Equity 100000 End Equity 118247.49 Net Profit 18.247% Sharpe Ratio 1.055 Sortino Ratio 1.46 Probabilistic Sharpe Ratio 57.612% Loss Rate 47% Win Rate 53% Profit-Loss Ratio 1.11 Alpha 0.129 Beta 0.14 Annual Standard Deviation 0.105 Annual Variance 0.011 Information Ratio 1.204 Tracking Error 0.201 Treynor Ratio 0.794 Total Fees $819.25 Estimated Strategy Capacity $7000000.00 Lowest Capacity Asset ATH S9AP9FK1TBHH Portfolio Turnover 22.12% |
from AlgorithmImports import * class ShortingYesterdayTopDailyGainers(QCAlgorithm): def initialize(self): self.set_start_date(2022, 1, 1) self.set_end_date(2022, 12, 31) self.universe_settings.schedule.on(self.date_rules.week_start()) self._universe = self.add_universe(self.selection) self.schedule.on(self.date_rules.week_start(), self.time_rules.at(9, 31), self.rebalance) self.last_prices = None self.short = [] self.long = [] def selection(self, fundamental): selected = [] prices = pd.DataFrame([[f.symbol, f.adjusted_price, f.market_cap] for f in fundamental], columns=["Symbol", "Price", "Cap"]).set_index("Symbol") prices = prices[(prices["Cap"] >= 1e11) & (prices["Price"] >= 5)] if isinstance(self.last_prices, pd.DataFrame) and not self.last_prices.empty: pct_chg = (prices - self.last_prices).dropna() self.short = list(pct_chg.nlargest(5, 'Price').index) self.long = list(pct_chg.nsmallest(5, 'Price').index) self.last_prices = prices return self.short + self.long def rebalance(self): self.set_holdings([PortfolioTarget(symbol, -0.1) for symbol in self.short] \ + [PortfolioTarget(symbol, 0.1) for symbol in self.long] \ + [PortfolioTarget(symbol, 0.) for symbol in self.securities.keys() if symbol not in self.short + self.long])