Hi All,

Ive been digging through the docs but i cant seem to find an answer to this simply. I'm running a simple system where we add the bar data to a rolling window every time it comes in using the method shown in the documentationand all i want to do is turn the rolling window with the tradebardata into a dataframe with the indexs as open high low close volume but using the  pd.Dataframe method never seems to work for me and I cant seem to get the thing working, can someone tell me what im doing wrong?

cheers

Matt

 

# region imports

from AlgorithmImports import *

import tensorflow

import pandas as pd

import statistics


 

# endregion


 

class HyperActiveRedViper(QCAlgorithm):


 

    def Initialize(self):

        self.SetStartDate(2022, 6, 20)  # Set Start Date

        self.SetCash(100000)  # Set Strategy Cash

        self.AddEquity("SPY", Resolution.Minute)

        self.counter = 0

        self.State = None


 

        # Create a Rolling Window to keep the 2 TradeBar

        self.tradeBarWindow  = RollingWindow[TradeBar](10000)


 

        self.SetWarmUp(10000) #warm up 10000 bars


 

# In OnData, update the rolling windows

    def OnData(self,slice):


 

        #first we check the data for this slice to see if it has data for our ticker in it

        #if so then we add the data to our rolling window.


 

        if slice.ContainsKey("SPY"):

            self.tradeBarWindow.Add(slice["SPY"])


 

        #Next we take the rolling window and move it to a dataframe


 

        df = pd.DataFrame(self.tradeBarWindow)


 

        self.Debug(df)


 

        #Now we run the calculations to create our interpretation columns for the ML model to predict on.


 

        df['Change'] = df.apply(lambda row: self.calculate_price_change(row), axis = 1)


 

        #self.calculate_close_bar_shape(self.tradeBarWindow[0])

        #self.calculate_open_bar_shape(self.tradeBarWindow[0])


 

        if len(self.tradeBarWindow) > 10001:

            self.Quit()