Overall Statistics
Total Trades
1076
Average Win
0.85%
Average Loss
-0.76%
Compounding Annual Return
5.394%
Drawdown
22.000%
Expectancy
0.057
Net Profit
21.913%
Sharpe Ratio
0.389
Probabilistic Sharpe Ratio
7.544%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
1.12
Alpha
0.016
Beta
0.216
Annual Standard Deviation
0.112
Annual Variance
0.012
Information Ratio
-0.474
Tracking Error
0.173
Treynor Ratio
0.201
Total Fees
$4523.67
Estimated Strategy Capacity
$17000000.00
Lowest Capacity Asset
MSFT R735QTJ8XC9X

class EmotionalFluorescentPinkSalmon(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 1)
        self.SetEndDate(2021, 10, 8)
        self.SetCash(100000)
        self.atr = {}; 
        self.atr_norm = {};
        symbols = ["AMZN", "MSFT", "AAPL"]
        self.stocks = [self.AddEquity(ticker, Resolution.Minute).Symbol for ticker in symbols]
        for sec in self.stocks:
            self.atr[sec] = self.ATR(sec, 14, MovingAverageType.Simple, Resolution.Daily)
        self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
        self.SetWarmUp(15, Resolution.Daily)
        self.yest_close = self.SMA(self.spy, 1, Resolution.Daily, Field.Close)

            
    def OnData(self, data):
        if self.IsWarmingUp or not self.yest_close.IsReady or not len(data.Bars) > 0: return 

        for sec in self.stocks:
            if not self.atr[sec].IsReady: continue
            atr_curr = self.atr[sec].Current.Value
            price = self.Securities[sec].Price
            self.atr_norm[sec] = atr_curr/price
            self.Plot("ATR", sec, self.atr_norm[sec])
            
        selected_atrs = {k: v for k, v in sorted(self.atr_norm.items(), key=lambda item: item[1], reverse=True)[-1:]}
        portfolio_targets = []
        for sec, volt in self.atr_norm.items():
            if sec in selected_atrs:
                portfolio_targets.append(sec)

        if self.Time.hour == 9 and self.Time.minute == 45:
            for sec in portfolio_targets:
                price = self.Securities[self.spy].Price
                yest_close = self.yest_close.Current.Value
                if price > yest_close:
                    self.SetHoldings(sec, 1/len(portfolio_targets))
        
        if self.Time.hour == 15 and self.Time.minute == 45:
            self.Liquidate()