Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
6.251%
Drawdown
22.800%
Expectancy
0
Net Profit
9.506%
Sharpe Ratio
0.37
Probabilistic Sharpe Ratio
17.463%
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)

        # ATR
        self.atr = self.ATR("SPY", 14)
        self.Atr1day = AverageTrueRange(14)

        self.SetWarmUp(timedelta(days = 20))

        atrConsolidator = TradeBarConsolidator(timedelta(days=1))
        atrConsolidator.DataConsolidated += self.ATRDayBar

        self.SubscriptionManager.AddConsolidator(self.spy.Symbol, atrConsolidator)
        
        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):
        self.Atr1day.Update(bar)

    def OnEndOfDay(self, symbol):
       
       self.Plot('ATR', 'ATR Daily', self.Atr1day.Current.Value)