Overall Statistics
Total Orders
2023
Average Win
0.30%
Average Loss
-0.28%
Compounding Annual Return
25.081%
Drawdown
25.500%
Expectancy
0.129
Start Equity
1000000
End Equity
1406748.31
Net Profit
40.675%
Sharpe Ratio
0.598
Sortino Ratio
0.755
Probabilistic Sharpe Ratio
34.755%
Loss Rate
45%
Win Rate
55%
Profit-Loss Ratio
1.07
Alpha
-0.009
Beta
1.422
Annual Standard Deviation
0.252
Annual Variance
0.064
Information Ratio
0.184
Tracking Error
0.209
Treynor Ratio
0.106
Total Fees
$16517.37
Estimated Strategy Capacity
$11000000.00
Lowest Capacity Asset
GFS XT0JK4MKIDET
Portfolio Turnover
26.65%
from AlgorithmImports import *

class ShortingYesterdayTopDailyGainers(QCAlgorithm):

    def initialize(self):
        self.set_cash(1_000_000)
        self.set_start_date(2023, 2, 13)
        etf = self.add_equity("QQQ").symbol
        self.add_universe(self.universe.etf(etf))
        self.settings.rebalance_portfolio_on_insight_changes = False
        self.universe_settings.schedule.on(self.date_rules.month_start())
        self.schedule.on(self.date_rules.every_day(etf), self.time_rules.before_market_close(etf, 1), self.store_closes)
        self.schedule.on(self.date_rules.every_day(etf), self.time_rules.after_market_open(etf, 1), self.gap_check)
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())
        self.closes = {}
        self.gap_size = float(self.get_parameter("gap_size", 5))/100
        self.insight_period = int(float(self.get_parameter("insight_period", 10)))
        
    def store_closes(self):
        self.closes = {security : security.price for security in self.active_securities.values if security.price > 0}

    def gap_check(self):
        if not self.closes: return
        gap = {security.symbol: ((security.price - close) / close) for (security, close) in self.closes.items() \
               if ((security.price - close) / close) > self.gap_size}
        gap_rank = list(dict(sorted(gap.items(), key=lambda item: item[1], reverse=True)).keys())[:10]
        self.emit_insights([Insight.price(symbol, timedelta(self.insight_period), InsightDirection.UP) for symbol in gap_rank])