Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
6.263%
Drawdown
22.800%
Expectancy
0
Net Profit
9.506%
Sharpe Ratio
0.371
Probabilistic Sharpe Ratio
17.497%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0.981
Annual Standard Deviation
0.149
Annual Variance
0.022
Information Ratio
-0.276
Tracking Error
0.003
Treynor Ratio
0.056
Total Fees
$1.27
Estimated Strategy Capacity
$39000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
# region imports
from AlgorithmImports import *
# endregion

class ATRForum(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 2, 11)  
        # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.spy = self.AddEquity("SPY", Resolution.Minute)
        self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
        self.first = None
        # ATR
        self.atr = self.ATR("SPY", 14)
        self.SetWarmUp(timedelta(days = 20))

        atrConsolidator = TradeBarConsolidator(timedelta(days=1))
        self.SubscriptionManager.AddConsolidator(self.spy.Symbol, atrConsolidator)
        atrConsolidator.DataConsolidated += self.ATRDayBar
        self.barWindow = RollingWindow[TradeBar](1)


    def OnData(self, data: Slice):
        if not self.Portfolio.Invested:
            self.SetHoldings("SPY", 1)

        

    def IndicatorUpdateMethod(self, indicator: object, indicator_data_point: IndicatorDataPoint):
        if self.atr.IsReady:
            indicator_value = self.atr.Current.Value

    def ATRDayBar(self, sender, bar):
        if self.IsWarmingUp:
            return
        self.Plot("ATR", "ATR", self.atr.Current.Value)   
        if not self.first == self.Time.day:
            self.Log(self.atr)
            self.first = self.Time.day