Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-76.045%
Drawdown
23.600%
Expectancy
0
Net Profit
-11.313%
Sharpe Ratio
-1.504
Probabilistic Sharpe Ratio
10.396%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.155
Beta
1.806
Annual Standard Deviation
0.436
Annual Variance
0.19
Information Ratio
-1.309
Tracking Error
0.289
Treynor Ratio
-0.363
Total Fees
$3.79
Estimated Strategy Capacity
$180000000.00
Lowest Capacity Asset
AAPL R735QTJ8XC9X
# region imports
from AlgorithmImports import *
# endregion

class ATRForum(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 9, 1)  # Set Start Date
        self.SetEndDate(2020, 10, 1)
        
        self.SetCash(100000)  # Set Strategy Cash
        self.spy = self.AddEquity("AAPL", Resolution.Minute)
        self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw)

        # ATR
        self.atr = self.ATR("AAPL", 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("AAPL", 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)