Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-6.8
Tracking Error
0.624
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
class RollingWindowAlgorithm(QCAlgorithm):

    def Initialize(self):
        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

        self.SetStartDate(2021,2,1)  #Set Start Date
        self.SetEndDate(2021,4,21)  #Set End Date
        self.SetCash(25000)           #Set Strategy Cash
      
        self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
        self.AddCrypto("BTCUSD", Resolution.Minute) # Subscribe to minutely QuoteBars in Initialize(self)

        # Creates a Rolling Window indicator to keep the 2 QuoteBar
        self.window = RollingWindow[QuoteBar](2)    # For other security types, use QuoteBar
     
        # Creates an indicator and adds to a rolling window when it is updated
        self.SMA("BTCUSD", 50).Updated += self.SmaUpdated
        self.smaWin = RollingWindow[IndicatorDataPoint](50)
        
        self.SetBenchmark("BTCUSD")
        
        self.SetWarmUp(50)

    def SmaUpdated(self, sender, updated):
        '''Adds updated values to rolling window'''
        self.smaWin.Add(updated)

    def OnData(self, data):
        '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.'''
        
        # Add Quotebar in rollling window
        if data.QuoteBars.ContainsKey("BTCUSD"):
        # Add EURUSD QuoteBar in rolling window
            self.window.Add(data.QuoteBars['BTCUSD'])
        
        # Wait for windows to be ready.
        if not (self.window.IsReady and self.smaWin.IsReady): return

    def OnEndOfDay(self):
        self.Plot("Window", "Count", self.window.Count)