I'm fairly new to Python as well as QuantConnect (previously a Javascript dev), and I'm needing help on this one.
I'm trying to get to where I have a List of Numpy arrays where each Numpy array has 20 rows of Historical data and indicators for each row. However, each subsequent array I want to have it's previous 19 bars of historical data for that bar. So kind of like this:
From data like this:
Datetime SMA EMA MACD RSI OpenPrice NextOpenPrice
9/3/19 12:55 35 34 8 3 34.17 35.01
9/3/19 12:50 34 33 9 2 33.18 34.17
9/3/19 12:45 32 33 8 3 32.48 33.18
9/3/19 12:40 32 32 9 3 32.12 32.48
I want the Numpy arrays to look like this:
print(resultset)
resultset[
array( [ [ 35, 34, 8, 3, 34.17, 35.01],
[ 34, 33, 9, 2, 33.18, 34.17],[ 32, 33, 8, 3, 32.48, 33.18],
[ . . . ]
[ ---total of 20 rows-- ],
[ . . . ],
[ 27, 28, 5, 1, 26.48, 26.89] ] ),
array( [ [ 34, 33, 9, 2, 33.18, 34.17], <----Notice how this next array starts on the second row of the first array
[ 32, 33, 8, 3, 32.48, 33.18],[ 32, 32, 9, 3, 32.12, 32.48],
[ . . . ]
[ ---total of 20 rows-- ],
[ . . . ],
[ 26, 27, 4, 1, 26.13, 26.48] ] ),
. . .
---nparrays for each group of bars back 240 bars---
---meaning a rolling group of 20 bars for each 240 bars---
. . .
]
I'm having trouble adding the indicators to the historical data as well as figuring out how to get those rolling 20 bars into each array.
You'll also notice I have the times in increments of 5 minutes. I'm also having trouble getting both history data and indicators matched up correctly on increments of 5 minutes.
I know I'm supposed to use a Consolidator, but I can't figure out how to get that to work for history and indicators and the times be matched up correctly.
I hope this makes sense and someone can help me
Thank you